summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-01-11 12:35:47 +0100
commit19985dbb8c0aa66dc4bf7905abc1148de909097d (patch)
tree2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /main
download1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst
1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip
Diffstat (limited to 'main')
-rw-r--r--main/.htaccess1
-rw-r--r--main/survey/ajax.php33
-rw-r--r--main/survey/app/.htaccess3
-rw-r--r--main/survey/app/Controllers/AjaxController.php708
-rw-r--r--main/survey/app/Controllers/BodyController.php2458
-rw-r--r--main/survey/app/Controllers/CheckController.php774
-rw-r--r--main/survey/app/Controllers/Controller.php113
-rw-r--r--main/survey/app/Controllers/DisplayController.php864
-rw-r--r--main/survey/app/Controllers/FindController.php290
-rw-r--r--main/survey/app/Controllers/HeaderController.php920
-rw-r--r--main/survey/app/Controllers/HelperController.php747
-rw-r--r--main/survey/app/Controllers/InitClass.php1230
-rw-r--r--main/survey/app/Controllers/JsController.php2835
-rw-r--r--main/survey/app/Controllers/LanguageController.php196
-rw-r--r--main/survey/app/Controllers/StatisticController.php282
-rw-r--r--main/survey/app/Controllers/SurveyController.php76
-rw-r--r--main/survey/app/Controllers/VariableClass.php193
-rw-r--r--main/survey/app/Controllers/Vprasanja/ComputeController.php55
-rw-r--r--main/survey/app/Controllers/Vprasanja/DatumController.php187
-rw-r--r--main/survey/app/Controllers/Vprasanja/DoubleController.php841
-rw-r--r--main/survey/app/Controllers/Vprasanja/DragDropController.php914
-rw-r--r--main/survey/app/Controllers/Vprasanja/DynamicController.php725
-rw-r--r--main/survey/app/Controllers/Vprasanja/HeatMapController.php242
-rw-r--r--main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php856
-rw-r--r--main/survey/app/Controllers/Vprasanja/ImenaController.php160
-rw-r--r--main/survey/app/Controllers/Vprasanja/MapsController.php364
-rw-r--r--main/survey/app/Controllers/Vprasanja/MaxDiffController.php295
-rw-r--r--main/survey/app/Controllers/Vprasanja/MultigridController.php1686
-rw-r--r--main/survey/app/Controllers/Vprasanja/MultigridMobileController.php1621
-rw-r--r--main/survey/app/Controllers/Vprasanja/NumberController.php372
-rw-r--r--main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php291
-rw-r--r--main/survey/app/Controllers/Vprasanja/QuotaController.php57
-rw-r--r--main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php521
-rw-r--r--main/survey/app/Controllers/Vprasanja/RankingController.php1021
-rw-r--r--main/survey/app/Controllers/Vprasanja/SystemVariableController.php62
-rw-r--r--main/survey/app/Controllers/Vprasanja/TextController.php1022
-rw-r--r--main/survey/app/Controllers/Vprasanja/VprasanjaController.php944
-rw-r--r--main/survey/app/Controllers/Vprasanja/VsotaController.php112
-rw-r--r--main/survey/app/Models/Model.php308
-rw-r--r--main/survey/app/Models/SaveSurvey.php1628
-rw-r--r--main/survey/app/Models/User.php58
-rw-r--r--main/survey/app/bootstrap.php104
-rw-r--r--main/survey/app/config.php49
-rw-r--r--main/survey/app/global_function.php70
-rw-r--r--main/survey/app/use_classes.php59
-rw-r--r--main/survey/download.php48
-rw-r--r--main/survey/edit_anketa.php29
-rw-r--r--main/survey/embed_out.php9
-rw-r--r--main/survey/image.php410
-rw-r--r--main/survey/index.php41
-rw-r--r--main/survey/js/ChartJS/Chart.bundle.js18608
-rw-r--r--main/survey/js/ChartJS/Chart.bundle.min.js10
-rw-r--r--main/survey/js/ChartJS/Chart.js14145
-rw-r--r--main/survey/js/ChartJS/Chart.min.js10
-rw-r--r--main/survey/js/ChartJS/chart_init.js260
-rw-r--r--main/survey/js/DragDrop/dragdrop.js1550
-rw-r--r--main/survey/js/DragDrop/dragdropbox.js951
-rw-r--r--main/survey/js/Fotografiranje/FotoDeclaration.js82
-rw-r--r--main/survey/js/Fotografiranje/webcam.js833
-rw-r--r--main/survey/js/Fotografiranje/webcam.swfbin0 -> 7090 bytes
-rw-r--r--main/survey/js/HeatMap/HeatMapCanvas.js285
-rw-r--r--main/survey/js/HeatMap/heatmap4Respondents.js13
-rw-r--r--main/survey/js/ImageHotSpot/imagemapRespondent.js859
-rw-r--r--main/survey/js/Maps/Geocoding.js92
-rw-r--r--main/survey/js/Maps/KlikNaMapo.js43
-rw-r--r--main/survey/js/Maps/MapDeclaration.js323
-rw-r--r--main/survey/js/Maps/Markers.js317
-rw-r--r--main/survey/js/Maps/SearchBox.js78
-rw-r--r--main/survey/js/Maps/ShapeDrawing.js397
-rw-r--r--main/survey/js/Maps/UserLocation.js94
-rw-r--r--main/survey/js/custom_column_label_respondent.js98
-rw-r--r--main/survey/js/customizeImageView4Respondent.js355
-rw-r--r--main/survey/js/dhtmlgoodies_calendar.js1518
-rw-r--r--main/survey/js/script.js1971
-rw-r--r--main/survey/js/signature/LICENSE.txt27
-rw-r--r--main/survey/js/signature/flashcanvas.js28
-rw-r--r--main/survey/js/signature/flashcanvas.swfbin0 -> 21235 bytes
-rw-r--r--main/survey/js/signature/jquery.signaturepad.js895
-rw-r--r--main/survey/js/signature_pad.js323
-rw-r--r--main/survey/js/tooltipster.min.js1
-rw-r--r--main/survey/js/trak_respondent.js67
-rw-r--r--main/survey/mobile-detect/Mobile_Detect.php767
-rw-r--r--main/survey/sa_koda.php45
-rw-r--r--main/survey/skins/1ka.css256
-rw-r--r--main/survey/skins/1ka/close.pngbin0 -> 275 bytes
-rw-r--r--main/survey/skins/1ka/header.pngbin0 -> 87 bytes
-rw-r--r--main/survey/skins/1ka/header_new.pngbin0 -> 89 bytes
-rw-r--r--main/survey/skins/1ka/header_new2.pngbin0 -> 3574 bytes
-rw-r--r--main/survey/skins/1ka/logo.pngbin0 -> 758 bytes
-rw-r--r--main/survey/skins/1ka/logo_full.pngbin0 -> 3178 bytes
-rw-r--r--main/survey/skins/1ka/logo_full_ang.pngbin0 -> 3041 bytes
-rw-r--r--main/survey/skins/1ka/logo_full_old.pngbin0 -> 2522 bytes
-rw-r--r--main/survey/skins/1ka/plus.pngbin0 -> 290 bytes
-rw-r--r--main/survey/skins/1kaBlack.css529
-rw-r--r--main/survey/skins/1kaBlue.css529
-rw-r--r--main/survey/skins/1kaGreen.css529
-rw-r--r--main/survey/skins/1kaGrey.css442
-rw-r--r--main/survey/skins/1kaNature.css564
-rw-r--r--main/survey/skins/1kaNature/bg1.jpgbin0 -> 139961 bytes
-rw-r--r--main/survey/skins/1kaNature/bg10.jpgbin0 -> 446729 bytes
-rw-r--r--main/survey/skins/1kaNature/bg11.jpgbin0 -> 356184 bytes
-rw-r--r--main/survey/skins/1kaNature/bg12.jpgbin0 -> 114309 bytes
-rw-r--r--main/survey/skins/1kaNature/bg13.jpgbin0 -> 256582 bytes
-rw-r--r--main/survey/skins/1kaNature/bg14.jpgbin0 -> 191577 bytes
-rw-r--r--main/survey/skins/1kaNature/bg15.jpgbin0 -> 207375 bytes
-rw-r--r--main/survey/skins/1kaNature/bg2.jpgbin0 -> 206042 bytes
-rw-r--r--main/survey/skins/1kaNature/bg3.jpgbin0 -> 238650 bytes
-rw-r--r--main/survey/skins/1kaNature/bg4.jpgbin0 -> 347652 bytes
-rw-r--r--main/survey/skins/1kaNature/bg5.jpgbin0 -> 455253 bytes
-rw-r--r--main/survey/skins/1kaNature/bg6.jpgbin0 -> 490365 bytes
-rw-r--r--main/survey/skins/1kaNature/bg7.jpgbin0 -> 247379 bytes
-rw-r--r--main/survey/skins/1kaNature/bg8.jpgbin0 -> 275981 bytes
-rw-r--r--main/survey/skins/1kaNature/bg9.jpgbin0 -> 434561 bytes
-rw-r--r--main/survey/skins/1kaOffice.css564
-rw-r--r--main/survey/skins/1kaOffice/bg1.jpgbin0 -> 143807 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg10.jpgbin0 -> 223837 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg11.jpgbin0 -> 98822 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg12.jpgbin0 -> 246860 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg13.jpgbin0 -> 259740 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg14.jpgbin0 -> 264281 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg15.jpgbin0 -> 109271 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg2.jpgbin0 -> 127853 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg3.jpgbin0 -> 85775 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg4.jpgbin0 -> 142542 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg5.jpgbin0 -> 226242 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg6.jpgbin0 -> 110841 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg7.jpgbin0 -> 110699 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg8.jpgbin0 -> 64086 bytes
-rw-r--r--main/survey/skins/1kaOffice/bg9.jpgbin0 -> 111881 bytes
-rw-r--r--main/survey/skins/1kaOrange.css529
-rw-r--r--main/survey/skins/1kaPurple.css529
-rw-r--r--main/survey/skins/1kaRed.css529
-rw-r--r--main/survey/skins/1ka_customsortables.css286
-rw-r--r--main/survey/skins/1ka_customsortables/close.pngbin0 -> 275 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/header.pngbin0 -> 87 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/header_new.pngbin0 -> 89 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/header_new2.pngbin0 -> 3574 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/logo.pngbin0 -> 758 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/logo_full.pngbin0 -> 3178 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/logo_full_ang.pngbin0 -> 3041 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/logo_full_old.pngbin0 -> 2522 bytes
-rw-r--r--main/survey/skins/1ka_customsortables/plus.pngbin0 -> 290 bytes
-rw-r--r--main/survey/skins/Classic.css243
-rw-r--r--main/survey/skins/Classic2.css244
-rw-r--r--main/survey/skins/Classic3.css239
-rw-r--r--main/survey/skins/Classic4.css240
-rw-r--r--main/survey/skins/Classic5.css242
-rw-r--r--main/survey/skins/Colorful.css127
-rw-r--r--main/survey/skins/Default.css92
-rw-r--r--main/survey/skins/Embed.css64
-rw-r--r--main/survey/skins/Embed2.css72
-rw-r--r--main/survey/skins/Fdv.css534
-rw-r--r--main/survey/skins/Mobile.css220
-rw-r--r--main/survey/skins/Mobile2.css219
-rw-r--r--main/survey/skins/Mobile3.css219
-rw-r--r--main/survey/skins/Mobile4.css219
-rw-r--r--main/survey/skins/Mobile5.css219
-rw-r--r--main/survey/skins/MobileBlack.css228
-rw-r--r--main/survey/skins/MobileBlue.css227
-rw-r--r--main/survey/skins/MobileCdi.css237
-rw-r--r--main/survey/skins/MobileFdv.css233
-rw-r--r--main/survey/skins/MobileGreen.css227
-rw-r--r--main/survey/skins/MobileOrange.css227
-rw-r--r--main/survey/skins/MobilePurple.css228
-rw-r--r--main/survey/skins/MobileRed.css228
-rw-r--r--main/survey/skins/MobileUni.css233
-rw-r--r--main/survey/skins/Modern.css105
-rw-r--r--main/survey/skins/Modern/add.pngbin0 -> 733 bytes
-rw-r--r--main/survey/skins/Modern/arrow.pngbin0 -> 967 bytes
-rw-r--r--main/survey/skins/Modern/arrowD.pngbin0 -> 964 bytes
-rw-r--r--main/survey/skins/Modern/arrowD2.pngbin0 -> 3823 bytes
-rw-r--r--main/survey/skins/Modern/arrowL.pngbin0 -> 995 bytes
-rw-r--r--main/survey/skins/Modern/arrowL2.pngbin0 -> 3782 bytes
-rw-r--r--main/survey/skins/Modern/arrowR.pngbin0 -> 991 bytes
-rw-r--r--main/survey/skins/Modern/arrowR2.pngbin0 -> 3798 bytes
-rw-r--r--main/survey/skins/Modern/arrowU.pngbin0 -> 878 bytes
-rw-r--r--main/survey/skins/Modern/arrowU2.pngbin0 -> 3733 bytes
-rw-r--r--main/survey/skins/Modern/background.jpgbin0 -> 366 bytes
-rw-r--r--main/survey/skins/Modern/blue_delete.pngbin0 -> 715 bytes
-rw-r--r--main/survey/skins/Oko.css328
-rw-r--r--main/survey/skins/Oko2.css328
-rw-r--r--main/survey/skins/Otroci.css329
-rw-r--r--main/survey/skins/Otroci/nadaljuj-kasneje.pngbin0 -> 3814 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-3-desno.pngbin0 -> 17420 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-3-footer.pngbin0 -> 2127 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-3-levo.pngbin0 -> 27907 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-3-top.pngbin0 -> 13715 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-4-desno.pngbin0 -> 17420 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-4-footer.pngbin0 -> 41434 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-4-top.pngbin0 -> 13260 bytes
-rw-r--r--main/survey/skins/Otroci/otroci-logo.pngbin0 -> 6315 bytes
-rw-r--r--main/survey/skins/Otroci2.css329
-rw-r--r--main/survey/skins/Otroci3.css309
-rw-r--r--main/survey/skins/Otroci4.css293
-rw-r--r--main/survey/skins/Otroci_Safe/nadaljuj-kasneje.pngbin0 -> 648 bytes
-rw-r--r--main/survey/skins/Otroci_Safe/otroci-1.pngbin0 -> 137 bytes
-rw-r--r--main/survey/skins/Otroci_Safe/otroci-2-figure.pngbin0 -> 4127 bytes
-rw-r--r--main/survey/skins/Otroci_Safe/otroci-2.pngbin0 -> 137 bytes
-rw-r--r--main/survey/skins/Otroci_Safe/otroci-figure.pngbin0 -> 4031 bytes
-rw-r--r--main/survey/skins/Otroci_Safe/otroci-logo.pngbin0 -> 6315 bytes
-rw-r--r--main/survey/skins/Slideshow.css111
-rw-r--r--main/survey/skins/Uni.css534
-rw-r--r--main/survey/skins/check-radio/box_checked_blue.pngbin0 -> 2124 bytes
-rw-r--r--main/survey/skins/check-radio/box_checked_grey.pngbin0 -> 1823 bytes
-rw-r--r--main/survey/skins/check-radio/box_empty_blue.pngbin0 -> 549 bytes
-rw-r--r--main/survey/skins/check-radio/box_empty_grey.pngbin0 -> 619 bytes
-rw-r--r--main/survey/skins/check-radio/icons.pngbin0 -> 135673 bytes
-rw-r--r--main/survey/skins/check-radio/icons.psdbin0 -> 623426 bytes
-rw-r--r--main/survey/skins/check-radio/radio_checked_blue.pngbin0 -> 2633 bytes
-rw-r--r--main/survey/skins/check-radio/radio_checked_grey.pngbin0 -> 2628 bytes
-rw-r--r--main/survey/skins/check-radio/radio_unchecked_blue.pngbin0 -> 1506 bytes
-rw-r--r--main/survey/skins/check-radio/radio_unchecked_grey.pngbin0 -> 1886 bytes
-rw-r--r--main/survey/skins/check-radio/smiley_happy_blue.pngbin0 -> 2487 bytes
-rw-r--r--main/survey/skins/check-radio/smiley_happy_grey.pngbin0 -> 2691 bytes
-rw-r--r--main/survey/skins/check-radio/star_blue.pngbin0 -> 1970 bytes
-rw-r--r--main/survey/skins/check-radio/star_empty_blue.pngbin0 -> 2718 bytes
-rw-r--r--main/survey/skins/check-radio/thumbs_up.pngbin0 -> 2171 bytes
-rw-r--r--main/survey/skins/check-radio/thumbs_up_blue.pngbin0 -> 2548 bytes
-rw-r--r--main/survey/skins/fdv/fdv.pngbin0 -> 7263 bytes
-rw-r--r--main/survey/skins/glasovanje/Classic.css58
-rw-r--r--main/survey/skins/glasovanje/Modern.css45
-rw-r--r--main/survey/skins/quiz/false.pngbin0 -> 15987 bytes
-rw-r--r--main/survey/skins/quiz/quiz.css62
-rw-r--r--main/survey/skins/quiz/true.pngbin0 -> 16065 bytes
-rw-r--r--main/survey/skins/quiz/true2.pngbin0 -> 16128 bytes
-rw-r--r--main/survey/skins/tooltipster/tooltipster.css288
-rw-r--r--main/survey/skins/uni/uni.pngbin0 -> 2831 bytes
-rw-r--r--main/survey/uporabnost.php44
-rw-r--r--main/survey/view_count.php16
229 files changed, 85655 insertions, 0 deletions
diff --git a/main/.htaccess b/main/.htaccess
new file mode 100644
index 0000000..b0e37d7
--- /dev/null
+++ b/main/.htaccess
@@ -0,0 +1 @@
+RewriteEngine Off \ No newline at end of file
diff --git a/main/survey/ajax.php b/main/survey/ajax.php
new file mode 100644
index 0000000..4027393
--- /dev/null
+++ b/main/survey/ajax.php
@@ -0,0 +1,33 @@
+<?php
+
+include_once('../../function.php');
+include_once('../../vendor/autoload.php');
+
+
+// pod do /main/survey/ - kot ROOT direktorij
+define('MAIN', __DIR__ . DIRECTORY_SEPARATOR);
+
+//direktorij app
+define('APP', MAIN . 'app' . DIRECTORY_SEPARATOR);
+
+
+// Nastavitve, kjer določamo PHP debuging/error
+require APP . 'config.php';
+new App\Controllers\Controller();
+
+// Definicija vseh spremenljiv, ki jih uporabljamo med razredi
+new App\Controllers\VariableClass();
+require_once(APP.'global_function.php');
+
+// začetek aplikacije
+new \App\Controllers\SurveyController(true);
+
+// Poklicemo ustrezen ajax
+if ($_GET['t'] == 'parapodatki') {
+ SurveyAdvancedParadataLog::getInstance()->ajax();
+}
+else {
+ new \App\Controllers\AjaxController();
+}
+
+?> \ No newline at end of file
diff --git a/main/survey/app/.htaccess b/main/survey/app/.htaccess
new file mode 100644
index 0000000..05cd49a
--- /dev/null
+++ b/main/survey/app/.htaccess
@@ -0,0 +1,3 @@
+# Ne dovolimo direktnega dostopa do tega direktorija
+
+deny from al
diff --git a/main/survey/app/Controllers/AjaxController.php b/main/survey/app/Controllers/AjaxController.php
new file mode 100644
index 0000000..33662e4
--- /dev/null
+++ b/main/survey/app/Controllers/AjaxController.php
@@ -0,0 +1,708 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+// Osnovni razredi
+use App\Controllers\StatisticController as Statistic;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Models\Model;
+use Common;
+use Branching;
+use SurveyAdvancedParadataLog;
+use SurveySetting;
+use MailAdapter;
+use GDPR;
+
+
+class AjaxController extends Controller
+{
+ //ajax zahteve
+ public function __construct()
+ {
+ if(empty($_GET['a'])){
+ return '';
+ }
+ if ($_GET['a'] == 'accept_droppable') {
+ $this->ajax_accept_droppable();
+ } elseif ($_GET['a'] == 'accept_ranking') {
+ $this->ajax_accept_ranking();
+ } elseif ($_GET['a'] == 'accept_dragdrop1') {
+ $this->ajax_accept_dragdrop1();
+ } elseif ($_GET['a'] == 'get_dragdrop1_data') {
+ $this->ajax_get_dragdrop1_data();
+ } elseif ($_GET['a'] == 'delete_dragdrop1_data') {
+ $this->ajax_delete_dragdrop1_data();
+ } elseif ($_GET['a'] == 'delete_dragdrop2_data') {
+ $this->ajax_delete_dragdrop2_data();
+ } elseif ($_GET['a'] == 'accept_dragdrop_grid') {
+ $this->ajax_accept_dragdrop_grid();
+ } elseif ($_GET['a'] == 'accept_sortable_ranking') {
+ $this->ajax_accept_sortable_ranking();
+ } elseif ($_GET['a'] == 'edit_size') {
+ $this->ajax_edit_size();
+ } elseif ($_GET['a'] == 'dodaj_ime') {
+ $this->ajax_dodaj_ime();
+ } elseif ($_GET['a'] == 'spol') {
+ $this->ajax_glasovanje_spol();
+ } elseif ($_GET['a'] == 'vote_spol') {
+ $this->ajax_glasovanje_vote_spol();
+ } elseif ($_GET['a'] == 'captcha') {
+ $this->ajax_captcha();
+ } elseif ($_GET['a'] == 'skin') {
+ $this->ajax_skin();
+ } elseif ($_GET['a'] == 'grupa_for_if') {
+ $this->ajax_grupa_for_if();
+ } elseif ($_GET['a'] == 'enable_comments') {
+ $this->ajax_enable_comments();
+ } elseif ($_GET['a'] == 'continue_later') {
+ $this->ajax_continue_later();
+ } elseif ($_GET['a'] == 'continue_later_send') {
+ $this->ajax_continue_later_send();
+ } elseif ($_GET['a'] == 'usr_id_data') {
+ $this->ajax_delete_signature_data();
+ }elseif ($_GET['a'] == 'get_tip_opozorila') {
+ $this->ajax_get_tip_opozorila();
+ } // genericna resitev za vse nadaljne
+ else {
+ $ajax = 'ajax_' . $_GET['a'];
+ if (method_exists($this, $ajax))
+ return $this->$ajax ();
+ else
+ echo 'method ' . $ajax . ' does not exist';
+ }
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new AjaxController();
+ }
+
+ public function ajax_delete_signature_data()
+ {
+
+ $usr_id = $_POST['usr_id'];
+ $anketa = $_POST['anketa'];
+ $spr_id = $_POST['spr_id'];
+ $vre_id = $_POST['vre_id'];
+
+
+ //$sqlsignaturefilename = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . $usr_id . "'");
+ $sqlsignaturefilename = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . $usr_id . "' AND code = '" . $spr_id . "' ");
+
+ if (mysqli_num_rows($sqlsignaturefilename) > 0) {
+ $rowSignatureFilename = mysqli_fetch_array($sqlsignaturefilename);
+ $file_2_delete = $rowSignatureFilename[0];
+ }
+
+ //echo $file_2_delete;
+
+ //$path = self::$site_url.'main/survey/uploads/'.$file_2_delete; //tale varianta ne omogoča brisanje na disku
+ $path = survey_path('uploads/' . $file_2_delete);
+
+ //echo $path;
+
+ if (is_file($path)) { //če slikovna datoteka podpisa obstaja
+ unlink($path); //zbriši datoteko
+ }
+
+ //sisplet_query("DELETE FROM srv_data_upload WHERE usr_id='" . get('usr_id') . "' AND ank_id='$anketa'");//zbriši iz baze info datoteki podpisa
+ sisplet_query("DELETE FROM srv_data_upload WHERE usr_id='" . get('usr_id') . "' AND ank_id='$anketa' AND code='$spr_id'");//zbriši iz baze info datoteki podpisa
+ sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE usr_id='" . get('usr_id') . "' AND spr_id='$spr_id' AND vre_id='$vre_id'");//zbriši iz baze info o vnesenem imenu
+ }
+
+ // sprememba skina
+ public function ajax_skin()
+ {
+ $mobile = (int)$_GET['mobile'];
+ setcookie('mobile', $mobile, 0, '/');
+ header("Location: " . $_SERVER['HTTP_REFERER']);
+ }
+
+ //za izris vprasanj pri antonucci designu 1
+ public function ajax_edit_size()
+ {
+ $spremenljivka = $_POST['spremenljivka'];
+ $size = $_POST['size'];
+
+ //sisplet_query("UPDATE srv_spremenljivka SET size='$size' WHERE id='$spremenljivka'");
+
+ for ($i = 0; $i < $size; $i++) {
+ echo ' <p><input type="text" name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="40" onkeyup="checkBranching();" value=""></p>' . "\n";
+ }
+ }
+
+ //antonucci design 2
+ public function ajax_dodaj_ime()
+ {
+ $spremenljivka = $_POST['spremenljivka'];
+ $ime = $_POST['ime'];
+
+ //sisplet_query("UPDATE srv_spremenljivka SET size='$size' WHERE id='$spremenljivka'");
+
+ echo ' <p><input type="text" value="' . $ime . '" disabled=true name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="40" onkeyup="checkBranching();" value=""></p>' . "\n";
+
+ echo ' <p><input type="text" size="40" disabled=true></p>' . "\n";
+ echo ' <p><input type="text" size="40" disabled=true></p>' . "\n";
+ echo ' <p><input type="text" size="40" disabled=true></p>' . "\n";
+
+ }
+
+ public function ajax_accept_droppable()
+ {
+
+ $child = $_POST['child'];
+ $parent = $_POST['parent'];
+
+
+ if ($parent == 'half2_1') {
+ //poiscemo usr_id
+ $sql0 = sisplet_query("SELECT usr_id FROM srv_data_imena WHERE id='$child'");
+ $row0 = mysqli_fetch_array($sql0);
+ $usr_id = $row0[0];
+
+ //poiscemo najvecji count
+ $sql = sisplet_query("SELECT MAX(countE) FROM srv_data_imena WHERE (usr_id='" . get('usr_id') . "' AND (emotion=1 AND emotionINT=0))");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $count = $row['MAX(countE)'];
+ }
+
+ $count++;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotion=1, countE='$count' WHERE id='$child'");
+ } elseif ($parent == 'half2_2') {
+ //poiscemo usr_id
+ $sql0 = sisplet_query("SELECT usr_id FROM srv_data_imena WHERE id='$child'");
+ $row0 = mysqli_fetch_array($sql0);
+ $usr_id = $row0[0];
+
+ //poiscemo najvecji count
+ $sql = sisplet_query("SELECT MAX(countS) FROM srv_data_imena WHERE (usr_id='" . get('usr_id') . "' AND (social=1 AND socialINT=0))");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $count = $row['MAX(countS)'];
+ }
+
+ $count++;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET social=1, countS='$count' WHERE id='$child'");
+ } elseif ($parent == 'half2_3') {
+ $count = 1;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotionINT=1, countE='$count' WHERE id='$child'");
+ } elseif ($parent == 'half2_4') {
+ $count = 1;
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET socialINT=1, countS='$count' WHERE id='$child'");
+ } //leva stran - brisemo iz baze (emotion)
+ elseif ($parent == 'half_1') {
+ //preuredimo ostale counterje
+ $sql = sisplet_query("SELECT countE, usr_id FROM srv_data_imena WHERE id='$child'");
+ $row = mysqli_fetch_array($sql);
+
+ $counter = $row[0];
+ $usr_id = $row[1];
+
+ $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND (countE > '$counter') ORDER BY countE");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $count = $row1['countE'];
+ $count--;
+ sisplet_query("UPDATE srv_data_imena SET countE='$count' WHERE id='$row1[id]'");
+ }
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotion=0, countE=0 WHERE id='$child'");
+ } //leva stran - brisemo iz baze (druzenje)
+ elseif ($parent == 'half_2') {
+ //preuredimo ostale counterje
+ $sql = sisplet_query("SELECT countS, usr_id FROM srv_data_imena WHERE id='$child'");
+ $row = mysqli_fetch_array($sql);
+
+ $counter = $row[0];
+ $usr_id = $row[1];
+
+ $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND (countS > '$counter') ORDER BY countS");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $count = $row1['countS'];
+ $count--;
+ sisplet_query("UPDATE srv_data_imena SET countS='$count' WHERE id='$row1[id]'");
+ }
+
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET social=0, countS=0 WHERE id='$child'");
+ } //leva stran - brisemo iz baze (emotionINT)
+ elseif ($parent == 'half_3') {
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET emotionINT=0, countE=0 WHERE id='$child'");
+ } //leva stran - brisemo iz baze (druzenjeINT)
+ elseif ($parent == 'half_4') {
+ //update baze
+ sisplet_query("UPDATE srv_data_imena SET socialINT=0, countS=0 WHERE id='$child'");
+ }
+
+
+ //izpisemo ime v divu po loadu
+ $sql1 = sisplet_query("SELECT text FROM srv_data_imena WHERE id='$child'");
+ $value = mysqli_fetch_array($sql1);
+
+ echo $value[0];
+
+ }
+
+ /**
+ * @desc poskrbi za shranjevanje vrednosti 99,98,97
+ */
+
+ //zapisovanje v bazo pri ranking dropih (n>k, n=k)
+ public function ajax_accept_ranking()
+ {
+
+
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $order = $_POST['order'];
+
+ // Popravimo da se po ajax-u ohrani jezik
+ if (isset($_POST['lang_id'])) {
+ $lang_id = save('lang_id', $_POST['lang_id'], 1);
+
+ $file = lang_path($lang_id);
+ if (@include($file))
+ $_SESSION['langX'] = lang_path($lang_id, 1);
+ }
+
+ // Napredni parapodatki - za ranking je lažje če je kar tukaj
+ /*if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ SurveyAdvancedParadataLog::getInstance()->logData(0, $usr_id, 'data change', '', $spremenljivka, $order);
+ }*/
+
+ $exploded = explode('&', $order);
+
+ //najprej pobrisemo iz baze vse vnose
+ sisplet_query("DELETE FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+
+ //sortiranje (vnos v srv_data_rating)
+ $i = 1;
+ foreach ($exploded AS $key) {
+ $key = str_replace('handle_', '', $key);
+ $explode = explode('[]=', $key);
+
+ if ($explode[1] != 0)
+ sisplet_query("INSERT INTO srv_data_rating (spr_id, vre_id, usr_id, vrstni_red) VALUES ('$spremenljivka', '$explode[1]', '" . get('usr_id') . "', '$i')");
+
+ $i++;
+ }
+
+ Vprasanja::getInstance()->displayVnos($spremenljivka);
+
+ echo '<div id="clr" class="clr"></div>';
+
+ }
+
+ //zapisovanje v bazo in brisanje pri drag drop
+ public function ajax_accept_dragdrop1()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $vre_id = $_POST['vre_id'];
+ $usr_id = $_POST['usr_id'];
+ $anketa = $_POST['anketa'];
+ $data_calculation = $_POST['data_calculation'];
+ $tip = $_POST['tip'];
+ $cat_right = $_POST['cat_right'];
+ $other_present = $_POST['other_present'];
+ $other = $_POST['other'];
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ //( ( (tip == 1 && other == 0 && cat_right) ) || ( (tip == 2) && (other_present != 0) ) || ( (other != 0) ) )
+ if (($tip == 1 && $cat_right && $other == 0) || (($tip == 2) && ($other_present != 0)) || (($other != 0))) {
+ sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ }
+ sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "')");
+ }
+
+ //asinhrono pobiranje podatkov za ureditev missing
+ public function ajax_get_dragdrop1_data()
+ {
+ Model::user_not_lurker();
+ $anketa = $_GET['anketa'];
+ $spremenljivka = $_GET['spremenljivka'];
+ $vre_id = array();
+ //echo 'Spremenljivka: '.$spremenljivka;
+ //echo 'Anketa: '.$anketa;
+ //$sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other!=0 ");
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka'");
+ $num = mysqli_num_rows($sql1);
+
+ /* echo '
+ <script>
+ console.log('.$num.');
+ </script>
+ '; */
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ //$vre_id[$i] = $row1['id'];
+ array_push($vre_id, $row1['id']);
+ }
+ //echo 'Podatek je: '.$num;
+ //echo $vre_id;
+ echo json_encode($vre_id);
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop
+ public function ajax_delete_dragdrop1_data()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+
+ sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id'");
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop, ko imamo missing-e
+ public function ajax_delete_dragdrop2_data()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+
+ sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ }
+
+ //zapisovanje v bazo pri drag drop v grid
+ public function ajax_accept_dragdrop_grid()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $vre_id = $_POST['vre_id'];
+ $usr_id = $_POST['usr_id'];
+ $tip = $_POST['tip'];
+ $anketa = $_POST['anketa'];
+ $indeks = $_POST['indeks'];
+ $last_vre_id = $_POST['last_vre_id'];
+ $cat_right = $_POST['cat_right'];
+ $vre_id_present = $_POST['vre_id_present'];
+
+
+ //vnesi podatke v bazo
+ if ($tip == 6) {
+ sisplet_query("INSERT INTO srv_data_grid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "', '$indeks')");
+ } else if ($tip == 16) {
+ sisplet_query("INSERT INTO srv_data_checkgrid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id) VALUES ('$spremenljivka', '$vre_id', '" . get('usr_id') . "', '$indeks')");
+ }
+
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop - tabela - vec odgovorov
+ public function ajax_delete_dragdrop_grid_data()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+ $indeks = $_POST['indeks'];
+ //brisi podatke iz baze
+ sisplet_query("DELETE FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id' AND grd_id = '$indeks' ");
+
+ }
+
+ //brisanje odgovorov iz baze pri drag drop
+ public function ajax_delete_dragdrop_grid_data_1()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $vre_id = $_POST['vre_id'];
+ $anketa = $_POST['anketa'];
+ $indeks = $_POST['indeks'];
+
+ sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$vre_id' AND grd_id = '$indeks'");
+
+ }
+
+ //
+ //brisanje odgovorov iz baze pri drag drop grid, ko se klikne gumb Ponastavi
+ public function ajax_delete_dragdrop_grid_data_reset()
+ {
+ Model::user_not_lurker();
+
+ $spremenljivka = $_POST['spremenljivka'];
+ $usr_id = $_POST['usr_id'];
+ $anketa = $_POST['anketa'];
+ $tip = $_POST['tip'];
+
+ if($tip == 6){
+ sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' ");
+ }else if($tip == 16){
+ sisplet_query("DELETE FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' ");
+ }
+ }
+
+ // respondent se strinja z uporabo piskotvkov - nastavimo piskotek ok
+ public function ajax_cookie_ok()
+ {
+
+ setcookie('cookie_ok', '1', time() + 2500000, '/');
+
+ }
+
+ //izpis statistike glede na spol
+ public function ajax_glasovanje_spol()
+ {
+ $spremenljivka = $_POST['spremenljivka'];
+ $spol = $_POST['spol'];
+
+ Statistic::displayStatGlasovanje($spremenljivka, $spol);
+ }
+
+ /**
+ * preveri, ce je captcha koda pravilno vnesena (preko ajaxa)
+ *
+ */
+ public function ajax_captcha(){
+ global $secret_captcha;
+
+ $text = strtoupper($_GET['text']);
+ $code = $_GET['code'];
+ $spr_id = $_GET['spr_id'];
+ $usr_id = $_GET['usr_id'];
+
+ $recaptchaResponse = $_POST['g-recaptcha-response'];
+ $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse);
+
+ // zdaj pa zabeleži mail (pred pošiljanjem)
+ // zdaj pa še v bazi tistih ki so se ročno dodali
+ if(strstr($request,"true")){
+ echo '1';
+ }
+ else {
+ echo '0';
+ }
+ }
+
+ /**
+ * poisce v kateri grupi/strani se pojavi if za redirect tabov
+ *
+ */
+ public function ajax_grupa_for_if($parent = 0){
+
+ $parent_if = $_POST['parent_if'];
+ if ($parent > 0) $parent_if = $parent;
+
+ ob_start();
+
+ $b = new Branching(get('anketa'));
+ $spr = $b->find_first_in_if($parent_if);
+
+ ob_clean();
+
+ $row = Model::select_from_srv_spremenljivka($spr);
+
+ if ($parent == 0)
+ echo $row['gru_id'];
+
+ return $row['gru_id'];
+ }
+
+ /**
+ * vklopi komentarje na anketo (v previewu je ta možnost)
+ *
+ */
+ public function ajax_enable_comments(){
+
+ ob_clean();
+
+ SurveySetting::getInstance()->Init((int)$_POST['anketa']);
+
+ SurveySetting::getInstance()->setSurveyMiscSetting('question_resp_comment', '1');
+ SurveySetting::getInstance()->setSurveyMiscSetting('question_resp_comment_viewadminonly', '3');
+ }
+
+
+ public function ajax_continue_later(){
+
+ save('lang_id', (int)$_GET['language']);
+
+ $url = $_POST['url'] . '&return=1';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+
+ $srv_continue_later_txt = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later_txt' . $_lang);
+ if ($srv_continue_later_txt == '') $srv_continue_later_txt = self::$lang['srv_continue_later_txt'];
+
+ $srv_continue_later_email = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later_email' . $_lang);
+ if ($srv_continue_later_email == '') $srv_continue_later_email = self::$lang['srv_continue_later_email'];
+
+ $srv_forma_send = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_forma_send' . $_lang);
+ if ($srv_forma_send == '') $srv_forma_send = self::$lang['srv_forma_send'];
+
+ echo '<div id="continue_later">';
+
+ echo '<p>' . $srv_continue_later_txt . ':</p><p class="url">' . $url . '</p>';
+
+ echo '<input type="hidden" name="url" id="url" value="' . $url . '">';
+
+ echo '<p>' . $srv_continue_later_email . ': <input type="email" name="email" id="email" value="" placeholder="' . self::$lang['srv_email_example2'] . '"> <button type="submit" onclick="continue_later_send(\'' . self::$site_url . '\', \'' . get('lang_id') . '\'); return false;">' . $srv_forma_send . '</button></p>';
+
+ echo '</div>';
+ }
+
+ public function ajax_continue_later_send(){
+ global $mysql_database_name;
+
+ ob_clean();
+
+ $s = self::$lang['srv_continue_later_subject'];
+
+ if($mysql_database_name == 'vprasalnikirsrssi')
+ $t = self::$lang['srv_continue_later_content_rs-rs'] . ': <a href="' . $_POST['url'] . '">' . $_POST['url'] . '</a>';
+ else
+ $t = self::$lang['srv_continue_later_content'] . ': <a href="' . $_POST['url'] . '">' . $_POST['url'] . '</a>';
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+ $t .= $signature;
+
+ $mail = $_POST['email'];
+
+ if ($mail == '') return;
+
+ try {
+ $MA = new MailAdapter(get('anketa'), $type='alert');
+ $MA->addRecipients($mail);
+ $result = $MA->sendMail(stripslashes($t), $s);
+ }
+ catch (Exception $e) {
+ }
+ }
+
+ public function ajax_get_tip_opozorila() {
+ $spr_id = $_POST['spr_id'];
+
+ //poberi podatke o na trenutnem obmocju
+ $sqlR = sisplet_query("SELECT reminder FROM srv_validation WHERE spr_id = $spr_id");
+ $rowR = mysqli_fetch_assoc($sqlR);
+ $tip_opozorila = $rowR['reminder'];
+
+ echo $tip_opozorila;
+ }
+
+
+ // Izpisemo seznam starih odgovorov v popup (dodatna nastavitev pri text vprasanju)
+ public function ajax_show_prevAnswers_all() {
+
+ $spremenljivka = $_POST['spremenljivka'];
+
+ echo '<h3>'.self::$lang['srv_prevAnswers'].'</h3>';
+
+ $sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='".$spremenljivka."' AND usr_id!='".get('usr_id')."' ORDER BY id DESC");
+ while($row = mysqli_fetch_array($sql)){
+ echo '<p>';
+ echo $row['text'];
+ echo '</p>';
+ }
+
+ // Gumb zapri
+ echo '<div class="prevAnswers_button">';
+ echo '<a href="#" onClick="hide_prevAnswers_all(\''.$spremenljivka.'\'); return false;"><span>'.self::$lang['srv_zapri'].'</span></a>';
+ echo '</div>';
+
+ echo '<script>
+ $("#fade").on("click", function() {
+ hide_prevAnswers_all(\''.$spremenljivka.'\');
+ });</script>';
+ }
+
+ // Izpisemo seznam starih odgovorov v popup (dodatna nastavitev pri text vprasanju)
+ public function ajax_show_gdpr_about() {
+ global $lang;
+
+ $anketa = $_POST['anketa'];
+
+ $gdpr_settings = GDPR::getSurveySettings($anketa);
+
+ echo '<h3>'.$lang['srv_gdpr_survey_gdpr_about'].'</h3>';
+
+ if($gdpr_settings['about'] == ''){
+ $about_array = GDPR::getGDPRInfoArray($anketa);
+ $about_text = GDPR::getGDPRTextFromArray($about_array, $type='html');
+
+ echo $about_text;
+ }
+ else{
+ echo nl2br($gdpr_settings['about']);
+ }
+
+ echo '<br />';
+
+ // Gumb zapri
+ echo '<div class="prevAnswers_button">';
+ echo '<a href="#" onClick="hide_gdpr_about(); return false;"><span>'.$lang['srv_zapri'].'</span></a>';
+ echo '</div>';
+
+ echo '<script>
+ $("#fade").on("click", function() {
+ hide_gdpr_about();
+ });</script>';
+
+ echo '<br />';
+ }
+
+
+ // Shranimo vrstni red pri randomizaciji (blokov ali vprasanj)
+ public function ajax_save_randomization_order() {
+
+ $usr_id = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['usr_id']);
+ $randomization_type = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['randomization_type']);
+
+ $vrstni_red = stripcslashes($_POST['order']);
+ $vrstni_red = str_replace('"', "", substr($vrstni_red, 1, -1));
+
+ // Random vrstni red VPRASANJ oz. BLOKOV znotraj bloka
+ // ID bloka znotraj katerega so random elementi
+ $parent_block_id = mysqli_real_escape_string($GLOBALS['connect_db'], $_POST['parent_block_id']);
+
+ $sql = sisplet_query("INSERT INTO srv_data_random_blockContent
+ (usr_id, block_id, vrstni_red)
+ VALUES
+ ('".$usr_id."', '".$parent_block_id."', '".$vrstni_red."')
+ ON DUPLICATE KEY UPDATE vrstni_red='".$vrstni_red."'
+ ");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/BodyController.php b/main/survey/app/Controllers/BodyController.php
new file mode 100644
index 0000000..308b30c
--- /dev/null
+++ b/main/survey/app/Controllers/BodyController.php
@@ -0,0 +1,2458 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 08.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\DisplayController as Display;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\JsController as Js;
+use App\Controllers\StatisticController as Statistic;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Models\Model;
+use App\Models\SaveSurvey;
+use Hierarhija\Hierarhija;
+use SurveyAdvancedParadataLog;
+use SurveyInfo;
+use SurveySetting;
+use SurveyAdminSettings;
+use Common;
+use TrackingClass;
+use SurveyPanel;
+use SurveyQuiz;
+use SurveyGorenje;
+use SurveyNIJZ;
+use GDPR;
+use UserAccess;
+
+
+class BodyController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new BodyController();
+ }
+
+
+ /**
+ * @desc prikaze uvodni nagovor
+ */
+ public function displayIntroduction()
+ {
+ Header::getInstance()->displaySistemske();
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ if (!get('printPreview')) {
+ SaveSurvey::saveSistemske();
+ }
+
+ // datapiping
+ $row['introduction'] = Helper::dataPiping($row['introduction']);
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ // crn div za ozadje popupov
+ echo '<div id="fade"></div>';
+ echo '<div id="popup"></div>';
+
+
+ echo '<div class="outercontainer_holder ' . $class . ' intro">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . ' intro">';
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ if (!get('printPreview')) {
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+ }
+
+ // opozorilo ce urejamo ze reseno anketo
+ if (get('quick_view') == true) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_quick_view_text'];
+ echo '</div>';
+ }
+ // opozorilo ce urejamo ze reseno anketo
+ if (isset($_GET['urejanje'])) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_edit_text'];
+ echo '</div>';
+
+ // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno
+ ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE - Ce ni tega flusha, prvi klik na urejanje odpre poruseno stran (naknadni kliki so pa potem ok)
+ $sas = new SurveyAdminSettings();
+ $sas->checkFirstDataChange();
+
+ // Updatamo tracking (ker gre za editiranje odgovorov)
+ TrackingClass::update(get('anketa'), 4);
+ }
+
+ echo '<form method="post" action="' . SurveyInfo::getSurveyLink(false, false) . '&amp;grupa=0' . Header::getSurveyParams(true) . str_replace('&', '&amp;', get('cookie_url')) . '">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <input type="hidden" name="dummy" value="foo">' . "\n";
+ echo ' <input type="hidden" name="referer" value="' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . '">' . "\n";
+
+ $this->displayIntroductionContent();
+
+
+ if ($row['user_from_cms'] == 1 && $row['user_from_cms_email'] == 1) {
+
+ $sql1 = sisplet_query("SELECT user_id FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sqlu = Model::db_select_user($row1['user_id']);
+ $rowu = mysqli_fetch_array($sqlu);
+ if (mysqli_num_rows($sqlu) > 0) {
+ echo ' <div class="spremenljivka">' . "\n";
+ echo self::$lang['srv_recognized'] . ' <strong>' . $rowu['name'] . ' ' . $rowu['surname'] . '</strong>';
+ if ($row['user_from_cms_email'] == 1)
+ echo ' (' . $rowu['email'] . ')';
+ echo ' </div>' . "\n";
+ }
+ }
+
+ // koda za izponjevanje ankete (splosna - brez prepoznave userjev) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ $sqlp = sisplet_query("SELECT COUNT(*) AS count FROM srv_password WHERE ank_id='" . get('anketa') . "'");
+ $rowp = mysqli_fetch_array($sqlp);
+ if ($rowp['count'] > 0 && $userAccess->checkUserAccess($what='password')) {
+ echo ' <div class="spremenljivka">' . "\n";
+ echo ' <p>' . self::$lang['insert_password'] . ': <input type="text" name="password" value="' . (isset($_COOKIE['password_' . get('anketa')]) ? $_COOKIE['password_' . get('anketa')] : '') . '"></p>';
+ echo ' </div>' . "\n";
+ }
+
+ if ($row['user_base'] == 1
+ #če imamo neindividualizirana vabila - poslana preko vabil, vendar bez kode in zato brez sledenja (uporabnik se pri pošiljanju NE prenese iz srv_invitations_recipients v srv_user)
+ && $row['individual_invitation'] != 0
+ ) {
+
+ if (isset($_GET['code']))
+ $usercode = $_GET['code'];
+ else
+ $usercode = '';
+
+ if ($row['usercode_required'] == 1)
+ $usercode == '';
+
+ // �e ni nujno da vnesemo kodo usercode_skip = 1 ali 2
+ $canNotSkip = true;
+ if ($row['usercode_skip'] > 0) {
+ if ($row['usercode_skip'] == 1) { // lahko presko�imo kodo
+ $canNotSkip = false;
+ } elseif ($row['usercode_skip'] == 2) { // preverimo �e je uporabnik avtor ankete
+ $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'");
+ if (mysqli_num_rows($sqlUserAutor) > 0)
+ $canNotSkip = false;
+ }
+ }
+
+ // Ce smo v preview ali testnem vnosu in ce imamo vklopljeno da ne preverjamo kode
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on' && isset($_GET['disablecode']) && $_GET['disablecode'] == 1) {
+ $canNotSkip = false;
+ }
+
+ if ($usercode == '' && $canNotSkip || ($row['usercode_required'] == 1 /*&& $row['usercode_skip'] != 1*/)) {
+
+ $usercode_text = ($row['usercode_text'] != "") ? $row['usercode_text'] : self::$lang['srv_basecode'];
+ echo ' <div class="spremenljivka">' . "\n";
+ echo ' <p>' . $usercode_text . ': <input type="text" name="usercode" value="' . $usercode . '"></p>';
+ echo ' </div>' . "\n";
+ } else {
+ echo ' <input type="hidden" name="usercode" value="' . $usercode . '">';
+ }
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ // izbira jezika za respondenta
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $row['multilang'] == 1 && !get('printPreview')) {
+
+ $lang_resp = $row['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+
+ $file = lang_path($lang_resp);
+ include($file);
+ $lang_array[$lang['id']] = $lang['language'];
+
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ echo ' <div class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira jezika z dropdown menijem
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+ echo ' <h3>' . self::$lang['lang'] . ': ';
+ echo ' <select
+ name="language"
+ id="language"
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+
+ echo ' </select>';
+ echo '</h3>' . "\n";
+ }
+ // Izbira jezika z radio gumbi (default)
+ else {
+ echo '<h3>' . self::$lang['lang'] . ': </h3>';
+ echo '<span style="font-size:13px;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<label for="language_' . $key . '">';
+ echo '<input type="radio" name="language" id="language_' . $key . '"
+ value="' . $key . '"' . ($key == $current ? '
+ checked="checked"' : '') . '
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language_' . $key . '\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+
+ echo $val;
+
+ echo '</label><br />';
+ }
+ echo '</span>';
+ }
+
+
+ echo ' </div>' . "\n";
+
+ }
+
+ echo '</div>' . "\n"; // - grupa
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ if (get('lang_id') != null)
+ $_lang = '_' . get('lang_id');
+ else
+ $_lang = '';
+
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage_uvod' . $_lang);
+ $label = $srv_nextpage != '' ? $srv_nextpage : self::$lang['srv_nextpage_uvod'];
+
+ if (!get('printPreview')) {
+
+ // JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija
+ $survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
+ if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){
+ $js_submit = ' onclick="';
+
+ if($survey_privacy == 2)
+ $js_submit .= 'privacy_check();';
+
+ if($row['cookie_continue'] == 0 && $row['cookie'] != -1)
+ $js_submit .= 'cookie_check();';
+
+ $js_submit .= 'return false;"';
+ }
+ else{
+ $js_submit = '';
+ }
+
+ echo ' <div class="buttons"><input class="next" type="submit" value="' . $label . '" '.$js_submit.'>' . "\n";
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1'){
+ echo '<input class="next" type="submit" value="' . self::$lang['srv_zapri'] . '" onclick="$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); return false;">' . "\n";
+ // Varianta da zapiranje iframa deluje cross domain
+ //echo '<input class="next" type="button" value="' . self::$lang['srv_zapri'] . '" onclick="parent.window.postMessage(\'closePopup\', \'http://HOST_DOMENA_TODO\');">' . "\n"
+ }
+
+ echo '</div>';
+ }
+
+ echo '</form>' . "\n";
+
+ echo '</div>' . "\n"; // - container
+
+ if (!get('printPreview')) {
+ $this->displayFooterNote();
+ }
+
+ // TAWK chat, ce je vklopljen
+ if(SurveyInfo::getInstance()->checkSurveyModule('chat')){
+ Display::getInstance()->displayChatTAWK();
+ }
+
+ echo '</div>' . "\n"; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ Js::js_tracking();
+ }
+
+ public function displayIntroductionContent()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+
+ // Ce prikazemo dodaten preduvod za gdpr ankete
+ if(GDPR::isGDPRSurveyTemplate(get('anketa'))){
+ self::displayIntroductionGDPR();
+ }
+
+
+ echo ' <div class="spremenljivka">' . "\n";
+
+ if ($row['introduction'] == '')
+ $intro = self::$lang['srv_intro'];
+ else
+ $intro = Helper::dataPiping($row['introduction']);
+
+ if (get('lang_id') != null) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='-1' AND lang_id='" . get('lang_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['naslov'] != '') $intro = $row1['naslov'];
+ }
+
+ echo '<div class="naslov">';
+
+ // ta p je mogoce prevec, ker ga verjetno vedno doda editor?
+ echo '<p>' . $intro . '</p>';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
+
+ if ($privacy == 1) {
+ echo '<p><br /></p><p style="font-weight:400;">' . self::$lang['srv_privacy_text_1'] . '</p>';
+
+ } elseif ($privacy == 2) {
+ echo '<p><br /></p>';
+
+ echo '<p style="font-weight:400;"><label for="privacy_box">';
+ echo '<input type="checkbox" name="privacy_box" id="privacy_box">';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio"></span>';
+ echo self::$lang['srv_privacy_text_2'];
+ echo '</label></p>';
+ }
+
+ // Ce imamo staticen uvod in preverjanje s captcho
+ if($row['intro_static'] == 2){
+ global $recaptcha_sitekey;
+
+ $captcha_error = (isset($_GET['captcha_error']) && $_GET['captcha_error'] == 1) ? true : false;
+
+ echo '<br />';
+
+ echo '<p>';
+ echo '<div class="g-recaptcha" data-sitekey="' .$recaptcha_sitekey .'"></div>';
+ echo '</p>';
+
+ if($captcha_error){
+ //echo '<p class="red italic">Wrong captcha!<p>';
+ }
+ }
+
+ echo '</div>' . "\n";
+
+ echo ' </div>' . "\n";
+ }
+
+ // Prikazemo dodaten uvod za GDPR
+ public function displayIntroductionGDPR()
+ {
+ $user_settings = GDPR::getSurveySettings(get('anketa'));
+
+ echo '<div class="spremenljivka '.(isset($_POST['gdpr']) ? ' required_require' : '').'">' . "\n";
+
+ echo '<div class="naslov">';
+
+ echo GDPR::getSurveyIntro(get('anketa'));
+
+ // JS za prikaz popup-a
+ echo '<script> $(".gdpr_popup_trigger").click(function(){ show_gdpr_about(\''.get('lang_id').'\'); });</script>';
+ echo '</div>' . "\n";
+
+ // Radio buttons
+ echo '<input type="hidden" name="gdpr" value="1">';
+ echo '<div class="variable_holder clr">';
+ echo ' <div class="variabla"><label for="gdpr_accept_0"><input type="radio" name="gdpr_accept" id="gdpr_accept_0" value="0"><span class="enka-checkbox-radio"></span>'.self::$lang['srv_gdpr_intro_no'].'</label></div>';
+ echo ' <div class="variabla"><label for="gdpr_accept_1"><input type="radio" name="gdpr_accept" id="gdpr_accept_1" value="1"><span class="enka-checkbox-radio"></span>'.self::$lang['srv_gdpr_intro_yes'].'</label></div>';
+ echo '</div>';
+
+ echo '</div>' . "\n";
+ }
+
+ /************************************************
+ * Izrišemo staticen uvod, ki ne shrani nicesar (user se ustvari v bazi sele na naslednji strani)
+ ************************************************/
+ public function displayStaticIntroduction()
+ {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ // datapiping
+ $row['introduction'] = Helper::dataPiping($row['introduction']);
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ echo '<div class="outercontainer_holder ' . $class . ' uvod_static">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . ' uvod_static">';
+ echo '<div class="outercontainer_header"></div>';
+
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ if (!get('printPreview')) {
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+ }
+
+ //opozorilo ce urejamo ze reseno anketo
+ if (get('quick_view') == true) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_quick_view_text'];
+ echo '</div>';
+ }
+ //opozorilo ce urejamo ze reseno anketo
+ if (isset($_GET['urejanje'])) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_edit_text'];
+ echo '</div>';
+
+ // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno
+ ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE
+ $sas = new SurveyAdminSettings();
+ $sas->checkFirstDataChange();
+
+ // Updatamo tracking (ker gre za editiranje odgovorov)
+ TrackingClass::update(get('anketa'), 4);
+ }
+
+ echo '<form method="post" action="' . SurveyInfo::getSurveyLink(false, false) . '&amp;grupa=0' . Header::getSurveyParams(true) . str_replace('&', '&amp;', get('cookie_url')) . '">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <input type="hidden" name="dummy" value="foo">' . "\n";
+ echo ' <input type="hidden" name="referer" value="' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . '">' . "\n";
+
+
+ $this->displayIntroductionContent();
+
+
+ // koda za izponjevanje ankete (splosna - brez prepoznave userjev) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ $sqlp = sisplet_query("SELECT COUNT(*) AS count FROM srv_password WHERE ank_id='" . get('anketa') . "'");
+ $rowp = mysqli_fetch_array($sqlp);
+ if ($rowp['count'] > 0 && $userAccess->checkUserAccess($what='password')) {
+ echo ' <div class="spremenljivka">' . "\n";
+ echo ' <p>' . self::$lang['insert_password'] . ': <input type="text" name="password" value="' . (isset($_COOKIE['password_' . get('anketa')]) ? $_COOKIE['password_' . get('anketa')] : '') . '"></p>';
+ echo ' </div>' . "\n";
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ // izbira jezika za respondenta
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $row['multilang'] == 1 && !get('printPreview')) {
+
+ $lang_resp = $row['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+
+ $file = lang_path($lang_resp);
+ include($file);
+ $lang_array[$lang['id']] = $lang['language'];
+
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ echo ' <div class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira jezika z dropdown menijem
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+ echo ' <h3>' . self::$lang['lang'] . ': ';
+ echo ' <select
+ name="language"
+ id="language"
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+ echo ' </select>';
+ echo '</h3>' . "\n";
+ } // Izbira jezika z radio gumbi (default)
+ else {
+ echo '<h3>' . self::$lang['lang'] . ': </h3>';
+ echo '<span style="font-size:13px;">';
+ foreach ($lang_array AS $key => $val) {
+ echo '<label for="language_' . $key . '">';
+ echo '<input type="radio" name="language" id="language_' . $key . '"
+ value="' . $key . '"' . ($key == $current ? '
+ checked="checked"' : '') . '
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language_' . $key . '\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;"> ';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+
+ echo $val;
+
+ echo '</label><br />';
+ }
+ echo '</span>';
+ }
+
+ echo ' </div>' . "\n";
+ }
+
+ echo '</div>' . "\n"; // - grupa
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage_uvod' . $_lang);
+ $label = $srv_nextpage != '' ? $srv_nextpage : self::$lang['srv_nextpage_uvod'];
+
+ if (!get('printPreview')) {
+
+ // JS na submitu prve strani - lahko da preverjamo privacy ali sprejetje cookija
+ $survey_privacy = SurveySetting::getInstance()->getSurveyMiscSetting('survey_privacy');
+ if(($row['cookie_continue'] == 0 && $row['cookie'] != -1) || $survey_privacy == 2){
+ $js_submit = ' onclick="';
+ if($survey_privacy == 2)
+ $js_submit .= 'privacy_check();';
+ if($row['cookie_continue'] == 0 && $row['cookie'] != -1)
+ $js_submit .= 'cookie_check();';
+ $js_submit .= 'return false;"';
+ }
+ else{
+ $js_submit = '';
+ }
+
+ echo ' <div class="buttons"><input class="next" type="submit" value="' . $label . '" '.$js_submit.'>' . "\n";
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1')
+ echo '<input class="next" type="submit" value="' . self::$lang['srv_zapri'] . '" onclick="$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); return false;">' . "\n";
+
+ echo '</div>';
+ }
+
+ echo '</form>' . "\n";
+
+ echo '</div>' . "\n"; // - container
+
+ if (!get('printPreview')) {
+
+ $this->displayFooterNote();
+ }
+
+ echo '</div>' . "\n"; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+ }
+
+
+ /************************************************
+ * Izrišemo konec ankete
+ ************************************************/
+ public function displayKonec()
+ {
+ global $mysql_database_name;
+ global $lang;
+ global $admin_type;
+ global $site_url;
+ global $app_settings;
+
+ Header::getInstance()->displaySistemske();
+
+ if (!get('printPreview')) {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'AND (finish_respondent=1 OR finish_respondent_cms=1 OR finish_author=1 OR finish_other =1)");
+
+
+ // EVALVACIJA - oznacimo, da je student odgovoril
+ if (Common::checkModule('evalvacija') == '1') {
+
+ $sql1 = sisplet_query("SELECT student FROM eval_data_user WHERE ank_id='".get('anketa')."' AND usr_id='".get('usr_id')."'");
+ $sql2 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='sifpredm' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'");
+ $sql3 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='siffaks' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'");
+ $sql4 = sisplet_query("SELECT d.* FROM srv_spremenljivka s, srv_grupa g, srv_data_text" . get('db_table') . " d WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='sifizv1' AND d.spr_id=s.id AND d.usr_id='" . get('usr_id') . "'");
+ $sql5 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl'");
+ $sql6 = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "'AND s.gru_id=g.id AND s.sistem='1' AND s.variable='podipl2'");
+
+ // Ce imamo sifro predmeta gre za anketo za ocenjevanje predmetov
+ if (mysqli_num_rows($sql2) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+ $row2 = mysqli_fetch_array($sql2);
+
+ // Ce imamo sifro izvajalca gre za anketo PRED izpiti (eval_data_anketaPred), drugace je anketa PO izpitih (eval_data_anketaPo)
+ if (mysqli_num_rows($sql4) > 0) {
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_anketaPred (predmet, student, ank_id) VALUES ('$row2[text]', '$row1[student]', '" . get('anketa') . "')");
+ } else {
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_anketaPo (predmet, student, ank_id) VALUES ('$row2[text]', '$row1[student]', '" . get('anketa') . "')");
+ }
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ // splosna PODIPLOMSKA anketa (ena na studenta, brez predmetov)
+ elseif (mysqli_num_rows($sql5) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_podipl (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')");
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ // splosna PODIPLOMSKA anketa 2 (ena na studenta, brez predmetov)
+ elseif (mysqli_num_rows($sql6) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_podipl2 (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')");
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ // SPLOSNA anketa (ena na studenta, brez predmetov)
+ elseif (mysqli_num_rows($sql1) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+
+ // student je v celoti odgovoril na anketo
+ sisplet_query("INSERT INTO eval_data_splosna (student, ank_id) VALUES ('$row1[student]', '" . get('anketa') . "')");
+
+ // Pobrisemo md5 (id studenta) iz zacasne tabele eval_data_user zaradi anonimnosti
+ sisplet_query("DELETE FROM eval_data_user WHERE usr_id='".get('usr_id')."' AND ank_id='".get('anketa')."'");
+ }
+ }
+
+ // Ce je vklopljen evoli team meter zabelezimo kvoto
+ $tm_quota_increase = false;
+ $modules = SurveyInfo::getInstance()->getSurveyModules();
+ if (isset($modules['evoli_teammeter'])
+ || isset($modules['evoli_quality_climate'])
+ || isset($modules['evoli_teamship_meter'])
+ || isset($modules['evoli_organizational_employeeship_meter'])
+ ) {
+
+ // Dobimo id skupine za respondenta
+ $sqlGroupTM = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND d.usr_id='".get('usr_id')."' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ if($rowGroupTM['vre_id'] > 0){
+
+ $tm_quota = 0;
+
+ // Prestejemo vse response za doloceno skupino/podjetje (to ni vezano na departmente, ker smo lahko tudi brez departmentov!)
+ $sqlTM = sisplet_query("SELECT DISTINCT(usr_id) AS usr_id
+ FROM srv_data_vrednost_active
+ WHERE vre_id='".$rowGroupTM['vre_id']."'");
+
+ while($rowTM = mysqli_fetch_array($sqlTM)){
+
+ // Dodatno se preverimo, ce je user res koncal anketo (ima status 6 in ni lurker)
+ $sqlTMU = sisplet_query("SELECT last_status, lurker FROM srv_user where id='".$rowTM['usr_id']."'");
+ $rowTMU = mysqli_fetch_array($sqlTMU);
+
+ if($rowTMU['last_status'] == '6' && $rowTMU['lurker'] == '0')
+ $tm_quota++;
+ }
+
+ $sqlTM = sisplet_query("UPDATE srv_evoli_teammeter
+ SET kvota_val='".$tm_quota."'
+ WHERE ank_id='".get('anketa')."' AND skupina_id='".$rowGroupTM['vre_id']."'");
+ $tm_quota_increase = true;
+ }
+ }
+
+ // Popravimo url za skok po koncu ankete ce nima http://
+ if ($row['url'] != '' && substr($row['url'], 0, 4) != 'http') {
+ $finishUrl = 'http://' . $row['url'];
+ } else {
+ $finishUrl = $row['url'];
+ }
+
+ // Dodamo datapiping v url-ju
+ if($row['url'] != ''){
+ // Počistimo html tage
+ $finishUrl = strip_tags(Helper::dataPiping($finishUrl));
+ }
+
+ // Preverimo ce imamo nastavljene kaksne get parametre za dodat pri skoku na url
+ if ($row['concl_link'] == 1 && $finishUrl != '') {
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $concl_url_usr_id = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_usr_id');
+ $concl_url_status = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_status');
+ $concl_url_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_recnum');
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1')
+ $finishUrl .= '?';
+
+ if ($concl_url_usr_id == '1') {
+ $finishUrl .= 'usr_id=' . get('usr_id') . '&';
+ }
+
+ if ($concl_url_status == '1' || $concl_url_recnum == '1') {
+ $sqlU = sisplet_query("SELECT last_status, recnum FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ if($concl_url_recnum == '1')
+ $finishUrl .= 'recnum=' . $rowU['recnum'] . '&';
+
+ if($concl_url_status == '1')
+ $finishUrl .= 'status=' . $rowU['last_status'] . '&';
+ }
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1')
+ $finishUrl = substr($finishUrl, 0, -1);
+ }
+
+ // Pri Gorenje anketah posljemo id reklamacije preko njihovega api-ja
+ if (Common::checkModule('gorenje')){
+ $rek_id = SurveyGorenje::getGorenjeVariable(get('anketa'), 'rekid', get('usr_id'));
+ if($rek_id != '' && $rek_id > 0){
+
+ // Posljemo id reklamacije preko api-ja
+ SurveyGorenje::sendGorenjeRekID($rek_id);
+ }
+ }
+
+ // Preverimo ce imamo vklopljen modul za panel - potem napolnimo url z ustreznimi parametri
+ if(isset($modules['panel'])){
+
+ // Pridobimo vse nastavitve panela
+ $sp = new SurveyPanel(get('anketa'));
+ $panel_settings = $sp->getPanelSettings();
+
+ // Posebno samo za ipanel - Izraelski projekt
+ if($app_settings['app_name'] == 'www.1ka.si' && (get('anketa') == '232992' || get('anketa') == '232795' || get('anketa') == '248217' || get('anketa') == '248757' || get('anketa') == '248762')){
+
+ // Pridobimo id panelista ki je bil shranjen na zacetku resevanja v sistemsko spremenljivko
+ $sqlP = sisplet_query("SELECT d.*, s.variable FROM srv_data_text".get('db_table')." d, srv_spremenljivka s, srv_grupa g
+ WHERE d.usr_id='".get('usr_id')."' AND s.variable IN ('id', 'i_project', 'i_user1', 'i_user4', 'i_user5', 'i_user6', 'i_user7')
+ AND d.spr_id=s.id AND s.gru_id=g.id AND g.ank_id='".get('anketa')."'");
+ while($rowP = mysqli_fetch_array($sqlP)){
+
+ if($rowP['variable'] == 'id')
+ $panelist_id = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user1')
+ $panelist_user = $rowP['text'];
+ elseif($rowP['variable'] == 'i_project')
+ $panelist_project = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user4')
+ $user_data4 = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user5')
+ $user_data5 = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user6')
+ $user_data6 = $rowP['text'];
+ elseif($rowP['variable'] == 'i_user7')
+ $user_data7 = $rowP['text'];
+ }
+
+ // Pridobimo koncen status panelista (ce ni bil nikjer nastavljen uporabimo default)
+ $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $panel_settings['status_default'];
+
+ // Nastavimo koncen url za redirect
+ $finishUrl = 'http://survey.ipanel.co.il/mrIWeb/mrIWeb.dll?';
+ $finishUrl .= 'id='.$panelist_id.'&i.user1='.$panelist_user.'&i.project='.$panelist_project.'&i.user9='.$panel_status;
+ $finishUrl .= '&i.user4='.$user_data4.'&i.user5='.$user_data5.'&i.user6='.$user_data6.'&i.user7='.$user_data7;
+ }
+ else{
+ // Pridobimo id panelista ki je bil shranjen na zacetku resevanja v sistemsko spremenljivko
+ $sqlP = sisplet_query("SELECT d.* FROM srv_data_text".get('db_table')." d, srv_spremenljivka s, srv_grupa g
+ WHERE d.usr_id='".get('usr_id')."' AND s.variable='".$panel_settings['user_id_name']."'
+ AND d.spr_id=s.id AND s.gru_id=g.id AND g.ank_id='".get('anketa')."'");
+ $rowP = mysqli_fetch_array($sqlP);
+ $panelist_id = $rowP['text'];
+
+ // Pridobimo koncen status panelista (ce ni bil nikjer nastavljen uporabimo default)
+ $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $panel_settings['status_default'];
+
+ // Nastavimo koncen url za redirect
+ $finishUrl = $row['url'].'?'.$panel_settings['user_id_name'].'='.$panelist_id.'&'.$panel_settings['status_name'].'='.$panel_status;
+ }
+ }
+
+ // Na koncu preverimo, če gre za hierarhijo in resevanje supersifre
+ // V kolikor gre za hierarhijo, ki uporablja superšifro potem pred redirectom poberemo vse parametre
+ if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2) {
+ $resevanje = sisplet_query("SELECT * FROM srv_hierarhija_supersifra_resevanje WHERE user_id='".get('usr_id')."'", "obj");
+
+ $kode = sisplet_query("SELECT kode FROM srv_hierarhija_supersifra WHERE koda='".$resevanje->supersifra."'", "obj");
+ $kode = unserialize($kode->kode);
+
+ sisplet_query("UPDATE srv_hierarhija_supersifra_resevanje SET status=6 WHERE user_id='".get('usr_id')."'");
+
+ // V kolikor prispemo smo ravno zaključili reševanje zadnje ankete v supersifri potem prikažemo konec oz. glede na nastavitve ankete in ne preusmerimo ponovno na začetek
+ if(end($kode) != $resevanje->koda){
+ // Glede na vrednost
+ $naslednja = array_search($resevanje->koda, $kode) + 1;
+
+ $url = sisplet_query("SELECT url FROM srv_hierarhija_koda WHERE koda='".$kode[$naslednja]."'", "obj");
+
+ $url_encode_spremenljivke = urlencode(base64_encode($url->url . '&supersifra=' . $resevanje->supersifra.'&resujem='.$naslednja));
+ $redirect = $site_url .'a/'.get('anketa').'?enc='.$url_encode_spremenljivke;
+
+ header("Location: $redirect");
+ }
+
+ }
+
+ // za posebno MJU anketo pridobimo skupino in preusmerimo nazaj na zacetek z ustreznim lepim linkom
+ if(isset($modules['mju_theme'])){
+
+ // Dobimo id skupine za respondenta
+ $sqlGroup = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND d.usr_id='".get('usr_id')."' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroup = mysqli_fetch_array($sqlGroup);
+
+ if($rowGroup['vre_id'] > 0){
+
+ $sqlGroupName = sisplet_query("SELECT naslov FROM srv_vrednost WHERE id='".$rowGroup['vre_id']."' AND spr_id='".$rowGroup['spr_id']."'");
+ $rowGroupName = mysqli_fetch_array($sqlGroupName);
+
+ $finishUrl = 'https://gov-ankete.si/'.$rowGroupName['naslov'];
+ }
+ else{
+ $finishUrl = 'https://gov-ankete.si/';
+ }
+ }
+ // za posebno MJU anketo pridobimo skupino in preusmerimo nazaj na zacetek z ustreznim lepim linkom
+ if(isset($modules['mju_redirect'])){
+
+ // Dobimo id skupine za respondenta
+ $sqlGroup = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND d.usr_id='".get('usr_id')."' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroup = mysqli_fetch_array($sqlGroup);
+
+ if($rowGroup['vre_id'] > 0){
+
+ $sqlGroupName = sisplet_query("SELECT naslov, variable FROM srv_vrednost WHERE id='".$rowGroup['vre_id']."' AND spr_id='".$rowGroup['spr_id']."'");
+ $rowGroupName = mysqli_fetch_array($sqlGroupName);
+
+ $finishUrl = 'https://gov-ankete.si/UE1_'.$rowGroupName['variable'];
+ }
+ else{
+ $finishUrl = 'https://gov-ankete.si/';
+ }
+ }
+
+
+ // URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php)
+ if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '')
+ $close_url = $app_settings['survey_finish_url'];
+ else
+ $close_url = 'https://www.1ka.si/';
+
+
+ // pri formi posebej pogledamo ce anketo zapremo ali skocimo na url - po novem je lahko vklopljen zakljucek
+ if ($row['survey_type'] == 1 && $row['show_concl'] == 0) {
+
+ if ($row['concl_link'] == 1) {
+ header("Location: $finishUrl");
+ }
+ else {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\''.$close_url.'\';' . "\n";
+ echo ' </script>' . "\n";
+ }
+ }
+ // zakljucek ankete ni prikazan in oznaceno je da zapremo anketo
+ elseif ($row['show_concl'] == 0) {
+
+ if ($row['concl_link'] == 0) {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\''.$close_url.'\';' . "\n";
+ echo ' </script>' . "\n";
+ }
+ // Rekurzivno
+ else if ($row['concl_link'] == 2) {
+ header("Location: " . SurveyInfo::getSurveyLink());
+ }
+ else {
+ header("Location: $finishUrl");
+ }
+
+ } else {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ echo '<div class="outercontainer_holder ' . $class . ' concl">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . ' concl">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1 ' . (isset($modules['uporabnost']) ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ echo '<div class="grupa">' . "\n";
+
+ Statistic::displayStatistika(true);
+
+ $this->displayKonecContent();
+
+ echo '</div>' . "\n"; //-grupa
+
+ if ($row['user_from_cms'] == 2) {
+ //echo '<p style="text-align:center"><a href="'.$site_url.'a/'.$this->anketa.'">'.$lang['srv_nextins'].'</a></p>';
+ echo '<p style="text-align:center"><a href="' . SurveyInfo::getSurveyLink() . '">' . $lang['srv_nextins'] . '</a></p>';
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ if (!get('printPreview')) {
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang);
+ if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage'];
+
+ $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink');
+
+ echo '<div class="buttons">';
+ // prejsna stran, prikazemo ce ni v zakjucku drugace nastavljeno
+ if ($row['concl_back_button'] != '0')
+ #echo '<input class="prev" type="button" value="'.$srv_prevpage.'" onclick="history.back()">'."\n";
+ if ($display_backlink != '0') {
+ // Posebej za WebSM anketo - back naredimo tako, da poiscemo prejsnjo stran
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+
+ $grupa = Find::findPrevGrupa(get('anketa'), get('grupa'));
+ $grupa = ($grupa > 0) ? '&grupa=' . $grupa : '';
+
+ $language = (isset($_GET['language'])) ? '&language=' . $_GET['language'] : '';
+
+ $link = SurveyInfo::getSurveyLink(false, false) . $grupa . $language;
+
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="location.href=\'' . $link . '\';">';
+ } else {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">' . "\n";
+ }
+ }
+ }
+ if ($finishUrl != '') {
+
+ if ($row['concl_link'] == 1) {
+ if (!isset($modules['uporabnost']))
+ $js = 'document.location.href=\'' . $finishUrl . '\';';
+ else
+ $js = 'top.location.href=\'' . $finishUrl . '\';';
+ }
+ elseif ($row['concl_link'] == 2) {
+ if (!isset($modules['uporabnost']))
+ $js = 'document.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ else
+ $js = 'top.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ }
+ elseif (!isset($modules['uporabnost'])) {
+ if (Common::checkModule('evalvacija') == '1')
+ $js = 'window.close(); document.location.href=\'https://www.uni-lj.si/\';';
+ else
+ $js = 'window.close(); document.location.href=\''.$close_url.'\';';
+ }
+ // uporabnost
+ else
+ $js = 'top.close();';
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1')
+ $js = '$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); ';
+
+
+ // Za posebno MJU anketo posebej pohendlamo kaj se zgodi po koncu
+ if(isset($modules['mju_theme'])){
+
+ // Mobitel ali tablica se po koncu zapre
+ if(get('mobile') == 1 || get('mobile') == 2){
+ $js = 'window.close(); document.location.href=\'https://http://www.mju.gov.si//\';';
+ }
+ // Drugace se preusmeri na zacetek
+ else{
+ $js = 'document.location.href=\'' . $finishUrl . '\';';
+ }
+ }
+
+
+ if (!get('printPreview')) {
+ $srv_konec = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec' . $_lang);
+ /*if ($row['text'] != '') // besedilo koncne povezave shranimo v misc setting, da bo konsistentno z ostalimi prevodi
+ $text = $row['text'];
+ else*/
+ if ($srv_konec != '')
+ $text = $srv_konec;
+ else
+ $text = $lang['srv_konec'];
+
+ if ($row['concl_end_button'] == 1)
+ echo '<input class="next" type="submit" value="' . $text . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+ if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1 && $admin_type <= 2) { // vnosos
+ $sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "'ORDER BY vrstni_red ASC LIMIT 1");
+ $rowg = mysqli_fetch_array($sqlg);
+ //echo '<p class="vnos"><a href="'.$site_url.'a/'.$this->anketa.'&grupa='.$rowg['id'].'">'.$lang['srv_nextins'].'</a> | <a href="'.$site_url.'admin/survey/index.php?anketa='.$this->anketa.'">'.$lang['srv_insend'].'</a></p>';
+ echo '<p class="vnos"><a href="' . SurveyInfo::getSurveyLink() . '&grupa=' . $rowg['id'] . '">' . $lang['srv_nextins'] . '</a> | <a href="' . $site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . $lang['srv_insend'] . '</a></p>';
+ }
+
+ echo '</div>' . "\n"; // -container
+
+ $this->displayFooterNote();
+ #$this->displayRespondetnPDF();
+
+ echo '</div>' . "\n"; // -outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+ }
+
+ //is respondent lurker?
+ $sqlur = sisplet_query("SELECT lurker FROM srv_user WHERE id = '" . get('usr_id') . "'", "obj");
+
+ // ce je tko oznacen in ce reposndent ni lurker, posljemo se alerte
+ if (mysqli_num_rows($sqlAlert) > 0 && $sqlur->lurker == 0)
+ Helper::getInstance()->alert();
+
+ // Ce je vklopljen evoli team meter, preverimo, ce posiljamo obvestilo po dosezeni kvoti
+ if( (isset($modules['evoli_teammeter']) || isset($modules['evoli_quality_climate']) || isset($modules['evoli_teamship_meter']) || isset($modules['evoli_organizational_employeeship_meter']))
+ && $tm_quota_increase
+ ){
+ Helper::getInstance()->alertTeamMeter();
+ }
+
+ Js::js_tracking();
+
+ } else { // za print preview in pdf
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ echo '<div id="container">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <div class="spremenljivka">' . "\n";
+ if ($row['conclusion'] == '') {
+ $concl = $lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ if (get('lang_id') != null) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "'AND spr_id='-2' AND lang_id='" . get('lang_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['naslov'] != '') $concl = $row1['naslov'];
+ }
+ echo ' <p>' . $concl . '</p>' . "\n";
+ echo ' </div>' . "\n";
+ echo '</div>' . "\n";
+ echo '</div>' . "\n";
+ }
+ }
+
+ public function displayKonecContent(){
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ echo ' <div class="spremenljivka">' . "\n";
+
+ // Ce gre za gdpr zakljucek (respondent ni sprejel pogojev)
+ if(GDPR::isGDPRSurveyTemplate(get('anketa')) && isset($_POST['gdpr_accept']) && $_POST['gdpr_accept'] == '0'){
+ self::displayKonecGDPR();
+ }
+ else{
+
+ if ($row['conclusion'] == '') {
+ $concl = self::$lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ if (get('lang_id') != null) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='-2' AND lang_id='" . get('lang_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['naslov'] != '') $concl = $row1['naslov'];
+ }
+
+ $concl = Helper::dataPiping($concl);
+
+ echo ' <div class="naslov"><p>' . $concl . '</p></div>' . "\n";
+
+ Display::getInstance()->displayReturnEditURL();
+ Display::getInstance()->displayRespondetnPDF();
+ }
+
+ echo ' </div>' . "\n";
+
+
+ // Prikaz pravilnih rezultatov v primeru kviza
+ if(SurveyInfo::getInstance()->checkSurveyModule('quiz')){
+
+ // Pridobimo nastavitve kviza
+ $sq = new SurveyQuiz(get('anketa'));
+ $quiz_settings = $sq->getSettings();
+
+ if($quiz_settings['results'] == '1' || $quiz_settings['results_chart'] == '1'){
+
+ echo '<div id="quiz_results">';
+
+ echo '<h2>'.self::$lang['results'].'</h2>';
+
+ // Prikaz grafa rezultatov
+ if($quiz_settings['results_chart'] == '1')
+ Display::getInstance()->displayQuizChart();
+
+ // Prikaz rezultatov
+ if($quiz_settings['results'] == '1')
+ Display::getInstance()->displayQuizAnswers();
+
+ echo '</div>';
+ }
+ }
+
+ // Prikaz Excelleration matrix grafa ce je vklopljen napredni modul
+ if(SurveyInfo::getInstance()->checkSurveyModule('excell_matrix')){
+ echo '<div id="excell_matrix">';
+ Display::getInstance()->displayExcellChart();
+ echo '</div>';
+ }
+
+ // SKAVTI - prikaz povzetka odgovorov in grafa
+ global $mysql_database_name;
+ //if($mysql_database_name == '1ka' && get('anketa') == '64'){
+ if($mysql_database_name == 'real1kasi' && (get('anketa') == '293926' || get('anketa') == '314856' || get('anketa') == '332793')){
+ echo '<div id="skavti_answers">';
+ Display::getInstance()->displaySkavtiAnswers();
+ echo '</div>';
+ }
+
+ // NIJZ - prikaz radar grafa in tabele
+ global $site_domain;
+ if( ($site_domain == 'test.1ka.si' && get('anketa') == '8892') || ($site_domain == 'anketa.nijz.si' && get('anketa') == '126738') ){
+
+ $nijz = new SurveyNIJZ(get('anketa'), get('usr_id'));
+
+ $nijz->displayRadar();
+ $nijz->displayTable();
+ }
+ }
+
+ // Prikazemo dodaten uvod za GDPR
+ public function displayKonecGDPR()
+ {
+ //$user_settings = GDPR::getSurveySettings(get('anketa'));
+
+ echo '<div class="naslov">';
+ echo '<p>'.self::$lang['srv_gdpr_concl'].'</p>';
+ echo '</div>';
+ }
+
+
+ /**
+ * @desc prikaze konec ankete
+ */
+ public function displayKonecGlasovanje(){
+ global $app_settings;
+
+ echo '<script>var srv_meta_anketa_id = ' . get('anketa') . ';</script>';
+
+ //izpis zakljucka
+ if (isset($_GET['glas_end']) && $_GET['glas_end'] == 1) {
+ if (!get('printPreview')) {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $endButton = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec');
+ $endButton = ($endButton == '') ? self::$lang['srv_konec'] : $endButton;
+ //$row['text'] == '' ? $endButton = self::$lang['srv_konec'] : $endButton = $row['text'];
+
+ //dodaten naslov gumba zakljucek
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage');
+ if ($srv_prevpage != '')
+ $text = $srv_prevpage;
+ else
+ $text = self::$lang['srv_prevpage'];
+
+
+ // URL na katerega skocimo ce se zapre okno - pogledamo ce imamo nastavljen custom url (settings_optional.php)
+ if(isset($app_settings['survey_finish_url']) && $app_settings['survey_finish_url'] != '')
+ $close_url = $app_settings['survey_finish_url'];
+ else
+ $close_url = 'https://www.1ka.si/';
+
+ // zakljucek ankete ni prikazan in oznaceno je da zapremo anketo
+ if ($row['show_concl'] < 1) {
+ if ($row['concl_link'] == 0) {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\''.$close_url.'\';' . "\n";
+ echo ' </script>' . "\n";
+ } else {
+ header("Location: $row[url]");
+ }
+ }
+
+
+ echo '<div class="outercontainer_holder concl_glasovanje">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer concl_glasovanje">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ echo '<div class="grupa">' . "\n";
+
+ echo ' <div class="spremenljivka">' . "\n";
+
+ if ($row['conclusion'] == '') {
+ $concl = self::$lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ echo ' <h3><p>' . $concl . '</p></h3>' . "\n";
+
+ echo ' </div>' . "\n";
+
+ echo '</div>' . "\n"; // -grupa
+
+ if ($_GET['preview'] == 'on') {
+ echo '<div class="buttons"><a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . self::$lang['srv_back_edit'] . '</a></div>' . "\n";
+ }
+
+ echo '<div class="buttons">';
+
+
+ if ($row['concl_back_button'] == 1) {
+ echo '<input class="prev" type="button" value="' . $text . '" onclick="javascript:history.go(-1)">';
+ }
+
+ if ($row['concl_end_button'] == 1) {
+ if ($row['concl_link'] == 1)
+ $js = 'document.location.href=\'' . $row['url'] . '\';';
+ else
+ $js = 'window.close(); document.location.href=\''.$close_url.'\';';
+
+ if (!get('printPreview')) {
+ echo '<input class="next" type="submit" value="' . $endButton . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+
+ echo '</div>' . "\n"; // -container
+
+ $this->displayFooterNote();
+
+ echo '</div>'; // -outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ // ce je tko oznacen posljemo se alerte
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "' AND (finish_respondent=1 OR finish_respondent_cms=1 OR finish_author=1 OR finish_other =1)");
+ if (mysqli_num_rows($sqlAlert) > 0)
+ Helper::getInstance()->alert();
+ }
+ else { // za print preview in pdf
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ echo '<div id="container">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <div class="spremenljivka">' . "\n";
+ if ($row['conclusion'] == '') {
+ $concl = self::$lang['srv_end'];
+ } else {
+ $concl = $row['conclusion'];
+ }
+ echo ' <p>' . $concl . '</p>' . "\n";
+ echo ' </div>' . "\n";
+ echo '</div>' . "\n";
+ }
+ } //izpis statistike
+ else {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqls = sisplet_query("SELECT stat FROM srv_spremenljivka s, srv_glasovanje g WHERE g.ank_id = '" . get('anketa') . "' AND s.id = g.spr_id");
+ $rows = mysqli_fetch_array($sqls);
+
+ //ce statistike ne prikazujemo skocimo na zakljucek (ce imammo izklopljeno ali nastavleno na samo urednike in ni urednik)
+ if ($rows['stat'] == 0 || ($rows['stat'] == 2 && self::$admin_type != 0 && self::$admin_type != 1)) {
+ //header('Location: '.self::$site_url.'a/'.get('anketa').'&grupa='.get('grupa').'&glas_end=1'.get('cookie_url').'');
+ header('Location: ' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . '&glas_end=1' . get('cookie_url') . '');
+ } else {
+
+ echo '<div class="outercontainer_holder concl_statistika">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer concl_statistika">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ echo '<div class="grupa">' . "\n";
+ Statistic::displayStatistika(true);
+ echo '</div>' . "\n";
+
+ echo '<div class="buttons">';
+ //$url_stat = ''.self::$site_url.'a/'.get('anketa').'&grupa='.get('grupa').'&glas_end=1'.get('cookie_url');
+ $url_stat = '' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . '&glas_end=1' . get('cookie_url');
+ $js = 'document.location.href=\'' . $url_stat . '\';';
+
+ // Gumb nazaj
+ if ($row['concl_back_button'] == 1) {
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage');
+ if ($srv_prevpage != '')
+ $text = $srv_prevpage;
+ else
+ $text = self::$lang['srv_prevpage'];
+
+ echo '<input class="prev" type="button" value="' . $text . '" onclick="javascript:history.go(-1)">';
+ }
+
+ if ($row['show_concl'] == 1) {
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+
+ $srv_potrdi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_potrdi'.$_lang);
+ if ($srv_potrdi == '') $srv_potrdi = self::$lang['srv_potrdi'];
+
+ echo '<input class="next" type="submit" value="' . $srv_potrdi . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ elseif ($row['concl_end_button'] == 1) {
+ $endButton = self::$lang['srv_konec'];
+ echo '<input class="next" type="submit" value="' . $endButton . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+
+ echo '</div>' . "\n";
+
+ echo '</div>' . "\n"; // -container
+
+ echo '</div>' . "\n"; // -outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+ }
+ }
+ }
+
+ // Konec pri anketi evoli team meter - ce je kvota polna
+ public function displayKonecEvoliTM($date_to='')
+ {
+ global $mysql_database_name;
+ global $lang;
+ global $admin_type;
+ global $site_url;
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ // Popravimo url za skok po koncu ankete ce nima http://
+ if ($row['url'] != '' && substr($row['url'], 0, 4) != 'http') {
+ $finishUrl = 'http://' . $row['url'];
+ } else {
+ $finishUrl = $row['url'];
+ }
+
+ // Dodamo datapiping v url-ju
+ if($row['url'] != ''){
+ // Počistimo html tage
+ $finishUrl = strip_tags(Helper::dataPiping($finishUrl));
+ }
+
+ // Preverimo ce imamo nastavljene kaksne get parametre za dodat pri skoku na url
+ if ($row['concl_link'] == 1 && $finishUrl != '') {
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $concl_url_usr_id = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_usr_id');
+ $concl_url_status = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_status');
+ $concl_url_recnum = SurveySetting::getInstance()->getSurveyMiscSetting('concl_url_recnum');
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1' || $concl_url_recnum == '1')
+ $finishUrl .= '?';
+
+ if ($concl_url_usr_id == '1') {
+ $finishUrl .= 'usr_id=' . get('usr_id') . '&';
+ }
+
+ if ($concl_url_status == '1' || $concl_url_recnum == '1') {
+ $sqlU = sisplet_query("SELECT last_status FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ if($concl_url_recnum == '1')
+ $finishUrl .= 'recnum=' . $rowU['recnum'] . '&';
+
+ if($concl_url_status == '1')
+ $finishUrl .= 'status=' . $rowU['last_status'] . '&';
+ }
+
+ if ($concl_url_usr_id == '1' || $concl_url_status == '1')
+ $finishUrl = substr($finishUrl, 0, -1);
+ }
+
+ if ($row['show_concl'] == 0) {
+
+ if ($row['concl_link'] == 0) {
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ echo ' document.location.href=\'http://www.1ka.si/\';' . "\n";
+ echo ' </script>' . "\n";
+ }
+ // Rekurzivno
+ else if ($row['concl_link'] == 2) {
+ header("Location: " . SurveyInfo::getSurveyLink());
+ }
+ else {
+ header("Location: $finishUrl");
+ }
+
+ }
+ else {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+ echo '<div class="outercontainer_holder ' . $class . '">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . '">' . "\n";
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+
+ Display::getInstance()->progress_bar();
+
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ // Vsebina zakljucka ce je kvota polna oz je presezen datum
+ echo '<div class="grupa">' . "\n";
+ echo ' <div class="spremenljivka">' . "\n";
+
+ echo ' <div class="naslov"><p>';
+ if($date_to != '')
+ echo self::$lang['srv_evoli_survey_expired'].' '.$date_to.' '.self::$lang['srv_evoli_survey_end_help'];
+ else
+ echo self::$lang['srv_evoli_survey_quota_full'].' '.self::$lang['srv_evoli_survey_end_help'];
+ echo ' </p></div>';
+
+ echo ' </div>' . "\n";
+ echo '</div>' . "\n"; //-grupa
+
+
+ if ($row['user_from_cms'] == 2) {
+ echo '<p style="text-align:center"><a href="' . SurveyInfo::getSurveyLink() . '">' . $lang['srv_nextins'] . '</a></p>';
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ if (!get('printPreview')) {
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang);
+ if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage'];
+
+ $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink');
+
+ echo '<div class="buttons">';
+ // prejsna stran, prikazemo ce ni v zakjucku drugace nastavljeno
+ /*if ($row['concl_back_button'] != '0')
+ if ($display_backlink != '0') {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">' . "\n";
+ }*/
+ }
+ if ($finishUrl != '') {
+ if ($row['concl_link'] == 1) {
+ if (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost'))
+ $js = 'document.location.href=\'' . $finishUrl . '\';';
+ else
+ $js = 'top.location.href=\'' . $finishUrl . '\';';
+ } elseif ($row['concl_link'] == 2) {
+ if (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost'))
+ $js = 'document.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ else
+ $js = 'top.location.href=\'' . SurveyInfo::getSurveyLink() . '\';';
+ } elseif (!SurveyInfo::getInstance()->checkSurveyModule('uporabnost')) {
+ if (Common::checkModule('evalvacija') == '1')
+ $js = 'window.close(); document.location.href=\'https://www.uni-lj.si/\';';
+ else
+ $js = 'window.close(); document.location.href=\'https://www.1ka.si/\';';
+ } // uporabnost
+ else
+ $js = 'top.close();';
+
+ if (isset($_GET['popup']) && $_GET['popup'] == '1')
+ $js = '$(\'#popup_div, #popup_iframe\', window.parent.document).hide(); ';
+
+
+ if (!get('printPreview')) {
+ $srv_konec = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_konec' . $_lang);
+
+ if ($srv_konec != '')
+ $text = $srv_konec;
+ else
+ $text = $lang['srv_konec'];
+
+ if ($row['concl_end_button'] == 1)
+ echo '<input class="next" type="submit" value="' . $text . '" onclick="' . $js . ' return false;">' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+ if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1 && $admin_type <= 2) { // vnosos
+ $sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "'ORDER BY vrstni_red ASC LIMIT 1");
+ $rowg = mysqli_fetch_array($sqlg);
+ //echo '<p class="vnos"><a href="'.$site_url.'a/'.$this->anketa.'&grupa='.$rowg['id'].'">'.$lang['srv_nextins'].'</a> | <a href="'.$site_url.'admin/survey/index.php?anketa='.$this->anketa.'">'.$lang['srv_insend'].'</a></p>';
+ echo '<p class="vnos"><a href="' . SurveyInfo::getSurveyLink() . '&grupa=' . $rowg['id'] . '">' . $lang['srv_nextins'] . '</a> | <a href="' . $site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . $lang['srv_insend'] . '</a></p>';
+ }
+
+ echo '</div>' . "\n"; // -container
+
+ $this->displayFooterNote();
+
+ echo '</div>' . "\n"; // -outercontainer
+ echo '<div class="outercontainer_holder_bottom"></div></div>'; // -outercontainer_holder
+ }
+ }
+
+
+ /**
+ * @desc prikaze trenutno anketo
+ */
+ public function displayAnketa()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ if (!get('printPreview')) {
+
+ // crn div za ozadje popupov
+ echo '<div id="fade"></div>';
+ echo '<div id="popup"></div>';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $hide_mobile_img = SurveySetting::getInstance()->getSurveyMiscSetting('hide_mobile_img');
+ $class = ($hide_mobile_img == '1') ? 'hide_mobile_img' : '';
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $class .= ' mobile_preview';
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $class .= ' tablet_preview';
+
+
+ echo '<div class="outercontainer_holder ' . $class . '">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer" class="' . $class . '">';
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ $d = new Display();
+ $d->logo();
+ $d->progress_bar();
+
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+
+ if (get('quick_view') == true) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_quick_view_text'];
+ echo '</div>';
+ }
+
+ //opozorilo ce urejamo ze reseno anketo
+ if (isset($_GET['urejanje'])) {
+ echo '<div id="edit_warning">';
+ echo self::$lang['srv_edit_text'];
+ echo '</div>';
+
+ // Preverimo ce gre za prvo popravljanje podatkov in avtomatsko ustvarimo arhiv podatkov ce je potrebno
+ //ob_flush(); // ZAKAJ JE TUKAJ TA FLUSH? KER POTEM NE DELA NAKNADNO UREJANJE CE IMA ANKETA LOOPE
+ $sas = new SurveyAdminSettings();
+ $sas->checkFirstDataChange();
+
+ // Updatamo tracking (ker gre za editiranje odgovorov)
+ TrackingClass::update(get('anketa'), 4);
+ }
+
+ $this->displayGrupa();
+
+ echo '</div>' . "\n"; // - container
+
+ $this->displayFooterNote();
+
+ // TAWK chat, ce je vklopljen
+ if(SurveyInfo::getInstance()->checkSurveyModule('chat')){
+ Display::getInstance()->displayChatTAWK();
+ }
+
+ echo '</div>'; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ Js::js_tracking();
+
+ } else {
+
+ echo '<div id="container">' . "\n";
+ $this->displayGrupa();
+ echo '</div>' . "\n";
+ }
+ }
+
+ public function displayAllPages()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ echo '<div class="outercontainer_holder">';
+ echo '<div class="outercontainer_holder_top"></div>';
+
+ echo '<div id="outercontainer">';
+ echo '<div class="outercontainer_header"></div>';
+
+ echo '<div id="container">' . "\n";
+
+ Display::getInstance()->logo();
+ Display::getInstance()->progress_bar();
+
+ if (!get('printPreview')) {
+ echo '<h1 ' . (SurveyInfo::getInstance()->checkSurveyModule('uporabnost') ? ' class="evalvacija"' : '') . '>' . Helper::getInstance()->displayAkronim() . '</h1>' . "\n";
+ }
+
+ echo '<div class="grupa">';
+ $this->displayIntroductionContent();
+ echo '</div>';
+
+ $this->displayGrupa();
+
+ echo '<div class="grupa">';
+ $this->displayKonecContent();
+ echo '</div>';
+
+ echo '</div>' . "\n"; // - container
+
+ echo '</div>' . "\n"; // - outercontainer
+
+ echo '<div class="outercontainer_holder_bottom"></div>';
+ echo '</div>'; // -outercontainer_holder
+
+ $this->displayFooterNote();
+ }
+
+ /**
+ * @desc prikaze trenutno grupo
+ */
+ public function displayGrupa(){
+ global $admin_type;
+
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo id-strani
+ if(SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ SurveyAdvancedParadataLog::getInstance()->displayGrupa(get('grupa'));
+ }
+
+ $sql = sisplet_query("SELECT naslov, vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row = mysqli_fetch_array($sql);
+ if (!get('printPreview')) {
+
+ Display::getInstance()->display_tabs();
+
+ echo '<form name="vnos" method="post" action="' . SurveyInfo::getSurveyLink(false, false) . '&amp;grupa=' . get('grupa') . (get('loop_id') != null ? '&amp;loop_id=' . get('loop_id') : '') . Header::getSurveyParams(true) . str_replace('&', '&amp;', get('cookie_url')) . '" enctype="multipart/form-data">' . "\n";
+ echo '<div class="grupa">' . "\n";
+ echo ' <input type="hidden" name="dummy" value="foo">' . "\n";
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ // izbira jezika za respondenta - Ce nimamo prikazanega uvoda, prikazemo izbiro na prvi strani
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang') == 1 && $rowa['multilang'] == 1 && $rowa['show_intro'] == 0 && $row['vrstni_red'] == 1) {
+
+ $lang_resp = $rowa['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+ $file = lang_path($lang_resp);
+ include($file);
+
+ $lang_array[$lang['id']] = $lang['language'];
+
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ echo ' <div class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira jezika z dropdown menijem
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type') == 1) {
+ echo ' <h3>' . self::$lang['lang'] . ': ';
+ echo ' <select
+ name="language"
+ id="language"
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+
+ echo ' </select>';
+ echo '</h3>' . "\n";
+ }
+ // Izbira jezika z radio gumbi (default)
+ else {
+ echo '<h3>' . self::$lang['lang'] . ': </h3>';
+ echo '<span style="font-size:13px;">';
+
+ foreach ($lang_array AS $key => $val) {
+ echo '<label for="language_' . $key . '">';
+ echo '<input type="radio" name="language" id="language_' . $key . '"
+ value="' . $key . '"' . ($key == $current ? '
+ checked="checked"' : '') . '
+ onchange="window.location.href =
+ \'' . SurveyInfo::getSurveyLink() . '?language=\'+document.getElementById(\'language_' . $key . '\').value+\'' .
+ '&survey-'.get('anketa').'=' . get('cookie_url') . '\'+\'' .
+ (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . '\'+\'' .
+ (isset($_GET['preview']) ? '&preview=' . $_GET['preview'] : '') . '\'+\'' .
+ (isset($_GET['testdata']) ? '&testdata=' . $_GET['testdata'] : '') . '\'+\'' .
+ (isset($_GET['code']) ? '&code=' . $_GET['code'] : '') . '\'+\'' .
+ (isset($_GET['params']) ? '&params=' . $_GET['params'] : '') . '\'+\'' .
+ (isset($_GET['usr_id']) ? '&usr_id=' . $_GET['usr_id'] : '') . '\'+\'' .
+ (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . '\'+\'' .
+ (isset($_GET['recnum']) ? '&recnum=' . $_GET['recnum'] : '') . '\'+\'' .
+ (isset($_GET['enc']) ? '&enc=' . urlencode($_GET['enc']) : '') . '\';
+ return false;"> ';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+
+ echo $val;
+
+ echo '</label><br />';
+ }
+ echo '</span>';
+ }
+
+ echo ' </div>' . "\n";
+ }
+
+ Vprasanja::getInstance()->displaySpremenljivke();
+
+ echo '</div>' . "\n"; // - grupa
+
+ Js::getInstance()->generateSubmitJS();
+
+ echo '</form>' . "\n";
+
+ Js::getInstance()->generateBranchingJS();
+
+ // Disable odgovorov, ce je ze izpolnjeval to stran in ima vklopljeno nastavitev, da ni dovoljeno naknadno vnasanje odogovorov
+ if($rowa['subsequent_answers'] == '0' && $admin_type != '0' && $admin_type != '1'){
+
+ // Preverimo, ce je uporabnik ze bil na strani
+ if(Check::getInstance()->check_subsequent_visit()){
+ echo '<script>disableSubsequentAnswers();</script>';
+ }
+ }
+
+ // nov zgornji link pri uporabnosti
+ $link = SurveySetting::getInstance()->getSurveyMiscSetting('uporabnost_link_' . get('grupa'));
+ if ($link != '' && strlen($link) > 7)
+ echo "<script> top.frames['link'].location.href = '" . $link . "'; </script>";
+ }
+ else{
+ Display::getInstance()->displaySpremenljivke();
+ }
+ }
+
+
+ public function displayFooterNote(){
+ global $mysql_database_name, $app_settings;
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ echo '<div id="footer_survey">';
+
+ // Pri mobilnem skinu (in mju skinu pri tablici) prikazemo na dnu se logo
+ if (get('mobile') == 1 || (get('mobile') == 2 && SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1')) {
+ Display::getInstance()->logo();
+ }
+
+ // Custom footer
+ if(isset($app_settings['footer_survey_custom']) && $app_settings['footer_survey_custom'] == 1){
+
+ echo '<p>'.$app_settings['footer_survey_text'].'</p>';
+ }
+ // Default footer
+ else{
+
+ $link = (self::$lang['id'] == '1') ? 'https://www.1ka.si' : 'https://www.1ka.si/d/en';
+ $link_cookie = (self::$lang['id'] == '1') ? 'https://www.1ka.si/d/sl/o-1ka/pogoji-uporabe-1ka/politika-piskotkov' : 'https://www.1ka.si/d/en/about/terms-of-use/cookie-policy';
+ $link_privacy = (self::$lang['id'] == '1') ? 'https://www.1ka.si/d/sl/o-1ka/pogoji-uporabe-storitve-1ka/politika-zasebnosti' : 'https://www.1ka.si/d/en/about/terms-of-use/privacy-policy';
+ $link_paradata = (self::$lang['id'] == '1') ? 'https://www.1ka.si/d/sl/o-1ka/pogoji-uporabe-1ka/izklop-parapodatkov' : 'https://www.1ka.si/d/en/about/terms-of-use/turn-off-paradata';
+
+ echo '<p class="footer_survey_UL">Univerza <i>v Ljubljani</i></p>';
+ echo '<p class="footer_survey_FDV"><i>Fakulteta za dru&#382;bene vede</i></p>';
+ echo '<p class="footer_survey_PoweredBy"><a href="'.$link.'" target="_blank">Powered by: 1KA</a></p>';
+ echo '<p class="footer_1ka"><a href="'.$link.'" target="_blank">1KA - ' . self::$lang['srv_footer_1ka'] . '</a></p>';
+
+ echo '<p class="privacy">';
+
+ $survey_ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip');
+ $ip_show = SurveySetting::getInstance()->getSurveyMiscSetting('survey_show_ip');
+ $survey_browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser');
+ $survey_referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal');
+ $survey_date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+
+
+ $privacy_text = '';
+
+ // Ce imamo vse izklopljeno je anketa brez parapodatkov
+ if(($survey_ip == 1 || $ip_show == 0) && $survey_browser == 1 && $survey_referal == 1 && $survey_date == 1){
+
+ $privacy_text = '<a href="'.$link_paradata.'" target="_blank">' . self::$lang['srv_no_paradata'] . '</a>';
+
+ echo $privacy_text;
+ }
+ else{
+ echo '<a href="'.$link.'" target="_blank">' . self::$lang['srv_no_anketa'] . ' </a>';
+
+ // Piskotki
+ if ($row['cookie'] == -1)
+ $privacy_text .= '<a href="'.$link_cookie.'" target="_blank">' . self::$lang['srv_no_cookie'] . '</a>, ';
+
+ // IP sledenje
+ if ($survey_ip == 1)
+ $privacy_text .= '<a href="'.$link_paradata.'" target="_blank">' . self::$lang['srv_no_ip'] . '</a>, ';
+
+ // Email povezovanje
+ if ($row['user_base'] == 1 && $row['show_email'] == 0)
+ $privacy_text .= '<a href="'.$link_paradata.'" target="_blank">' . self::$lang['srv_no_email'] . '</a>, ';
+
+ echo substr($privacy_text, 0, -2);
+ }
+
+ echo '</p>';
+
+ echo '<p class="privacy_link">';
+ echo '<a href="' . $link_privacy . '" target="_blank">' . self::$lang['srv_privacy_policy'] . '</a>';
+ echo '</p>';
+ }
+
+ echo '</div>';
+
+
+ // OKNO Z NASTAVITVAMI ZA PREVIEW / TEST
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on' && $_GET['no_preview'] != '1') {
+
+ echo '<div id="preview-window">';
+
+
+ // Gump za odprtje/zaprtje okna
+ echo '<div id="preview_open" '.($_GET['testdata'] == 'on' ? ' class="testdata"' : '').'>';
+
+ echo '<a href="#" onclick="preview_popup_open(); return false;" class="preview_icon_open" style="display:none;"><span class="faicon dropdown_blue"></span></a>';
+ echo '<a href="#" onclick="preview_popup_close(); return false;" class="preview_icon_close"><span class="faicon dropup_blue"></span></a>';
+
+ echo '</div>';
+
+
+ // Preklop na celostranski preview
+ echo '<div id="preview_switch">';
+
+ echo '<span class="bold">'.self::$lang['srv_mode'] . ':</span>';
+ echo '<span class="'.(get('displayAllPages') ? 'nonactive' : 'active').'"><a href="' . SurveyInfo::getSurveyLink() . Header::getSurveyParams(false, null, array('pages')) . '" title="' . self::$lang['srv_normal_x'] . '">' . self::$lang['srv_normal'] . '</a></span>';
+ echo '<span class="'.(get('displayAllPages') ? 'active' : 'nonactive').'"><a href="' . SurveyInfo::getSurveyLink() . Header::getSurveyParams(false, array('pages' => 'all', 'mobile' => '0')) . '" title="' . self::$lang['srv_scrolling_x'] . '">' . self::$lang['srv_scrolling'] . '</a></span>';
+
+ echo '</div>';
+
+
+ // Vsebina - preview-holder
+ echo '<div id="preview-holder">';
+
+ echo '<div id="preview" class="' . ($_GET['testdata'] == 'on' ? 'testdata' : '') . '">';
+
+ if ($_GET['testdata'] == 'on')
+ echo '<p>' . self::$lang['srv_testalert'] . '</p>';
+ else
+ echo '<p>' . self::$lang['srv_previewalert'] . '</p>';
+
+ if ($row['multilang'] == 1) {
+ $lang_resp = $row['lang_resp'];
+ $lang_array = array();
+
+ $current = self::$lang['id'];
+ $file = lang_path($lang_resp);
+ include($file);
+
+ $lang_array[$lang['id']] = $lang['language'];
+ $file = lang_path($current);
+ include($file);
+
+ $sqll = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id='" . get('anketa') . "' ORDER BY language");
+ while ($rowl = mysqli_fetch_array($sqll)) {
+ $lang_array[$rowl['lang_id']] = $rowl['language'];
+ }
+
+ // FORM s preklopom jezika
+ echo '<form name="change_lang" action="" method="get">';
+
+ if (isset($_GET['code']))
+ echo '<input type="hidden" name="code" value="' . $_GET['code'] . '">';
+
+ if (isset($_GET['preview']))
+ echo '<input type="hidden" name="preview" value="' . $_GET['preview'] . '">';
+
+ if (isset($_GET['disableif']))
+ echo '<input type="hidden" name="disableif" value="' . $_GET['disableif'] . '">';
+
+ if (isset($_GET['displayifs']))
+ echo '<input type="hidden" name="displayifs" value="' . $_GET['displayifs'] . '">';
+
+ if (isset($_GET['displayvariables']))
+ echo '<input type="hidden" name="displayvariables" value="' . $_GET['displayvariables'] . '">';
+
+ if (isset($_GET['disablealert']))
+ echo '<input type="hidden" name="disablealert" value="' . $_GET['disablealert'] . '">';
+
+ if (isset($_GET['disablecode']))
+ echo '<input type="hidden" name="disablecode" value="' . $_GET['disablecode'] . '">';
+
+ if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0)
+ echo '<input type="hidden" name="disablecode" value="1">';
+
+ if (isset($_GET['grupa']))
+ echo '<input type="hidden" name="grupa" value="' . $_GET['grupa'] . '">';
+
+
+ echo '<p>' . self::$lang['lang'] . ': ';
+
+ echo ' <select name="language" onchange="document.change_lang.submit();">';
+ foreach ($lang_array AS $key => $val) {
+ echo '<option value="' . $key . '"' . ($key == $current ? ' selected' : '') . '>' . $val . '</option>';
+ }
+ echo ' </select></p>' . "\n";
+
+ echo '</form>';
+ }
+
+
+ // Preklop med preview-ji za mobilnik, tablico in pc
+ if(!get('displayAllPages')){
+
+ echo '<span id="preview_device"><span>' . self::$lang['srv_para_graph_device'] . ': </span>';
+
+ if (isset($_GET['mobile']) && $_GET['mobile'] == '1')
+ $device_value = 1;
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == '2')
+ $device_value = 2;
+ else
+ $device_value = 0;
+
+ echo '<a href="#" title="PC" onClick="$(\'#device_value\').val(\'0\'); document.change_diable.submit();"><span class="faicon monitor ' . ($device_value == 0 ? ' active' : '') . '"></span></a>';
+
+ // Ce imamo izklopljene mobilne prilagoditve ne pustimo preview-ja na mobile, ker itak ne prikaze scalano
+ $mobile_friendly = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_friendly');
+ if($mobile_friendly != '0'){
+ echo '<a href="#" title="' . self::$lang['srv_preview_tablet'] . '" onClick="$(\'#device_value\').val(\'2\'); document.change_diable.submit();"><span class="faicon tablet ' . ($device_value == 2 ? ' active' : '') . '"></span></a>';
+ echo '<a href="#" title="' . self::$lang['srv_preview_mobile'] . '" onClick="$(\'#device_value\').val(\'1\'); document.change_diable.submit();"><span class="faicon mobile ' . ($device_value == 1 ? ' active' : '') . '"></span></a>';
+ }
+
+ echo '</span>';
+ }
+
+
+ // FORM z dropdownom za preklop med stranmi
+ echo '<form name="go_to_page" action="#" method="get">';
+
+ if (isset($_GET['code']))
+ echo '<input type="hidden" name="code" value="' . $_GET['code'] . '">';
+
+ if (isset($_GET['preview']))
+ echo '<input type="hidden" name="preview" value="' . $_GET['preview'] . '">';
+
+ if (isset($_GET['mobile']))
+ echo '<input type="hidden" name="mobile" value="' . $_GET['mobile'] . '">';
+
+ echo '<input type="hidden" name="disableif" value="1">';
+
+ if (isset($_GET['displayifs']))
+ echo '<input type="hidden" name="displayifs" value="' . $_GET['displayifs'] . '">';
+
+ if (isset($_GET['displayvariables']))
+ echo '<input type="hidden" name="displayvariables" value="' . $_GET['displayvariables'] . '">';
+
+ if (isset($_GET['disablealert']))
+ echo '<input type="hidden" name="disablealert" value="' . $_GET['disablealert'] . '">';
+
+ if (isset($_GET['disablecode']))
+ echo '<input type="hidden" name="disablecode" value="' . $_GET['disablecode'] . '">';
+
+ if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0)
+ echo '<input type="hidden" name="disablecode" value="1">';
+
+ if ($row['multilang'] == 1 && isset($_GET['language']))
+ echo '<input type="hidden" name="language" value="' . $_GET['language'] . '">';
+
+
+ // Skok na doloceno stran - samo ce nimamo prikaza vse na eni strani
+ if(!get('displayAllPages')){
+ echo '<p>' . self::$lang['srv_jump_to'] . ': <select name="grupa" onchange="document.go_to_page.submit();">';
+
+ $sql1 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_grupa WHERE ank_id = '" . get('anketa') . "' ORDER BY vrstni_red ASC");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<option value="' . $row1['id'] . '" ' . ($row1['id'] == get('grupa') ? 'selected' : '') . '>' . self::$lang['srv_stran'] . ' ' . $row1['vrstni_red'] . '</option>';
+
+ $sql2 = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='$row1[id]' ORDER BY vrstni_red ASC");
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ if ($row['multilang'] == 1) {
+ $sqlLang = sisplet_query("SELECT * FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='" . $row2['id'] . "' AND lang_id='" . get('lang_id') . "'");
+ if (mysqli_num_rows($sqlLang) > 0) {
+ $rowLang = mysqli_fetch_array($sqlLang);
+ $row2['naslov'] = $rowLang['naslov'];
+ }
+ }
+
+ echo '<option value="' . $row1['id'] . '"> - (' . $row2['variable'] . ') ' . substr($row2['naslov'], 0, 100) . '</option>';
+ }
+ }
+ echo '</select></p>';
+ }
+
+ echo '</form>';
+
+
+ // FORM s checkbox nastavitvami
+ $link = SurveyInfo::getSurveyLink(get('anketa')) . '' . Header::getSurveyParams(false, null, array('disableif', 'disablealert', 'disablecode', 'displayifs', 'displayvariables', 'hidecomment', 'mobile')) . '&survey-' . get('anketa') . '=' . $_GET['survey-' . get('anketa') . ''] . '&grupa=' . $_GET['grupa'];
+ echo '<form name="change_diable" action="' . $link . '" method="get">';
+
+ echo '<input type="hidden" name="mobile" id="device_value" value="' . $device_value . '">';
+
+ if ($row['multilang'] == 1 && isset($_GET['language']))
+ echo '<input type="hidden" name="language" value="' . $_GET['language'] . '">';
+
+ if (isset($_GET['code']))
+ echo '<input type="hidden" name="code" value="' . $_GET['code'] . '">';
+
+ echo '<p><label for="disableif"><input type="checkbox" value="1" ' . ($_GET['disableif'] == '1' ? ' checked' : '') . ' name="disableif" id="disableif" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_disableif'] . '</label></p>';
+
+ echo '<p><label for="disablealert"><input type="checkbox" value="1" ' . ($_GET['disablealert'] == '1' ? ' checked' : '') . ' name="disablealert" id="disablealert" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_disablealert'] . '</label></p>';
+
+ // Pogoj za izlapljanje kode ce imamo email vabila z zahtevano kodo
+ if ($row['user_base'] == 1 && $row['individual_invitation'] != 0 && $row['usercode_skip'] == 0) {
+ echo '<p><label for="disablecode"><input type="checkbox" value="1" ' . ($_GET['disablecode'] == '1' ? ' checked' : '') . ' name="disablecode" id="disablecode" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_disablecode'] . '</label></p>';
+ }
+
+ echo '<p><label for="displayifs"><input type="checkbox" value="1" ' . ($_GET['displayifs'] == '1' ? ' checked' : '') . ' name="displayifs" id="displayifs" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_displayifs'] . '</label></p>';
+
+ echo '<p><label for="displayvariables"><input type="checkbox" value="1" ' . ($_GET['displayvariables'] == '1' ? ' checked' : '') . ' name="displayvariables" id="displayvariables" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_displayvariables'] . '</label></p>';
+
+
+ // Komentarji - vidno samo ce imamo ustrezen paket
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ if($userAccess->checkUserAccess($what='komentarji')){
+
+ $question_resp_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment');
+ $preview_disable_test_insert = SurveySetting::getInstance()->getSurveyMiscSetting('preview_disable_test_insert');
+
+ if ($_GET['testdata'] == 'on' || $preview_disable_test_insert == 0) {
+
+ if ($question_resp_comment == 0) {
+ echo '<p><a href="#" onclick="$.post(\'' . self::$site_url . '/main/survey/ajax.php?a=enable_comments\', {anketa: ' . get('anketa') . '}, function () { window.location = window.location + \'&testdata=on\' }); return false;">';
+
+ if ($_GET['testdata'] == 'on')
+ echo self::$lang['srv_preview_comments'];
+ else
+ echo self::$lang['srv_savedatapreview'];
+
+ echo '</a></p>';
+ }
+ else {
+ if ($_GET['testdata'] == 'on') {
+ echo '<p><label for="hidecomment"><input type="checkbox" value="1" ' . ($_GET['hidecomment'] == '1' ? ' checked' : '') . ' name="hidecomment" id="hidecomment" onchange="document.change_diable.submit();"><span class="enka-checkbox-radio"></span>';
+ echo ' ' . self::$lang['srv_preview_comments2'] . '</label></p>';
+ } else {
+ echo '<p><a href="#" onclick="$.post(\'' . self::$site_url . '/main/survey/ajax.php?a=enable_comments\', {anketa: ' . get('anketa') . '}, function () { window.location = window.location + \'&testdata=on\' }); return false;">';
+ echo self::$lang['srv_savedatapreview'];
+ echo '</a></p>';
+ }
+ }
+ }
+ }
+
+
+
+ echo '</form>';
+
+ echo '</div>' . "\n"; // preview
+
+
+ // Komentarji - vidno samo ce imamo ustrezen paket
+ if($userAccess->checkUserAccess($what='komentarji')){
+
+ if ($question_resp_comment == 1 && $_GET['testdata'] == 'on') {
+ $question_resp_comment_inicialke = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_inicialke');
+
+ if ($question_resp_comment_inicialke == 1) {
+ echo '<p class="inicialke">' . self::$lang['srv_inicialke'] . ': <input type="text" value="" size="3" id="inicialke"></p>';
+ echo '<script> inicialke(); </script>';
+ }
+ }
+
+ $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'");
+ (mysqli_num_rows($sqlUserAutor) > 0) ? save('userAutor', true) : save('userAutor', false);
+ // Komentarji urednikov na anketo
+ if (get('userAutor')) {
+
+ echo '<div style="margin: 20px 0 15px; width: 100%;">';
+
+ $view = 1;
+ $survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment');
+ $preview_hide_survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('preview_hide_survey_comment');
+ if ((self::$admin_type <= $survey_comment && $survey_comment != '') && (/*$preview_hide_survey_comment != 1 ||*/
+ $_GET['testdata'] == 'on')
+ ) {
+
+ echo '<span class="stngs floatLeft">';
+
+ $show_survey_comment = $_GET['show_survey_comment'];
+ if ($row['forum'] == 0 || $row['thread'] == 0) {
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="0" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+ echo '</a>';
+ } else {
+
+ $sqlf = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread]'");
+ $rowf = mysqli_fetch_array($sqlf);
+ $rowf['count']--; //zaradi 1. avtomatskega posta
+
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="0" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+
+ // ali prikazemo okno odprto - je dodan tak admin komentar
+ $sqlf1 = sisplet_query("SELECT * FROM post p WHERE p.tid='$row[thread]' AND p.ocena='5'");
+ while ($rowf1 = mysqli_fetch_array($sqlf1)) {
+ $s = sisplet_query("SELECT * FROM views WHERE pid='$rowf1[id]' AND uid='self::$global_user_id'");
+ if (mysqli_num_rows($s) == 0)
+ $show_survey_comment = 1;
+ }
+ echo '</a>';
+ }
+
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/js-lang.php?lang='.self::$lang['lang_short'].'&amp;v=13.06.07"></script>';
+ // Ce je tole vklopljeno se js porusi?
+ //echo '<script type="text/javascript" src="'.self::$site_url.'/admin/survey/minify/g=jsnew?v=13.06.07"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/jquery/jquery.qtip-1.0.js"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/script.js"></script>';
+ echo '<script> $(function() { load_comment(\'#surveycomment_0_' . $view . '\'' . ($show_survey_comment == '1' ? ', \'2\'' : '') . '); });</script>';
+
+ echo '</span>';
+ }
+
+ // Uredniske nastavitve link
+ echo '<span class="floatRight bold"><a href="' . self::$site_url . '/admin/survey/index.php?anketa=' . get('anketa') . '&a=testiranje&popup=open" target="_blank" title="' . self::$lang['srv_uredniske_nastavitve'] . '">' . self::$lang['settings'] . ' <span class="faicon settings"></span></a></span>';
+
+ echo '</div>';
+ }
+ // Komentarji respondentov na anketo
+ elseif (self::$global_user_id > 0 || true) {
+
+ echo '<p class="stngs">';
+
+ $view = 1;
+ $survey_comment_resp = SurveySetting::getInstance()->getSurveyMiscSetting('survey_comment_resp');
+ $preview_hide_survey_comment = SurveySetting::getInstance()->getSurveyMiscSetting('preview_hide_survey_comment');
+ if (((self::$admin_type <= $survey_comment_resp && self::$admin_type != -1 && $survey_comment_resp != '') || $survey_comment_resp == 4) && ($preview_hide_survey_comment != 1 || $_GET['testdata'] == 'on')) {
+
+ $show_survey_comment = $_GET['show_survey_comment'];
+
+ if ($row['forum'] == 0 || $row['thread_resp'] == 0) {
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="4" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ //echo '<span class="sprites _comments_add" title="'.self::$lang['srv_survey_comment'].'"></span>';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+ echo '</a>';
+ }
+ else {
+
+ $sqlf = sisplet_query("SELECT COUNT(*) AS count FROM post WHERE tid='$row[thread_resp]'");
+ $rowf = mysqli_fetch_array($sqlf);
+ $rowf['count']--; //zaradi 1. avtomatskega posta
+ echo '<a href="#" onclick="return false;" class="surveycomment bold" id="surveycomment_0_' . $view . '" type="4" view="' . $view . '" spremenljivka="0">';
+ echo self::$lang['srv_comment_splosen'] . ' ';
+ echo '<span class="faicon comment" title="' . self::$lang['srv_survey_comment'] . '" alt="' . self::$lang['srv_survey_comment'] . '"></span>';
+
+ $sqlf1 = sisplet_query("SELECT * FROM post p WHERE p.tid='$row[thread_resp]' AND p.ocena='5'");
+ while ($rowf1 = mysqli_fetch_array($sqlf1)) {
+ $s = sisplet_query("SELECT * FROM views WHERE pid='$rowf1[id]' AND uid='self::$global_user_id'");
+ if (mysqli_num_rows($s) == 0)
+ $show_survey_comment = 1;
+ }
+ echo '</a>';
+ }
+
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/js-lang.php?lang='.self::$lang['lang_short'].'&amp;v=13.06.07"></script>';
+ // Ce je tole vklopljeno se js porusi?
+ //echo '<script type="text/javascript" src="'.self::$site_url.'/admin/survey/minify/g=jsnew?v=13.06.07"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/jquery/jquery.qtip-1.0.js"></script>';
+ echo '<script type="text/javascript" src="' . self::$site_url . '/admin/survey/script/script.js"></script>';
+ echo '<script> $(function() { load_comment(\'#surveycomment_0_' . $view . '\'' . ($show_survey_comment == '1' ? ', \'2\'' : '') . '); });</script>';
+ }
+
+ echo '</p>';
+ }
+ }
+
+ echo '</div>' . "\n"; // preview-holder
+
+ echo '</div>' . "\n"; // preview-window
+
+
+ ?><script>
+ if (localStorage.preview_popup == 1) {
+ $('#preview-holder, #preview_switch').hide();
+
+ $('.preview_icon_open').show();
+ $('.preview_icon_close').hide();
+
+ $('#preview-window').addClass('closed');
+ }
+ </script><?
+
+
+ // Komentarji - vidno samo ce imamo ustrezen paket
+ if($userAccess->checkUserAccess($what='komentarji')){
+
+ // Prikazemo okno s komentarji ce je nastavljeno da je vedno odprto
+ $preview_survey_comment_showalways = SurveySetting::getInstance()->getSurveyMiscSetting('preview_survey_comment_showalways');
+ if ($preview_survey_comment_showalways == 1) {
+
+ $view = 1;
+ $show_survey_comment = '1';//$_GET['show_survey_comment'];
+
+ ?><script>
+ $(function () {
+ <?echo 'load_comment(\'#surveycomment_0_' . $view . '\'' . ($show_survey_comment == '1' ? ', \'2\'' : '') . ');';?>
+ });
+ </script><?
+ }
+ }
+
+ }
+
+
+ save('cookie_expire', $row['cookie']);
+
+ // alert za shranjevanje cookiejev
+ if (get('cookie_expire') != -1 && !(isset($_COOKIE['cookie_ok']) && $_COOKIE['cookie_ok'] == 1) && !empty($row)) {
+
+ echo '<div id="cookie_alert">';
+ if($mysql_database_name == 'vprasalnikirsrssi')
+ echo self::$lang['srv_cookie_ok_rsrs'];
+ else
+ echo self::$lang['srv_cookie_ok'];
+ echo '</div>';
+
+ ?><script>
+ $(function () {
+ $('#cookie_alert').slideDown();
+ });
+ $('#cookie_ok').on('click', cookie_ok);
+ </script><?
+ }
+
+ // alert da je testna anketa
+ if ((get('cookie_expire') == -1 || (isset($_COOKIE['cookie_ok']) && $_COOKIE['cookie_ok'] == 1)) && isset($_GET['testdata']) && $_GET['testdata'] == 'on') {
+
+ echo '<div id="test_alert">';
+ echo self::$lang['srv_test_alert'];
+ echo '</div>';
+
+ ?><script>
+ $(function () {
+ $('#test_alert').slideDown();
+ });
+ </script><?
+ }
+ // alert da je predogled
+ elseif ((get('cookie_expire') == -1 || (isset($_COOKIE['cookie_ok']) && $_COOKIE['cookie_ok'] == 1)) && isset($_GET['preview']) && $_GET['preview'] == 'on') {
+
+ echo '<div id="test_alert">';
+ echo self::$lang['srv_preview_alert'];
+ echo '</div>';
+
+ ?><script>
+ $(function () {
+ $('#test_alert').slideDown();
+ });
+ </script><?
+ }
+
+
+ // Odgovori, ki so disable jih ustrezno skrijemo
+ ?><script>
+ $('.answer-disabled').find('td.category ').each(function () {
+ $(this).find('input, textarea').attr('disabled', 'disabled');
+ });
+ $('div.variabla.answer-disabled').find('label input').attr('disabled', 'disabled');
+ $('span.answer-disabled').on('click', function () {
+ return false;
+ });
+ </script><?
+
+
+ // Alert ce ni javascripta
+ echo '<div id="javascript_alert">';
+ echo self::$lang['srv_javascript_warning'];
+ echo '</div>';
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/CheckController.php b/main/survey/app/Controllers/CheckController.php
new file mode 100644
index 0000000..d39a6c2
--- /dev/null
+++ b/main/survey/app/Controllers/CheckController.php
@@ -0,0 +1,774 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 12.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\FindController as Find;
+use App\Models\Model;
+use Cache;
+use enkaParameters;
+use SurveyInfo;
+use SurveyMissingValues;
+use Common;
+use Mobile_Detect;
+
+
+class CheckController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ parent::getAllVariables();
+
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new CheckController();
+ }
+
+ private function refreshVariables()
+ {
+ return parent::getAllVariables();
+ }
+
+ /**
+ * @desc preveri ali so na trenutni grupi prikazana vprasanja (zaradi branchinga)
+ */
+ public function checkGrupa()
+ {
+
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id = '" . get('grupa') . "' ORDER BY vrstni_red");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($this->checkSpremenljivka($row['id']))
+ return true;
+
+ }
+
+ return false;
+ }
+
+ /**
+ * @desc preveri ali je spremenljivka vidna (zaradi branchinga) (oz. lahko je nastavljena vidnost samo administratorju)
+ */
+ public function checkSpremenljivka($spremenljivka, $isTestData=false)
+ {
+ $checkSpremenljivka = get('checkSpremenljivka');
+ if (array_key_exists($spremenljivka, $checkSpremenljivka)) {
+ return $checkSpremenljivka[$spremenljivka];
+ }
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ // ce vprasanje ni vidno ali ce uporabnik nima dostopa do vprasanja
+ if ($row['visible'] == 0 || !((self::$admin_type <= $row['dostop'] && self::$admin_type >= 0) || (self::$admin_type == -1 && $row['dostop'] == 4))) {
+ return save('checkSpremenljivka[' . $spremenljivka . ']', false, 1);
+ }
+
+ // Pri testnih podatkih ne upostevamo ifov, ker drugace nic ne napolni
+ if(!$isTestData){
+ $sql1 = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$spremenljivka'");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ if (!$this->checkIf($row1['parent']))
+ return save('checkSpremenljivka[' . $spremenljivka . ']', false, 1);
+ }
+
+ return save('checkSpremenljivka[' . $spremenljivka . ']', true, 1);
+ }
+
+ /**
+ * @desc preveri ali se elementi v podanem IFu prikazejo ali ne
+ */
+ public function checkIf($if)
+ {
+ if ($if == 0) return true;
+
+ $checkIf = get('checkIf');
+ if (array_key_exists($if, $checkIf)) {
+ return $checkIf[$if];
+ }
+
+ // preverimo po strukturi navzgor
+ $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_if = '$if'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+ if (!$this->checkIf($row['parent'])) {
+ return save('checkIf[' . $if . ']', false, 1);
+ }
+
+ $sql = sisplet_query("SELECT * FROM srv_if WHERE id = '$if'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ // ce je IF oznacen da se vedno prikaze
+ if ($row['enabled'] == 1)
+ return save('checkIf[' . $if . ']', true, 1);
+
+ // ce je IF oznacen da se nikoli ne prikaze
+ if ($row['enabled'] == 2)
+ return save('checkIf[' . $if . ']', false, 1);
+
+ // ce je IF oznacen kot blok, potem se vedno prikaze
+ if ($row['tip'] == 1)
+ return save('checkIf[' . $if . ']', true, 1);
+
+
+ $eval = "if (";
+
+ //$sql = sisplet_query("SELECT * FROM srv_condition WHERE if_id = '$if' ORDER BY vrstni_red ASC");
+ $sql = Cache::srv_condition($if);
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+ $i = 0;
+ // zgeneriramo pogoje z oklepaji, ki jih potem spustimo skozi eval
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($i++ != 0)
+ if ($row['conjunction'] == 0)
+ $eval .= ' && ';
+ else
+ $eval .= ' || ';
+
+ if ($row['negation'] == 1)
+ $eval .= ' ! ';
+
+ for ($i = 1; $i <= $row['left_bracket']; $i++)
+ $eval .= ' ( ';
+
+ if ($this->checkCondition($row['id']))
+ $eval .= ' true ';
+ else
+ $eval .= ' false ';
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $eval .= ' ) ';
+ }
+ $eval .= ") return true; else return false; ";
+
+ // ne glih best practice, ampak takle mamo...
+ $eval = @eval($eval);
+ if ($eval === true)
+ return save('checkIf[' . $if . ']', true, 1);
+
+ return save('checkIf[' . $if . ']', false, 1);
+ }
+
+ /**
+ * @desc preveri podani condition
+ */
+ public function checkCondition($condition)
+ {
+
+ $sql = sisplet_query("SELECT * FROM srv_condition WHERE id = '$condition'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ // obicne spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ $row2 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ // radio, checkbox, dropdown
+ if ($row2['tip'] <= 3) {
+
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_vre c, srv_data_vrednost" . get('db_table') . " v
+ WHERE c.cond_id='$condition' AND c.vre_id=v.vre_id
+ AND v.spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'");
+
+ // Dodatno preverjanje ce imamo pogoj -1
+ $sql3b = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id='$condition' AND vre_id='-1'");
+ $sql4b = sisplet_query("SELECT * FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'");
+
+ if ($row['operator'] == 0 && mysqli_num_rows($sql3) == 0 && mysqli_num_rows($sql3b) == 0)
+ return false;
+ elseif ($row['operator'] == 0 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && mysqli_num_rows($sql3) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) == 0)
+ return false;
+
+ // multigrid
+ } elseif ($row2['tip'] == 6 || $row2['tip'] == 16) {
+
+ // tabela radio (brez dvojne tabele - ki gre v checkgrid)
+ if ($row2['tip'] == 6 && $row2['enota'] != 3) {
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_grid" . get('db_table') . " d
+ WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]'
+ AND c.grd_id=d.grd_id AND d.usr_id='" . get('usr_id') . "' AND d.vre_id='$row[vre_id]'");
+
+ // Dodatno preverjanje ce imamo pogoj -1
+ $sql3b = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$condition' AND grd_id='-1'");
+ $sql4b = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ } // tabela checkboxov
+ else {
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_checkgrid" . get('db_table') . " d
+ WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]'
+ AND c.grd_id=d.grd_id AND d.usr_id='" . get('usr_id') . "' AND d.vre_id='$row[vre_id]'");
+
+ // Dodatno preverjanje ce imamo pogoj -1
+ $sql3b = sisplet_query("SELECT * FROM srv_condition_grid WHERE cond_id='$condition' AND grd_id='-1'");
+ $sql4b = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ }
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ if ($row['operator'] == 0 && !mysqli_num_rows($sql3) > 0 && !mysqli_num_rows($sql3b) > 0)
+ return false;
+ elseif ($row['operator'] == 0 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && !mysqli_num_rows($sql3) == 0)
+ return false;
+ elseif ($row['operator'] == 1 && mysqli_num_rows($sql3b) > 0 && mysqli_num_rows($sql4b) == 0)
+ return false;
+
+ } elseif ($row2['tip'] == 19 || $row2['tip'] == 20) {
+
+ $sql3 = sisplet_query("SELECT text FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "' AND grd_id='$row[grd_id]'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($row3['text'] < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($row3['text'] > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text']))
+ return false;
+
+ // textbox
+ } elseif ($row2['tip'] == 21) {
+
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] <= 5) {
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+
+ // length
+ } else {
+
+ if ($row['operator'] == 6 && !(strlen($row3['text']) == $row['text']))
+ return false;
+ elseif ($row['operator'] == 7 && !(strlen($row3['text']) < $row['text']))
+ return false;
+ elseif ($row['operator'] == 8 && !(strlen($row3['text']) > $row['text']))
+ return false;
+
+ }
+
+ // vsota
+ } elseif ($row2['tip'] == 18) {
+
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND vre_id='$row[vre_id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($row3['text'] < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($row3['text'] > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text']))
+ return false;
+
+ // razvrscanje
+ } elseif ($row2['tip'] == 17) {
+
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c, srv_data_rating d
+ WHERE c.cond_id='$condition' AND d.spr_id='$row[spr_id]'
+ AND d.vre_id='$row[vre_id]' AND d.usr_id='" . get('usr_id') . "' AND d.vrstni_red=c.grd_id");
+
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ if ($row['operator'] == 0 && !mysqli_num_rows($sql3) > 0)
+ return false;
+ elseif ($row['operator'] == 1 && !mysqli_num_rows($sql3) == 0)
+ return false;
+
+ // number
+ } else {
+
+ if ($row['grd_id'] == 0) $text = 'text';
+ else $text = 'text2';
+
+ $sql3 = sisplet_query("SELECT " . $text . " AS text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[spr_id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+ $row3 = mysqli_fetch_array($sql3);
+
+ if ($row['operator'] == 0 && !($row3['text'] == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($row3['text'] != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($row3['text'] < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($row3['text'] <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($row3['text'] > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($row3['text'] >= $row['text']))
+ return false;
+
+ }
+
+ // recnum
+ } elseif ($row['spr_id'] == -1) {
+
+ $sqlu = sisplet_query("SELECT recnum FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $rowu = mysqli_fetch_array($sqlu);
+
+ if (!($rowu['recnum'] % $row['modul'] == $row['ostanek']))
+ return false;
+
+ // calculations
+ } elseif ($row['spr_id'] == -2) {
+
+ $calculation = $this->checkCalculation($row['id']);
+
+ if ($row['operator'] == 0 && !($calculation == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($calculation != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($calculation < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($calculation <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($calculation > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($calculation >= $row['text']))
+ return false;
+
+ // kvote
+ } elseif ($row['spr_id'] == -3) {
+
+ $quota = $this->checkQuota($row['id']);
+
+ if ($row['operator'] == 0 && !($quota == $row['text']))
+ return false;
+ elseif ($row['operator'] == 1 && !($quota != $row['text']))
+ return false;
+ elseif ($row['operator'] == 2 && !($quota < $row['text']))
+ return false;
+ elseif ($row['operator'] == 3 && !($quota <= $row['text']))
+ return false;
+ elseif ($row['operator'] == 4 && !($quota > $row['text']))
+ return false;
+ elseif ($row['operator'] == 5 && !($quota >= $row['text']))
+ return false;
+
+ // naprava
+ } elseif ($row['spr_id'] == -4) {
+
+ if (in_array($row['text'], array('0','1','2','3'))){
+
+ // Star nacin detekcije - vedno vezan na prvi prihod, po novem detektiramo vsakic posebej
+ /*$sqlU = sisplet_query("SELECT device FROM srv_user WHERE id='".get('usr_id')."'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ if (!($rowU['device'] == $row['text']))
+ return false;*/
+
+ $device = 0;
+ $useragent = $_SERVER['HTTP_USER_AGENT'];
+
+ if ($useragent != '' && get_cfg_var('browscap')) {
+
+ $browser_detect = get_browser($useragent, true);
+
+ $detect = New Mobile_Detect();
+ $detect->setUserAgent($useragent);
+
+ // Detect naprave (pc, mobi, tablet, robot)
+ if ($detect->isMobile()) {
+ if ($detect->isTablet())
+ $device = 2;
+ else
+ $device = 1;
+ }
+ elseif ($browser_detect['crawler'] == 1){
+ $device = 3;
+ }
+ }
+
+ if (!($device == $row['text']))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @desc izracuna kalkulacijo in vrne rezultat
+ */
+ public function checkCalculation($condition)
+ {
+
+ $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$condition' ORDER BY vrstni_red ASC");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+
+ $i = 0;
+ $expression = '';
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($i++ != 0)
+ if ($row['operator'] == 0)
+ $expression .= ' + ';
+ elseif ($row['operator'] == 1)
+ $expression .= ' - ';
+ elseif ($row['operator'] == 2)
+ $expression .= ' * ';
+ elseif ($row['operator'] == 3)
+ $expression .= ' / ';
+
+ for ($i = 1; $i <= $row['left_bracket']; $i++)
+ $expression .= ' ( ';
+
+ // spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+
+ $row1 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ if ($row1['tip'] <= 3) { // radio, checkbox, dropdown
+ $sum = 0;
+ $sql2 = sisplet_query("SELECT v.variable FROM srv_data_vrednost" . get('db_table') . " d, srv_vrednost v WHERE d.vre_id=v.id AND d.spr_id='$row1[id]' AND d.usr_id='" . get('usr_id') . "'");
+ while ($row2 = mysqli_fetch_array($sql2)) { // zanka je zaradi checkboxov
+ $sum += $row2['variable'];
+ }
+ $expression .= $sum;
+
+ } elseif ($row1['tip'] == 7 || $row1['tip'] == 22 || $row1['tip'] == 25) { // number, calculation, quota
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ $row2 = mysqli_fetch_array($sql2);
+ if ($row2['text'] == '') $row2['text'] = 0;
+ $expression .= $row2['text'];
+
+ } elseif ($row1['tip'] == 8) { // datum
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ $row2 = mysqli_fetch_array($sql2);
+ if ($row2['text'] == '') $row2['text'] = 0;
+
+ $row2['text'] = ceil(strtotime($row2['text']) / (60 * 60 * 24));
+
+ $expression .= $row2['text'];
+ }
+
+ // multigrid in checkbox
+ } elseif ($row['vre_id'] > 0) {
+
+ $row1 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ // checkbox
+ if ($row1['tip'] == 2) {
+ $sum = 0;
+ $sql2 = sisplet_query("SELECT v.variable FROM srv_data_vrednost" . get('db_table') . " d, srv_vrednost v WHERE d.vre_id=v.id AND d.spr_id='$row1[id]' AND d.usr_id='" . get('usr_id') . "'");
+ while ($row2 = mysqli_fetch_array($sql2)) { // zanka je zaradi checkboxov
+ $sum += $row2['variable'];
+ }
+ $expression .= $sum;
+ }
+ // multigrid
+ else{
+ $sql1 = sisplet_query("SELECT g.variable, g.other FROM srv_data_grid" . get('db_table') . " d, srv_grid g WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.usr_id='" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ // Pri multigridih se missingi pri kalkulacijah stejejo kot 0 (in ne -99, -98...)
+ if ($row1['other'] < 0)
+ $row1['variable'] = 0;
+
+ $expression .= $row1['variable'];
+ }
+ }
+
+ // konstante
+ } elseif ($row['spr_id'] == -1) {
+
+ $expression .= $row['number'];
+
+ }
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $expression .= ' ) ';
+
+ }
+
+ $expression = 'return ' . $expression . ';';
+
+ return eval($expression);
+
+ }
+
+ /**
+ * @desc izracuna kvoto in vrne rezultat
+ */
+ public function checkQuota($condition)
+ {
+
+ $sql = sisplet_query("SELECT * FROM srv_quota WHERE cnd_id = '$condition' ORDER BY vrstni_red ASC");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+ $i = 0;
+ $expression = '';
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($i++ != 0)
+ if ($row['operator'] == 0)
+ $expression .= ' + ';
+ elseif ($row['operator'] == 1)
+ $expression .= ' - ';
+ elseif ($row['operator'] == 2)
+ $expression .= ' * ';
+ elseif ($row['operator'] == 3)
+ $expression .= ' / ';
+
+ for ($i = 1; $i <= $row['left_bracket']; $i++)
+ $expression .= ' ( ';
+
+ // spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ $row1 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ // radio, checkbox, multigrid
+ if ($row['vre_id'] > 0) {
+
+ // multigrid
+ if ($row1['tip'] == 6)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_grid" . get('db_table') . " d, srv_grid g, srv_user u
+ WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.grd_id='$row[grd_id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ // multicheckbox
+ elseif ($row1['tip'] == 16)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g, srv_user u
+ WHERE g.id=d.grd_id AND g.spr_id=d.spr_id AND d.spr_id='$row[spr_id]' AND d.vre_id='$row[vre_id]' AND d.grd_id='$row[grd_id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ // radio, select
+ elseif ($row1['tip'] == 1 || $row1['tip'] == 3)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_vrednost" . get('db_table') . " d, srv_user u
+ WHERE d.vre_id='$row[vre_id]' AND d.spr_id='$row1[id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ // checkbox
+ elseif ($row1['tip'] == 2)
+ $sql2 = sisplet_query("SELECT COUNT(*) AS quota
+ FROM srv_data_vrednost" . get('db_table') . " d, srv_user u
+ WHERE d.vre_id='$row[vre_id]' AND d.spr_id='$row1[id]' AND d.usr_id=u.id AND u.deleted='0'");
+
+ $row2 = mysqli_fetch_array($sql2);
+
+ $expression .= $row2['quota'];
+ }
+ } // konstante (statusi...)
+ elseif ($row['spr_id'] < 0) {
+
+ $status = '';
+
+ // Kvota ustreznih odgovorov
+ if ($row['spr_id'] == -7) {
+ $status .= ' AND (last_status=\'5\' OR last_status=\'6\') AND lurker=\'0\' ';
+ } // Kvota posameznih statusov
+ elseif ($row['spr_id'] > -7) {
+ $status .= ' AND last_status=\'' . -$row['spr_id'] . '\' ';
+ }
+
+ $sqlU = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='".get('anketa')."' ".$status." AND deleted='0'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ $expression .= $rowU['COUNT(id)'];
+ }
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $expression .= ' ) ';
+ }
+
+ $expression = 'return ' . $expression . ';';
+
+ return eval($expression);
+ }
+
+ /************************************************
+ * Preveri userja, ki se je vrnil in ga (če je tako nastavljeno) preusmeri na stran, kjer je končal
+ ************************************************/
+ public function check_cookie_return()
+ {
+
+ $row = \SurveyInfo::getInstance()->getSurveyRow();
+
+ // EVALVACIJA - nastavljeno je da ga preusmerimo na stran kjer je koncal - za studentsko evalvacijo vedno preusmerjamo z ustreznimi parametri - ZAENKRAT NI VKLOPLJENO
+ if (Common::checkModule('evalvacija') == '1' && false) {
+ $sql1 = sisplet_query("SELECT g.id FROM srv_user_grupa" . get('db_table') . " u, srv_grupa g WHERE u.gru_id=g.id AND u.usr_id='" . get('usr_id') . "' ORDER BY g.vrstni_red DESC LIMIT 1");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ save('grupa', $row1['id']);
+ $grupa = Find::getInstance()->findNextGrupa();
+
+ if ($grupa > 0) {
+ $params = $_SERVER['QUERY_STRING'];
+
+ setcookie('ref', get('anketa')); // cookie z referalom (da se ne sprozi redirect zaradi referala pri ?code= )
+ return header("Location: " . \SurveyInfo::getSurveyLink() . "&grupa=$grupa&" . $params . get('cookie_url') . "&c");
+ die();
+ }
+ }
+
+ // nastavljeno je da ga preusmerimo na stran kjer je koncal
+ if ($row['cookie_return'] == 1) {
+
+ $sql1 = sisplet_query("SELECT g.id FROM srv_user_grupa" . get('db_table') . " u, srv_grupa g WHERE u.gru_id=g.id AND u.usr_id='" . get('usr_id') . "' ORDER BY g.vrstni_red DESC LIMIT 1");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+
+ if(mysqli_num_rows($sql1) > 0){
+
+ $row1 = mysqli_fetch_array($sql1);
+
+ save('grupa', $row1['id']);
+
+ $grupa = Find::getInstance()->findNextGrupa();
+
+ if ($grupa > 0) {
+ setcookie('ref', get('anketa')); // cookie z referalom (da se ne sprozi redirect zaradi referala pri ?code= )
+ return header("Location: " . \SurveyInfo::getSurveyLink() . "&grupa=$grupa" . (isset($_GET['language']) ? '&language=' . $_GET['language'] : '') . (isset($_GET['skupina']) ? '&skupina=' . $_GET['skupina'] : '') . get('cookie_url') . "&c");
+ die();
+ }
+ }
+ }
+ }
+
+ /**
+ * preveri, ce je katera od spremenljivk CAPTCHA in preveri, ce je pravilno vnesena
+ * treba extra preverjat, ce je JS izklopljen
+ *
+ */
+ public function check_captcha()
+ {
+ global $secret_captcha;
+
+ // Ce urejamo podatke v admin vmesniku ne preverjamo nicesar
+ if(isset($_GET['t']) && $_GET['t'] == 'postprocess' || get('grupa') == '0' || get('grupa') == ''){
+ return;
+ }
+
+ $sql = sisplet_query("SELECT id, params FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND visible='1' AND tip='21' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $captcha = ($spremenljivkaParams->get('captcha') ? $spremenljivkaParams->get('captcha') : 0);
+
+ if ($captcha == 1) {
+ $recaptchaResponse = $_POST['g-recaptcha-response'];
+ $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse);
+
+ // zdaj pa zabeleži mail (pred pošiljanjem)
+ // zdaj pa še v bazi tistih ki so se ročno dodali
+ if(strstr($request,"true")){
+ //
+ }
+ else {
+ echo '<p>Wrong CAPTCHA code.</p><p><a href="#" onclick="javascript:history.go(-1)">Back</a></p>';
+ die();
+ }
+ }
+ }
+ }
+
+ /**
+ * preveri, ce preveri, ce je CAPTCHA pravilno vnesena pri uvodu (ce imamo staticen uvod s preverjanjem captche)
+ *
+ */
+ public function check_captcha_intro(){
+ global $secret_captcha;
+
+ $recaptchaResponse = $_POST['g-recaptcha-response'];
+ $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret_captcha."&response=".$recaptchaResponse);
+
+ if(strstr($request,"true")){
+ //
+ }
+ else {
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false).'?captcha_error=1');
+ die();
+ }
+ }
+
+ public function checkMissingForSpremenljivka($spremenljivka, $loop_id)
+ {
+ $missing = false;
+
+ $smv = new SurveyMissingValues(get('anketa'));
+ $missing_values = $smv->GetUnsetValuesForSurvey();
+
+ if (count($missing_values) > 0) {
+
+ $qry = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other IN ('" . implode('\',\'', array_keys($missing_values)) . "')");
+ $missing_vrednosti = array();
+ while ($row = mysqli_fetch_assoc($qry)) {
+ $missing_vrednosti[] = $row[id];
+ }
+ # pogledamo ali imamo kak zapis v srv_data_vrednost. potem je to najbrž missing
+
+ $srv_data_vrednost = array();
+ $sql2_c = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row2_c = mysqli_fetch_array($sql2_c)) {
+ #samo če je bil izbran missing -99 ne vem, -98 drugo .....
+ if (in_array($row2_c['vre_id'], $missing_vrednosti) && $missing == false) {
+ $missing = $row2_c['vre_id'];
+ }
+ }
+ }
+ return $missing;
+ }
+
+ // Preverimo, ce je uporabnik ze bil na strani
+ public function check_subsequent_visit(){
+
+ $sql = sisplet_query("SELECT g.id
+ FROM srv_user_grupa".get('db_table')." u, srv_grupa g
+ WHERE u.gru_id=g.id AND u.usr_id='".get('usr_id')."' AND g.id='".get('grupa')."'
+ ");
+
+ if(mysqli_num_rows($sql) > 0)
+ return true;
+ else
+ return false;
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Controller.php b/main/survey/app/Controllers/Controller.php
new file mode 100644
index 0000000..a9ad8fe
--- /dev/null
+++ b/main/survey/app/Controllers/Controller.php
@@ -0,0 +1,113 @@
+<?php
+/**
+ * MINI - an extremely simple naked PHP application
+ *
+ * @package mini
+ * @author Panique
+ * @link http://www.php-mini.com
+ * @link https://github.com/panique/mini/
+ * @license http://opensource.org/licenses/MIT MIT License
+ */
+
+namespace App\Controllers;
+
+use App\Controllers\VariableClass as Variable;
+use App\Models\Model as Model;
+use PDO;
+
+class Controller
+{
+ /**
+ * @var null Database Connection
+ */
+ public $db = null;
+
+ /**
+ * @var null Model
+ */
+ public $model = null;
+
+ /**
+ * Whenever controller is created, open a database connection too and load "the model".
+ */
+ public function __construct()
+ {
+ $this->openDatabaseConnection();
+ $this->loadModel();
+ $this->getGlobalVariables();
+ }
+
+ /************************************************
+ * Vse globalne spremenljivke dodamo v omenjen razred, da jih lahko potem kličemo na posameznem razredu
+ *
+ * @return $this
+ ************************************************/
+ public static $global_user_id;
+ public static $admin_type;
+ public static $site_url;
+ public static $site_path;
+ public static $lang;
+ public static $mysql_database_name;
+
+ public function getGlobalVariables()
+ {
+ // Definiramo globalne spremenljivke, ki jih kasneje uporabljamo v funkcijah
+ global $global_user_id;
+ global $admin_type;
+ global $site_url;
+ global $site_path;
+ global $lang;
+ global $mysql_database_name;
+
+ self::$global_user_id = $global_user_id;
+ self::$admin_type = $admin_type;
+ self::$site_url = $site_url;
+ self::$site_path = $site_path;
+ self::$lang = $lang;
+ self::$mysql_database_name = $mysql_database_name;
+ }
+
+ /************************************************
+ * Pridobimo vse variable, ki se uporabljajo za main/survey in jih dodamo na Controller -> $this variable
+ *
+ * @return $this
+ ************************************************/
+ public function getAllVariables()
+ {
+ // pridobimo vse spremenljivke, ki jih uporabljamo med različnimi razredi
+ $var = Variable::getAll();
+
+ // vrnemo kot $this parameter, da jih uporabljamo znotraj razreda in ni potrebno vse popravljati
+ // v obliko Variable::get('name') amap preprosto kličemo $this->name
+ foreach ($var as $key => $value) {
+ $this->$key = $value;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Open the database connection with the credentials from application/config/config.php
+ */
+ private function openDatabaseConnection()
+ {
+ // set the (optional) options of the PDO connection. in this case, we set the fetch mode to
+ // "objects", which means all results will be objects, like this: $result->user_name !
+ // For example, fetch mode FETCH_ASSOC would return results like this: $result["user_name] !
+ // @see http://www.php.net/manual/en/pdostatement.fetch.php
+ $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
+
+ // generate a database connection, using the PDO connector
+ // @see http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/
+ $this->db = new PDO(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS, $options);
+ }
+
+ /**
+ * Loads the "model".
+ * @return object model
+ */
+ public function loadModel()
+ {
+ $this->model = new Model($this->db);
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/DisplayController.php b/main/survey/app/Controllers/DisplayController.php
new file mode 100644
index 0000000..c0cbf43
--- /dev/null
+++ b/main/survey/app/Controllers/DisplayController.php
@@ -0,0 +1,864 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 05.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+// Osnovni razredi
+use App\Controllers\AjaxController as Ajax;
+use App\Controllers\BodyController as Body;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use SurveyInfo;
+use SurveySetting;
+use Common;
+use SurveyGorenje;
+
+class DisplayController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DisplayController();
+ }
+
+ public function logo()
+ {
+ // Za gorenje posebej prikazemo logo
+ if(Common::checkModule('gorenje')){
+ SurveyGorenje::logoGorenje(get('anketa'), get('usr_id'));
+ return;
+ }
+
+ $class = '';
+ $url = self::$site_url;
+
+ // Logo prikazemo angleski v vseh primerih kjer respondentov jezik ni slovenscina in ce ni custom - popravimo tudi link na angleski frontend
+ if (self::$lang['language'] != 'Slovenščina') {
+ $class = ' class="english"';
+ if (strpos(self::$site_url, 'www.1ka.si') !== false)
+ $url = self::$site_url.'d/en/';
+ }
+
+ echo '<div id="logo" ' . $class . '><a href="' . $url . '" title="' . self::$lang['srv_1cs'] . ' ' . self::$lang['srv_footer_1ka'] . '" target="_blank">' . self::$lang['srv_1cs'] . '</a><div id="logo_right"></div></div>';
+ }
+
+ /**
+ * @desc prikaze progress bar
+ */
+ public function progress_bar()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sql_count_pages = sisplet_query("SELECT COUNT( g.id ) AS count FROM srv_grupa g WHERE g.ank_id = '" . get('anketa') . "'");
+ $row_count_pages = mysqli_fetch_assoc($sql_count_pages);
+
+ // Ce prikazemo gumb za tawk chat
+ $tawk_chat = false;
+ if(SurveyInfo::getInstance()->checkSurveyModule('chat') == '1'){
+ $sql_chat = sisplet_query("SELECT chat_type FROM srv_chat_settings WHERE ank_id='".get('anketa')."'");
+ $row_chat = mysqli_fetch_assoc($sql_chat);
+
+ if($row_chat['chat_type'] == '2')
+ $tawk_chat = true;
+ }
+
+ if (($row['progressbar'] == 1 && $row_count_pages['count'] > 1) || ($row['continue_later'] == 1) || $tawk_chat) {
+ echo '<div class="header_settings_holder">';
+
+ if ($row['progressbar'] == 1 && $row_count_pages['count'] > 1) {
+
+ echo '<div class="progress_bar">';
+
+ $sql1 = sisplet_query("SELECT COUNT(s.id) AS count
+ FROM srv_grupa g, srv_spremenljivka s
+ WHERE s.gru_id=g.id AND g.ank_id = '" . get('anketa') . "' AND s.visible='1'");
+ $row1 = mysqli_fetch_array($sql1);
+ $all = $row1['count'];
+
+ $sql2 = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sql3 = sisplet_query("SELECT COUNT(s.id) AS count
+ FROM srv_grupa g, srv_spremenljivka s
+ WHERE s.gru_id=g.id AND g.ank_id = '" . get('anketa') . "' AND s.visible='1' AND g.vrstni_red<='$row2[vrstni_red]'");
+ $row3 = mysqli_fetch_array($sql3);
+ $ans = $row3['count'];
+
+ if ($all > 0) {
+
+ $p = round($ans / $all * 100, 0);
+
+ echo '<span>0%</span>';
+ echo '<div class="progress_bar_line"><span style="width:' . $p . '%"></span></div>';
+ echo '<span>100%</span>';
+ }
+
+ echo '</div>';
+ }
+
+ // Prikaz opcije "nadaljuj kasneje"
+ if ($row['continue_later'] == 1) {
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_continue_later = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_continue_later' . $_lang);
+ if ($srv_continue_later == '') $srv_continue_later = self::$lang['srv_continue_later'];
+
+ echo '<div class="continue_later_setting">';
+ echo ' <a href="#" onclick="continue_later(\'' . self::$site_url . '\', \'' . get('lang_id') . '\'); return false;">' . $srv_continue_later . '</a>';
+ echo '</div>';
+ }
+
+ // Priakz gumba za vklop tawk chata
+ if ($tawk_chat){
+ echo '<div class="tawk_chat">';
+ echo ' <span class="tawk-chat-activation">'.self::$lang['srv_chat_turn_on'].'</span>';
+ echo '</div>';
+ }
+
+ echo '</div>';
+ }
+ }
+
+ // Prikaze ikono za izvoz pdf rezultatov v zakljucku
+ public function displayRespondetnPDF()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ if ((int)$row['concl_PDF_link'] == 1) {
+
+ // Ce je vklopljen evoli ali evoli employeeship meter, prikazemo link do posebnega porocila
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli') || SurveyInfo::getInstance()->checkSurveyModule('evoli_employmeter')){
+
+ // Nastavimo ustrezen jezik za report
+ if(self::$lang['id'] == '1')
+ $report_lang = 'slo';
+ elseif(self::$lang['id'] == '29')
+ $report_lang = 'dan';
+ else
+ $report_lang = '';
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli_employmeter'))
+ $evoli_module = 'pdf_employmeter';
+ else
+ $evoli_module = 'pdf_evoli';
+
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(serialize(array('m' => $evoli_module, 'anketa' => get('anketa'), 'usr_id' => get('usr_id'), 'lang' => $report_lang)));
+
+ echo '<br class="clr"/>';
+
+ echo '<div class="concl_evoli_report naslov"><p>';
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli')){
+ echo self::$lang['srv_report_pdf_evoli'].': ';
+
+ echo '<a href="' . $pdf_url . '" class="pdfExport" target="_blank">';
+ echo '<span class="evoli_button">'.self::$lang['srv_report_pdf_evoli_button'].'</span>';
+ echo '</a>';
+ }
+ else{
+ echo self::$lang['srv_report_pdf_evoli_em'].': ';
+
+ echo '<a href="' . $pdf_url . '" class="pdfExport" target="_blank">';
+ echo '<span class="evoli_button">'.self::$lang['srv_report_pdf_evoli_em_button'].'</span>';
+ echo '</a>';
+ }
+
+ echo '</p></div>';
+ }
+ else{
+ # parametre zapakiramo v array injih serializiramo in zakodiramo z base64
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(serialize(array('a' => 'pdf_results', 'anketa' => get('anketa'), 'usr_id' => get('usr_id'), 'type' => '0')));
+
+ #echo '<div id="icon_bar">';
+ echo '<br class="clr"/><div><p>';
+ echo '<a href="' . $pdf_url . '" class="pdfExport" target="_blank"><span class="sprites pdf_white"></span> '.self::$lang['srv_report_pdf'].'</a>';
+ echo '</p></div>';
+ }
+ }
+ }
+
+ // Prikaze url za naknadno popravljanje odgovorov (od zacetka ankete) v zakljucku
+ public function displayReturnEditURL()
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ if ((int)$row['concl_return_edit'] == 1) {
+
+ $return_url = $_POST['url'] . '&return=1';
+ $return_url = SurveyInfo::getSurveyLink() . get('cookie_url') . '&return=1';
+
+ echo '<br class="clr"/><div class="return_edit_url"><p>';
+ echo self::$lang['srv_concl_return_edit_URL'].':<br />';
+ echo '<a href="'.$return_url.'" title="'.self::$lang['srv_concl_return_edit_URL'].'"><span>'.$return_url.'</span></a>';
+ echo '</p></div>';
+ }
+ }
+
+ // Prikaze pravilne rezultate v primeru modula KVIZ
+ public function displayQuizAnswers()
+ {
+ // echo '<h2>'.self::$lang['results'].'</h2>';
+
+ // Loop cez vsa ustrezna vprasanja (ki imajo oznacen vsaj en pravilen odgovor)
+ $sqlS = sisplet_query("SELECT s.id, s.naslov, s.info FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.tip IN ('1', '2', '3') AND s.visible='1'
+ AND EXISTS (SELECT q.* FROM srv_quiz_vrednost q WHERE q.spr_id=s.id)
+ AND NOT EXISTS (SELECT d.* FROM srv_data_vrednost_active d WHERE d.spr_id=s.id AND usr_id='".get('usr_id')."' AND d.vre_id='-2')");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ echo '<div class="spremenljivka">';
+
+ //Vprasanja::getInstance()->displaySpremenljivka($rowS['id']);
+
+ echo '<div class="naslov">'.$rowS['naslov'];
+ if ($rowS['info'] != '')
+ echo '<p class="spremenljivka_info">' . $rowS['info'] . '</p>';
+ echo '</div>';
+
+ echo '<div class="variable_holder">';
+
+ // Loop cez vse vrednosti v vprasanju
+ $sqlV = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='".$rowS['id']."' ORDER BY vrstni_red ASC");
+ while($rowV = mysqli_fetch_array($sqlV)){
+
+ // Za vsako pogledamo ce je pravilna oz napacna
+ $answer = false;
+ $correct = false;
+
+ $sqlAnswer = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."' AND usr_id='".get('usr_id')."'");
+ if(mysqli_num_rows($sqlAnswer) == 1)
+ $answer = true;
+
+ $sqlQuiz = sisplet_query("SELECT * FROM srv_quiz_vrednost WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."'");
+ if(mysqli_num_rows($sqlQuiz) == 1)
+ $correct = true;
+
+ if($correct && $answer){
+ echo '<div class="variabla green">';
+ echo $rowV['naslov'] . '<span class="true"></span>';
+ echo '</div>';
+ }
+ elseif($correct){
+ echo '<div class="variabla bold">';
+ //echo $rowV['naslov'] . '<span class="true2"></span>';
+ echo $rowV['naslov'];
+ echo '</div>';
+ }
+ elseif($answer){
+ echo '<div class="variabla red">';
+ echo $rowV['naslov'] . '<span class="false"></span>';
+ echo '</div>';
+ }
+ else{
+ echo '<div class="variabla">';
+ echo $rowV['naslov'];
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ echo '</div>';
+ }
+ }
+
+ // Prikaze graf rezultatov v primeru modula KVIZ
+ public function displayQuizChart()
+ {
+ //echo '<h2>'.self::$lang['results'].'</h2>';
+
+ $cnt_all = 0;
+ $cnt_answered = 0;
+ $cnt_unanswered = 0;
+ $cnt_correct = 0;
+ $cnt_incorrect = 0;
+
+ // Loop cez vsa ustrezna vprasanja (ki imajo oznacen vsaj en pravilen odgovor)
+ $sqlS = sisplet_query("SELECT s.id, s.naslov, s.info FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.tip IN ('1', '2', '3') AND s.visible='1'
+ AND EXISTS (SELECT q.* FROM srv_quiz_vrednost q WHERE q.spr_id=s.id)
+ AND NOT EXISTS (SELECT d.* FROM srv_data_vrednost_active d WHERE d.spr_id=s.id AND usr_id='".get('usr_id')."' AND d.vre_id='-2')");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ $cnt_all++;
+
+ $answer = false;
+ $correct = false;
+
+ // Loop cez vse vrednosti v vprasanju
+ $sqlV = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='".$rowS['id']."' ORDER BY vrstni_red ASC");
+ while($rowV = mysqli_fetch_array($sqlV)){
+
+ // Za vsako pogledamo ce je odgovorjena
+ $sqlAnswer = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."' AND usr_id='".get('usr_id')."'");
+ if(mysqli_num_rows($sqlAnswer) == 1){
+ $answer = true;
+
+ // Za vsako pogledamo ce je pravilna oz napacna
+ $sqlQuiz = sisplet_query("SELECT * FROM srv_quiz_vrednost WHERE spr_id='".$rowS['id']."' AND vre_id='".$rowV['id']."'");
+
+ if(mysqli_num_rows($sqlQuiz) == 1){
+ $correct = true;
+ }
+ // Ce je oznacil napacno breakamo
+ else{
+ $correct = false;
+ break;
+ }
+ }
+ }
+
+ if($answer)
+ $cnt_answered++;
+ else
+ $cnt_unanswered++;
+
+ if($correct)
+ $cnt_correct++;
+ else
+ $cnt_incorrect++;
+ }
+
+
+ // Izrisemo graf
+ /*echo 'Vseh: '.$cnt_all;
+ echo '<br>odgovorjen: '.$cnt_answered;
+ echo '<br>neodg: '.$cnt_unanswered;
+ echo '<br>pravilen: '.$cnt_correct;
+ echo '<br>nepravilen: '.$cnt_incorrect;*/
+
+ // Include knjiznice Chart.JS
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/Chart.min.js"></script>';
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/chart_init.js?v=3"></script>';
+
+ // Izris grafa
+ echo '<div class="spremenljivka" id="quiz_results_chart_holder">';
+ echo '<canvas id="quiz_results_chart" class="chart"></canvas>';
+ echo '<script>$(document).ready(function(){ init_quiz_results_chart('.$cnt_all.', '.$cnt_correct.', '.$cnt_incorrect.', \''.self::$lang['srv_quiz_results_chart_correct'].'\', \''.self::$lang['srv_quiz_results_chart_incorrect'].'\'); })</script>';
+ echo '</div>';
+ }
+
+
+ // Prikaze graf za matriko odlicnosti (excell_matrix) v primeru modula Excelleration matrix
+ public function displayExcellChart()
+ {
+ echo '<h3 style="padding-left: 20px;">'.self::$lang['srv_excell_matrix_title'].'</h3>';
+
+ // Loop cez vsa ustrezna vprasanja in njihove vrednosti (jih zakesiramo)
+ $variables = array();
+ $variable_marza = array();
+ $variable_lp = array();
+ $spr_ids = '';
+ $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable, v.id AS vre_id, v.variable AS vre_variable, v.naslov AS vre_naslov
+ FROM srv_spremenljivka s, srv_grupa g, srv_vrednost v
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id
+ AND s.variable LIKE 'em%'
+ AND v.spr_id=s.id");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ // Marza
+ if($rowS['spr_variable'] == 'emM'){
+
+ // ID-ji vprasanj za query
+ if(!isset($variable_marza['id']))
+ $spr_ids .= $rowS['spr_id'].',';
+
+ $variable_marza['naslov'] = strip_tags($rowS['spr_naslov']);
+ $variable_marza['id'] = $rowS['spr_id'];
+
+ $variable_marza['vrednosti'][$rowS['vre_id']]['variable'] = $rowS['vre_variable'];
+ $variable_marza['vrednosti'][$rowS['vre_id']]['naslov'] = $rowS['vre_naslov'];
+ }
+ // Letni promet
+ elseif($rowS['spr_variable'] == 'emLP'){
+
+ $variable_lp['naslov'] = strip_tags($rowS['spr_naslov']);
+ $variable_lp['id'] = $rowS['spr_id'];
+ }
+ // Ostali
+ else{
+
+ // ID-ji vprasanj za query
+ if(!isset($variables[$rowS['spr_id']]['variable']))
+ $spr_ids .= $rowS['spr_id'].',';
+
+ $variables[$rowS['spr_id']]['naslov'] = strip_tags($rowS['spr_naslov']);
+ $variables[$rowS['spr_id']]['variable'] = $rowS['spr_variable'];
+
+ $variables[$rowS['spr_id']]['vrednosti'][$rowS['vre_id']]['variable'] = $rowS['vre_variable'];
+ $variables[$rowS['spr_id']]['vrednosti'][$rowS['vre_id']]['naslov'] = $rowS['vre_naslov'];
+ }
+ }
+ $spr_ids = substr($spr_ids, 0, -1);
+
+ // Loop cez vse respondente s statusom 6 - vsak je svoj bubble
+ $data = array();
+ $sum = 0;
+ $cnt = 0;
+ $sqlAnswers = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE usr_id='".get('usr_id')."' AND spr_id IN (".$spr_ids.")");
+ while($rowAnswers = mysqli_fetch_array($sqlAnswers)){
+
+ // Marzo normalno preberemo
+ if($rowAnswers['spr_id'] == $variable_marza['id']){
+ $value = $variable_marza['vrednosti'][$rowAnswers['vre_id']]['variable'];
+ $data['marza'] = $value;
+
+ $variable_marza['value'] = $rowAnswers['vre_id'];
+ }
+ // Pri ostalih racunamo povprecje
+ else{
+ $value = $variables[$rowAnswers['spr_id']]['vrednosti'][$rowAnswers['vre_id']]['variable'];
+ $sum += (int)$value;
+ $cnt++;
+
+ $variables[$rowAnswers['spr_id']]['value'] = $rowAnswers['vre_id'];
+ }
+ }
+ $data['excell'] = round($sum/$cnt, 1);
+
+ // Posebej pridobimo tudi letni promet
+ $sqlAnswers = sisplet_query("SELECT text FROM srv_data_text_active WHERE usr_id='".get('usr_id')."' AND spr_id='".$variable_lp['id']."'");
+ $rowAnswers = mysqli_fetch_array($sqlAnswers);
+ $data['letni_promet'] = $rowAnswers['text'];
+ $variable_lp['value'] = $rowAnswers['text'];
+
+ // Max radius=80 (vrednost 1000), min radius=8 (vrednost 100)
+ $radius = $data['letni_promet'];
+
+ // Include knjiznice Chart.JS
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/Chart.min.js"></script>';
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/chart_init.js?v=2"></script>';
+
+ // Izris grafa
+ echo '<div class="spremenljivka">';
+ echo '<canvas id="excell_matrix_chart" class="chart"></canvas>';
+ echo '<script>$(document).ready(function(){ init_excell_matrix('.$data['excell'].', '.$data['marza'].', '.$radius.'); })</script>';
+ echo '</div>';
+
+
+ // Izrisemo se seznam vprasanj
+ foreach($variables as $spr_id => $spremenljivka){
+
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$spremenljivka['naslov'].'</div>';
+ echo ' <div class="variable_holder">';
+ foreach($spremenljivka['vrednosti'] as $vre_id => $vrednost){
+ echo ' <div class="variabla" '.($variables[$spr_id]['value'] == $vre_id ? ' style="font-weight:bold; color:red;"' : '').'>'.$vrednost['naslov'].'</div>';
+ }
+ echo ' </div>';
+ echo '</div>';
+ }
+
+ // Marza
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$variable_marza['naslov'].'</div>';
+ echo ' <div class="variable_holder">';
+ foreach($variable_marza['vrednosti'] as $vre_id => $vrednost){
+ echo ' <div class="variabla" '.($variable_marza['value'] == $vre_id ? ' style="font-weight:bold; color:red;"' : '').'>'.$vrednost['naslov'].'</div>';
+ }
+ echo ' </div>';
+ echo '</div>';
+
+ // Letni promet
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$variable_lp['naslov'].'</div>';
+ echo ' <div class="variable_holder">';
+ echo ' <div class="variabla" style="font-weight:bold; color:red;">'.$variable_lp['value'].'</div>';
+ echo ' </div>';
+ echo '</div>';
+ }
+
+
+ // SKAVTI - prikaze povzetek in graf za njihovo anketo
+ public function displaySkavtiAnswers(){
+
+ // Stevilo top pohval in izziv, ki jih izpisemo v zakljucku
+ $max_odgovorov = 3;
+
+ $vprasanja = array();
+ $spr_ids = '';
+
+ // Loop cez vsa ustrezna vprasanja in njihove vrednosti (jih zakesiramo)
+ $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id
+ AND s.variable LIKE 'R%'
+ ");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ $vprasanje_number = substr($rowS['spr_variable'], 1);
+ $vprasanja[$rowS['spr_id']] = $vprasanje_number;
+
+ // ID-ji vprasanj za query
+ $spr_ids .= $rowS['spr_id'].',';
+ }
+
+ $spr_ids = substr($spr_ids, 0, -1);
+
+
+ // Loop cez vse response za vprasanja
+ $pohvale = array();
+ $izzivi = array();
+ $sqlAnswers = sisplet_query("SELECT vd.*, v.naslov, v.variable
+ FROM srv_data_vrednost_active vd, srv_vrednost v
+ WHERE vd.usr_id='".get('usr_id')."' AND vd.spr_id IN (".$spr_ids.")
+ AND v.id=vd.vre_id
+ ");
+ while($rowAnswers = mysqli_fetch_array($sqlAnswers)){
+
+ // Pohvala
+ if((int)$rowAnswers['variable'] >= 1 && (int)$rowAnswers['variable'] <= 199){
+ $pohvale[(int)$rowAnswers['variable']] = $rowAnswers;
+ }
+ // Izziv
+ elseif((int)$rowAnswers['variable'] >= 201 && (int)$rowAnswers['variable'] <= 399){
+ $izzivi[(int)$rowAnswers['variable']] = $rowAnswers;
+ }
+ }
+
+ // Sortiramo po velikosti
+ ksort($pohvale, SORT_NUMERIC);
+ ksort($izzivi, SORT_NUMERIC);
+
+
+ // Loop cez komentarje v nagovorih
+ $pohvale_besedilo = array();
+ $izzivi_besedilo = array();
+ $sqlS = sisplet_query("SELECT s.id AS spr_id, s.naslov AS spr_naslov, s.variable AS spr_variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id
+ AND (s.variable LIKE 'P%' OR s.variable LIKE 'G%')
+ ");
+ if (!$sqlS) echo mysqli_error($GLOBALS['connect_db']);
+ while($rowS = mysqli_fetch_array($sqlS)){
+
+ $tip = substr($rowS['spr_variable'], 0, 1);
+ $vprasanje_number = substr($rowS['spr_variable'], 1);
+ $naslov = $rowS['spr_naslov'];
+
+ // Pohvala
+ if($tip == 'P'){
+ $pohvale_besedilo[$vprasanje_number] = $naslov;
+ }
+ // Izziv
+ elseif($tip == 'G'){
+ $izzivi_besedilo[$vprasanje_number] = $naslov;
+ }
+ }
+
+
+ // Izrisemo seznam vprasanj s pohvalami
+ echo '<h2 style="padding-left: 20px;">POHVALE</h2>';
+
+ // Nagovor za pohvale
+ $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='pohvale'
+ ");
+ $rowNagovor = mysqli_fetch_array($sqlNagovor);
+ echo '<div class="spremenljivka" style="border-bottom:0;"><div class="naslov">'.$rowNagovor['naslov'].'</div></div>';
+
+ $i = 1;
+ foreach($pohvale as $pohvala_vrednost => $vrednost){
+
+ if($i > $max_odgovorov)
+ break;
+
+ $spr_id = $vrednost['spr_id'];
+ $vprasanje_number = $vprasanja[$spr_id];
+
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$pohvale_besedilo[$vprasanje_number].'</div>';
+ echo '</div>';
+
+ $i++;
+ }
+
+ // Izrisemo seznam vprasanj z izzivi
+ echo '<br><h2 style="padding-left: 20px;">IZZIVI</h2>';
+
+ // Nagovor za izzive
+ $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='izzivi'
+ ");
+ $rowNagovor = mysqli_fetch_array($sqlNagovor);
+ echo '<div class="spremenljivka" style="border-bottom:0;"><div class="naslov">'.$rowNagovor['naslov'].'</div></div>';
+
+ $i = 1;
+ foreach($izzivi as $izziv_vrednost => $vrednost){
+
+ if($i > $max_odgovorov)
+ break;
+
+ $spr_id = $vrednost['spr_id'];
+ $vprasanje_number = $vprasanja[$spr_id];
+
+ echo '<div class="spremenljivka">';
+ echo ' <div class="naslov">'.$izzivi_besedilo[$vprasanje_number].'</div>';
+ echo '</div>';
+
+ $i++;
+ }
+
+ $this->displaySkavtiRadar();
+ }
+
+ // SKAVTI - prikaze graf pajkovo mrezo
+ private function displaySkavtiRadar(){
+
+ // Include knjiznice Chart.JS
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/Chart.min.js"></script>';
+ echo '<script src="'.self::$site_url.'/main/survey/js/ChartJS/chart_init.js?v=3"></script>';
+
+
+ // Priprava podatkov za radar
+ $radar_data = array();
+ $sqlB = sisplet_query("SELECT i.label, i.id
+ FROM srv_if i, srv_branching b
+ WHERE b.ank_id='".get('anketa')."' AND i.id=b.element_if
+ AND i.tip='1'
+ ");
+ if (!$sqlB) echo mysqli_error($GLOBALS['connect_db']);
+
+ // Za graf rabimo vsaj 3 ogljisca
+ if(mysqli_num_rows($sqlB) < 3)
+ return;
+
+ // Loop cez bloke (stranica radarja)
+ while($rowB = mysqli_fetch_array($sqlB)){
+
+ // Dobimo vsa ustrezna vprasanja z odgovori v tem bloku
+ $sqlQ = sisplet_query("SELECT s.id AS spr_id, s.variable AS spr_variable, v.naslov, v.variable, vd.*
+ FROM srv_branching b, srv_spremenljivka s, srv_vrednost v, srv_data_vrednost_active vd
+ WHERE b.ank_id='".get('anketa')."' AND b.parent='".$rowB['id']."' AND b.element_spr=s.id
+ AND s.variable LIKE 'R%'
+ AND vd.usr_id='".get('usr_id')."' AND vd.spr_id=s.id
+ AND v.id=vd.vre_id
+ ");
+ if (!$sqlQ) echo mysqli_error($GLOBALS['connect_db']);
+
+ // Loop cez vprasanja in odgovore v bloku
+ $count_answers_pohvale = 0;
+ $count_answers_izzivi = 0;
+ while($rowQ = mysqli_fetch_array($sqlQ)){
+
+ // Pohvala
+ if((int)$rowQ['variable'] >= 1 && (int)$rowQ['variable'] <= 200){
+ $count_answers_pohvale++;
+ }
+ // Izziv
+ elseif((int)$rowQ['variable'] >= 201 && (int)$rowQ['variable'] <= 400){
+ $count_answers_izzivi++;
+ }
+ }
+
+ $count_answers_all = (int)$count_answers_pohvale + (int)$count_answers_izzivi;
+ if($count_answers_all > 0){
+ $radar_data[$rowB['label']]['all'] = $count_answers_all;
+ $radar_data[$rowB['label']]['pohvale'] = $count_answers_pohvale;
+ $radar_data[$rowB['label']]['izzivi'] = $count_answers_izzivi;
+ }
+ }
+ //echo '<pre>' . var_export($radar_data, true) . '</pre>';
+
+ $labels = array();
+ $values = array();
+ $i = 0;
+ foreach($radar_data as $radar_label => $radar_values){
+
+ $labels[$i] = $radar_label;
+ $pohvale[$i] = round($radar_values['pohvale'] / $radar_values['all'] * 10, 2);
+ $izzivi[$i] = round($radar_values['izzivi'] / $radar_values['all'] * 10, 2);
+
+ $i++;
+ }
+
+ $json_labels = json_encode($labels);
+ $json_pohvale = json_encode($pohvale);
+ $json_izzivi = json_encode($izzivi);
+
+ echo '<br><h2 style="padding-left: 20px;">Pajkova mreža</h2>';
+
+ // Nagovor za mrezo
+ $sqlNagovor = sisplet_query("SELECT s.naslov, s.variable
+ FROM srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='".get('anketa')."' AND s.gru_id=g.id AND s.variable='mreza'
+ ");
+ $rowNagovor = mysqli_fetch_array($sqlNagovor);
+ echo '<div class="spremenljivka" style="border-bottom:0;"><div class="naslov">'.$rowNagovor['naslov'].'</div></div>';
+
+ // Izris grafa
+ echo '<div class="spremenljivka radar_chart" id="skavti_radar_chart_holder">';
+
+ echo '<canvas id="skavti_radar_chart" class="chart"></canvas>';
+ echo '<script>$(document).ready(function(){ init_skavti_radar('.$json_labels.', '.$json_pohvale.', '.$json_izzivi.'); })</script>';
+
+ echo '</div>';
+ }
+
+
+ /**
+ * prikaze lepo obvestilo o napaki (anketa je zaključena itd...)
+ *
+ * @param mixed $text
+ */
+ public function displayNapaka($text)
+ {
+ Header::getInstance()->header();
+
+ $anketa = get('anketa');
+
+ echo '<div class="outercontainer_holder"><div class="outercontainer_holder_top"></div>';
+ echo '<div id="outercontainer">';
+
+ echo ' <div class="outercontainer_header"></div>';
+
+
+ echo ' <div id="container">';
+
+ $this->logo();
+
+ echo ' <h1>' . Helper::getInstance()->displayAkronim() . '</h1>';
+
+ echo ' <div class="grupa">';
+ echo ' <div class="spremenljivka">';
+ echo ' <p>' . $text . '</p>';
+ echo ' </div>';
+ echo ' </div>'; // -grupa
+
+ echo ' </div>'; // -container
+
+ Body::getInstance()->displayFooterNote();
+
+ echo '</div>'; // -outercontainer
+ echo '<div class="outercontainer_holder_bottom"></div></div>'; // -outercontainer_holder
+ }
+
+ /**
+ * Prikaze zavihke za bloke, ce obstajajo
+ *
+ */
+ public function display_tabs()
+ {
+
+ $sql = sisplet_query("SELECT * FROM srv_if i, srv_branching b WHERE i.tab='1' AND i.tip='1' AND i.id=b.element_if AND b.ank_id='" . get('anketa') . "' ORDER BY b.parent, b.vrstni_red");
+ if (mysqli_num_rows($sql) > 0) {
+
+ echo '<div class="tabs">';
+
+ $i = 0;
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($i++ != 0) echo ' | ';
+ $label = ($row['label'] == '' ? self::$lang['srv_blok'] . ' (' . $row['number'] . ')' : $row['label']);
+ echo '<a href="#" onclick="submitForm(\'' . $row['id'] . '\'); return false;" ' . (Ajax::getInstance()->ajax_grupa_for_if($row['id']) == get('grupa') ? ' class="active"' : '') . '>' . $label . '</a> ';
+ }
+
+ echo '</div>';
+
+ }
+ }
+
+ /**
+ * @desc konstruktor
+ */
+ public function PrintSurvey()
+ {
+
+ if (isset($_GET['anketa'])) {
+ save('anketa', $_GET['anketa']);
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ // uvodni nagovor
+ if ($rowa['show_intro'] != 0) {
+ Body::getInstance()->displayIntroduction();
+ }
+
+ // prikažemo ankete
+ do {
+ save('grupa', Find::getInstance()->findNextGrupa());
+
+ Body::getInstance()->displayAnketa();
+ } while (get('grupa') != Find::getInstance()->findNextGrupa() && Find::getInstance()->findNextGrupa() > 0);
+
+ // prikažemo konec
+ Body::getInstance()->displayKonec();
+ } else
+ echo 'Ni podatkov o anketi!';
+ }
+
+
+ /**
+ * @desc prikaze chat okno za tawk chat, ce je modul vklopljen (js koda)
+ */
+ public function displayChatTAWK(){
+
+ echo '<div style="display:none;">';
+
+ $sql = sisplet_query("SELECT code, chat_type FROM srv_chat_settings WHERE ank_id='".get('anketa')."'");
+ if(mysqli_num_rows($sql) > 0){
+
+ $row = mysqli_fetch_array($sql);
+
+ if($row['code'] != ''){
+
+ // JS koda za widget
+ echo $row['code'];
+
+ echo "<script type='text/javascript'>";
+
+ // Dodatno se poslje tudi recnum in usr_id
+ $sqlu = sisplet_query("SELECT id, recnum FROM srv_user WHERE id = '".get('usr_id')."'");
+ $rowu = mysqli_fetch_array($sqlu);
+ echo "Tawk_API = Tawk_API || {}; Tawk_API.visitor = {name : 'Recnum ".$rowu['recnum']." (".get('usr_id').")', email : ''}; \n";
+
+ // Nastavimo za span class="tawk-chat-activation" tage
+ if($row['chat_type'] == '1' || $row['chat_type'] == '2'){
+
+ // Na klik prikazemo chat
+ echo "$('.tawk-chat-activation').click(function() { Tawk_API.showWidget(); Tawk_API.maximize(); }); \n";
+
+ // Dodatna nastavitev, da je chat po defaultu skrit
+ echo "Tawk_API.onLoad = function(){ Tawk_API.hideWidget();
+ Tawk_API.setAttributes({
+ 'recnum' : '".$rowu['recnum']."',
+ 'user-id' : '".get('usr_id')."'}, function(error){});
+ }; \n";
+ }
+ else{
+ // Dodatno še shranimo recnum in id, ce user slucajno spremeni ime
+ echo "Tawk_API.onLoad = function(){ Tawk_API.setAttributes({
+ 'recnum' : '".$rowu['recnum']."',
+ 'user-id' : '".get('usr_id')."'}, function(error){});
+ };";
+ }
+ echo "</script>";
+ }
+ }
+
+ echo '</div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/FindController.php b/main/survey/app/Controllers/FindController.php
new file mode 100644
index 0000000..0f60a43
--- /dev/null
+++ b/main/survey/app/Controllers/FindController.php
@@ -0,0 +1,290 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use Cache;
+
+class FindController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ parent::getAllVariables();
+
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new FindController();
+ }
+
+
+ /**
+ * poisce, ce ima podani element parenta, ki je loop
+ *
+ */
+ public static function find_parent_loop($element_spr, $element_if = 0)
+ {
+ $anketa = get('anketa');
+ $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$element_spr' AND element_if = '$element_if' AND ank_id='$anketa'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ if ($row['parent'] == 0) return 0;
+
+ $sql = sisplet_query("SELECT id FROM srv_if WHERE id = '$row[parent]' AND tip = '2'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ if (mysqli_num_rows($sql) > 0)
+ return $row['parent'];
+ else
+ return self::find_parent_loop(0, $row['parent']);
+
+ }
+
+ /**
+ * poisce naslednjo vre_id v loopu
+ *
+ */
+ public function findNextLoopId($if_id = 0)
+ {
+
+ if ($if_id == 0) {
+ $sql = sisplet_query("SELECT if_id FROM srv_loop_data WHERE id='" . get('loop_id') . "'");
+ $row = mysqli_fetch_array($sql);
+ $if_id = $row['if_id'];
+ $loop_id = get('loop_id');
+ }
+ else
+ $loop_id = 0;
+
+ $sql = sisplet_query("SELECT spr_id, max FROM srv_loop WHERE if_id = '$if_id'");
+ $row = mysqli_fetch_array($sql);
+ $spr_id = $row['spr_id'];
+ $max = $row['max'];
+
+ $spr = Cache::srv_spremenljivka($spr_id);
+
+ // Radio, checkbox, sn imena
+ if ($spr['tip'] == 2 || $spr['tip'] == 3 || $spr['tip'] == 9) {
+
+ $data_vrednost = array();
+ if ($spr['tip'] == 9)
+ $sql1 = sisplet_query("SELECT vre_id FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'");
+ else
+ $sql1 = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $data_vrednost[$row1['vre_id']] = 1;
+ }
+
+ $vre_id = '';
+ $i = 1;
+ $sql = sisplet_query("SELECT lv.vre_id, lv.tip FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if_id' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($row['tip'] == 0) { // izbran
+ if (isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 1) { // ni izbran
+ if (!isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 2) { // vedno
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ } // nikoli nimamo sploh v bazi, zato ni potrebno nic, ker se nikoli ne prikaze
+
+ if ($i > $max && $max > 0) break;
+ }
+
+ $vre_id = substr($vre_id, 2);
+ if ($vre_id == '')
+ return null;
+
+ $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_vrednost v WHERE l.if_id='$if_id' AND l.id > '$loop_id' AND l.vre_id IN ($vre_id) AND l.vre_id=v.id ORDER BY l.id ASC");
+
+
+ if (!$sql) {
+ echo 'err56545' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ $row = mysqli_fetch_array($sql);
+
+ if (mysqli_num_rows($sql) > 0)
+ return $row['id'];
+ else
+ return null;
+ }
+ // Number
+ elseif ($spr['tip'] == 7) {
+
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $num = (int)$row1['text'];
+ $sql2 = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id <= '$loop_id'");
+ if (mysqli_num_rows($sql2) >= $num || (mysqli_num_rows($sql2) >= $max && $max > 0))
+ return null;
+
+ $sql = sisplet_query("SELECT id FROM srv_loop_data WHERE if_id='$if_id' AND id > '$loop_id'");
+ $row = mysqli_fetch_array($sql);
+
+ if (mysqli_num_rows($sql) > 0)
+ return $row['id'];
+ else
+ return null;
+
+ }
+ // Ranking
+ elseif ($spr['tip'] == 17) {
+
+ $data_vrednost = array();
+ $sql1 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spr_id' AND usr_id='" . get('usr_id') . "' ORDER BY vrstni_red ASC");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $data_vrednost[$row1['vre_id']] = 1;
+ }
+
+ $vre_id = '';
+ $i = 1;
+ $sql = sisplet_query("SELECT lv.vre_id, lv.tip FROM srv_loop_vre lv, srv_vrednost v WHERE lv.if_id='$if_id' AND lv.vre_id=v.id ORDER BY v.vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($row['tip'] == 0) { // izbran
+ if (isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 1) { // ni izbran
+ if (!isset($data_vrednost[$row['vre_id']])) {
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ }
+ } elseif ($row['tip'] == 2) { // vedno
+ $vre_id .= ', ' . $row['vre_id'];
+ $i++;
+ } // nikoli nimamo sploh v bazi, zato ni potrebno nic, ker se nikoli ne prikaze
+
+ if ($i > $max && $max > 0) break;
+ }
+
+ $vre_id = substr($vre_id, 2);
+ if ($vre_id == '')
+ return null;
+
+
+ // Ce gre za prvi loop poiscemo ranking odgovor na prvem mestu
+ if($loop_id == 0){
+ $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_data_rating dr
+ WHERE l.if_id='$if_id' AND l.id > '$loop_id' AND l.vre_id IN ($vre_id)
+ AND l.vre_id=dr.vre_id AND dr.usr_id='".get('usr_id')."' AND dr.vrstni_red = '1'
+ ");
+ }
+ // Ce gre za kasnejsi loop poiscemo naslednji ranking odgovor
+ else{
+ $sql2 = sisplet_query("SELECT dr.vrstni_red FROM srv_loop_data l, srv_data_rating dr WHERE l.if_id='$if_id' AND l.id='$loop_id' AND dr.vre_id=l.vre_id AND dr.usr_id='".get('usr_id')."'");
+ if(mysqli_num_rows($sql2) > 0){
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sql = sisplet_query("SELECT l.id FROM srv_loop_data l, srv_vrednost v, srv_data_rating dr
+ WHERE l.if_id='$if_id' AND l.id != '$loop_id' AND l.vre_id IN ($vre_id)
+ AND l.vre_id=v.id
+ AND dr.vre_id=v.id AND dr.usr_id='".get('usr_id')."' AND dr.vrstni_red > '".$row2['vrstni_red']."'
+ ORDER BY dr.vrstni_red ASC
+ ");
+ }
+ else
+ return null;
+ }
+
+ if (!$sql) {
+ echo 'err56545' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ $row = mysqli_fetch_array($sql);
+
+
+ if (mysqli_num_rows($sql) > 0)
+ return $row['id'];
+ else
+ return null;
+ }
+ }
+
+ /**
+ * @desc poisce prejsnjo stran - grupo, 0 pomeni konec
+ */
+ public static function findPrevGrupa()
+ {
+ $anketa = get('anketa');
+ $grupa = get('grupa');
+
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '$grupa'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$anketa' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1");
+
+ // naslednja stran
+ if (mysqli_num_rows($sql) > 0) {
+
+ $row = mysqli_fetch_array($sql);
+ return $row['id'];
+
+ // konec
+ } else {
+
+ return 0;
+ }
+ }
+
+ /**
+ * @desc poisce naslednjo stran - grupo, 0 pomeni konec
+ */
+ public function findNextGrupa($gru_id=0)
+ {
+ //vrstni red trenutne grupe
+ if (get('grupa') > 0) {
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+ }
+ elseif ($gru_id > 0) {
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . $gru_id . "'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+ }
+ else {
+ $vrstni_red = 0;
+ }
+
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red>'$vrstni_red' ORDER BY vrstni_red ASC LIMIT 1");
+
+ // naslednja stran
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ return $row['id'];
+ }
+ // konec
+ else {
+ return 0;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/HeaderController.php b/main/survey/app/Controllers/HeaderController.php
new file mode 100644
index 0000000..1a7df13
--- /dev/null
+++ b/main/survey/app/Controllers/HeaderController.php
@@ -0,0 +1,920 @@
+<?php
+/***************************************
+ * Description: Odgovoreun za glavo, kjer poberemo tudi vse spremenljivke iz URL naslovov
+ * Autor: Robert Šmalc
+ * Created date: 28.01.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\HelperController as Helper;
+use App\Models\Model;
+use App\Controllers\FindController as Find;
+use Common;
+use SurveyAdvancedParadataLog;
+use SurveyInfo;
+use SurveyThemeEditor;
+use SurveyPanel;
+
+class HeaderController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new HeaderController();
+ }
+
+ /**
+ * nastavi default parametre, ki se prenasajo preko urlja
+ *
+ */
+ public static function getSurveyParams($encode = false, $force = null, $forcenot = null)
+ {
+
+ if (!is_array($force)) $force = array();
+ if (!is_array($forcenot)) $forcenot = array();
+ $g = '';
+
+ $paramslist = array(
+ 'language',
+ 'preview',
+ 'testdata',
+ 'mobile',
+ 'urejanje',
+ 'quick_view',
+ 'disableif',
+ 'disablealert',
+ 'disablecode',
+ 'displayifs',
+ 'displayvariables',
+ 'hidecomment',
+ 'popup',
+ 'no_preview',
+ 'theme_profile',
+ 'theme',
+ 'ai',
+ 'pages'
+ );
+
+ // add params that are not forced and not notforced
+ foreach ($paramslist AS $param) {
+ if (isset($_GET[$param]) && !array_key_exists($param, $force) && !in_array($param, $forcenot))
+ $g .= '&' . $param . '=' . $_GET[$param];
+ }
+
+ // add forced params
+ foreach ($force AS $key => $val) {
+ $g .= '&' . $key . '=' . $val;
+ }
+
+ if ($encode) $g = str_replace('&', '&amp;', $g);
+
+ return $g;
+
+ }
+
+ /************************************************
+ * Funcktja pridobi vse url parametre in jih ustrezno doda v globalne spremenljivke razreda SurveyClass
+ *
+ * @param $_GET
+ * @param $var - vse spremenljivke
+ * @return (obje ct) $get
+ ************************************************/
+ public function getAllUrlParameters()
+ {
+ // Vse GET parametre damo v objekt
+ if (!empty($_GET))
+ $get = (object)$_GET;
+
+ //V kolikor gre za enkripcijo potem najprej dekriptiramo - URLDECODE SE ZE AVTOMATSKO IZVEDE NA $_GET array-u
+ if (isset($get->enc)) {
+ //$request_decoded = base64_decode(urldecode($get->enc));
+ $request_decoded = base64_decode($get->enc);
+
+ $request_array = array();
+ parse_str($request_decoded, $request_array);
+
+ foreach ($request_array as $var => $value) {
+ $get->$var = $value;
+ }
+ }
+
+ //postavimo še ID ankete, ker ga bomo največkrat potrebovali
+ if (empty($get->anketa) && !is_int($get->anketa) && empty($_POST['anketa'])) {
+ return header('Location: ' . self::$site_url);
+ die("Missing anketa id!");
+ }
+ $anketa = (($get->anketa) ? $get->anketa : $_POST['anketa']);
+
+ // Shranimo vse spremenljivke iz get parametrov v classu VariableClass
+ save('anketa', $anketa);
+ save('get', $get);
+
+ return $get;
+ }
+
+
+ /************************************************
+ * Pridobimo vse parametre iz piškotka
+ *
+ * @param $_COOKIE
+ * @return (object) $cookie
+ ************************************************/
+ public function getAllCookieParameters()
+ {
+ $cookie = null;
+ // Vse GET parametre damo v objekt
+ if (!empty($_COOKIE))
+ $cookie = (object)$_COOKIE;
+
+ // Piškot shranimo v spremenljivke VariableClass
+ save('cookie', $cookie);
+
+ return $cookie;
+ }
+
+ /**
+ * @desc zgenereira header
+ */
+ public function header(){
+ global $app_settings;
+
+
+ // preprecimo caching - tudi s klikom na gumb nazaj!
+ header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT");
+ header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT");
+ header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
+ header("Cache-Control: post-check=0, pre-check=0", FALSE);
+ header("Pragma: no-cache"); // HTTP/1.0
+
+
+ echo '<head>' . "\n";
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqlv = sisplet_query("SELECT value FROM misc WHERE what='version'");
+ $rowv = mysqli_fetch_array($sqlv);
+
+ // Custom header title
+ if(isset($app_settings['head_title_custom']) && $app_settings['head_title_custom'] == 1){
+ echo '<title>'.strip_tags(Helper::getInstance()->displayAkronim(0)).' - '.$app_settings['head_title_text'].'</title>' . "\n";
+ }
+ // Default header title
+ else{
+ echo '<title>'.strip_tags(Helper::getInstance()->displayAkronim(0)).' - '.self::$lang['1ka_surveys'].'</title>' . "\n";
+ }
+
+ echo ' <meta charset="utf-8">' . "\n";
+
+ // Preprecimo vklop compatibility moda v IE
+ echo ' <meta http-equiv="X-UA-Compatible" content="IE=edge" />' . "\n";
+
+ // nova verzija UI 1.8.10 - includamo minificirano skupaj z script.js (uporabimo iste jQuery fajle kot v adminu)
+ echo ' <script src="' . self::$site_url . 'admin/survey/minify/g=jsfrontend?v=' . $rowv['value'] . '"></script>' . "\n";
+ echo '<script src="https://www.google.com/recaptcha/api.js" async defer></script>' . "\n";
+
+ // tukaj nalozimo CSS za jquery in template temo
+ echo ' <link href="' . self::$site_url . 'admin/survey/minify/g=cssfrontend?v=' . $rowv['value'] . '" rel="stylesheet">' . "\n";
+
+ //nalozimo stringe iz langa za JS
+ echo '<script type="text/javascript" src="' . self::$site_url . 'admin/survey/script/js-lang.php?lang=' . ($row['lang_admin'] == 1 ? 'si' : 'en') . '&amp;v=' . $rowv['value'] . '"></script>' . "\n";
+
+ // nalozimo open sans fonte za nov design
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700&subset=latin,latin-ext" rel="stylesheet" />';
+ /*echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700&subset=latin,latin-ext" rel="stylesheet">';*/
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,500,500i,600,600i,700,700i&amp;subset=latin-ext" rel="stylesheet" />';
+
+
+ // CSS mobile skin za telefone in tablice
+ if (get('mobile') == 1) {
+
+ echo ' <meta content="width=device-width; initial-scale=1.0;" name="viewport">' . "\n";
+
+ // za MJU anketo nalozimo posebej custom skin
+ if(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){
+ $this->loadCustomMadeSkin($custom_skin='MJU');
+ }
+ // CSS samo za mobilne telefone
+ else{
+ $this->themeEditorMobileCustom();
+ }
+ }
+ // CSS za tablice je po defaultu enak kot za pc
+ elseif(get('mobile') == 2){
+
+ echo ' <meta content="width=device-width" name="viewport">' . "\n";
+
+ // za MJU anketo nalozimo posebej custom skin
+ if(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){
+ $this->loadCustomMadeSkin($custom_skin='MJU');
+ }
+ // profili tem - skinov
+ else{
+ $this->themeEditor();
+ }
+ }
+ // CSS za pc
+ else{
+
+ // Custom skin za Bled
+ if($row['skin'] == 'Bled'){
+ $this->loadCustomMadeSkin($custom_skin='Bled');
+ }
+ // za MJU anketo nalozimo posebej custom skin
+ elseif(SurveyInfo::getInstance()->checkSurveyModule('mju_theme') == '1'){
+ $this->loadCustomMadeSkin($custom_skin='MJU');
+ }
+ // profili tem - skinov
+ else{
+ $this->themeEditor();
+ }
+ }
+
+
+ // še css za printer
+ // tole je ze out-of-date, po moje je zaenkrat boljs brez posebnega print skina
+ //echo ' <link rel="stylesheet" href="'.self::$site_url.'main/survey/skins/printer.css" media="print">'."\n";
+
+ // Skin za glasovanje
+ $sqlG = sisplet_query("SELECT skin FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'");
+ $rowG = mysqli_fetch_array($sqlG);
+ if (mysqli_num_rows($sqlG) > 0)
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/glasovanje/' . $rowG['skin'] . '.css" media="screen">' . "\n";
+
+ // CSS za modul kviz
+ if (SurveyInfo::getInstance()->checkSurveyModule('quiz')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/quiz/quiz.css" media="screen">' . "\n";
+ }
+
+ // CSS za modul SAZU anketo
+ if (SurveyInfo::getInstance()->checkSurveyModule('sazu')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'admin/survey/modules/mod_SAZU/css/style_sazu.css" media="screen">' . "\n";
+ }
+
+ // CSS za rtl text - glede na lang datoteko (zaenkrat samo arabscina)
+ if (in_array(self::$lang['id'], array('39', '43'))) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'public/css/main_rtl.css" media="screen">' . "\n";
+ }
+
+ // JavaScript za napredne parapodatke
+ if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+
+ // Ce ne postamo oz. ce smo na zadnji strani vkljucimo js kodo
+ if(count($_POST) == 0 || Find::getInstance()->findNextGrupa($_GET['grupa']) == 0){
+ SurveyAdvancedParadataLog::getInstance()->prepareLogging();
+ SurveyAdvancedParadataLog::getInstance()->linkJavaScript();
+ }
+ }
+
+ echo '</head>' . "\n";
+
+
+ // Ce imamo vklopljen evoli na instalaciji, potem onemogocimo kopiranje
+ $evoli_copy_disable = '';
+ if (Common::checkModule('evoli') == '1' || Common::checkModule('evoli_employmeter') == '1')
+ $evoli_copy_disable = 'oncopy="return false;" oncut="return false;" oncontextmenu="return false;"';
+
+ $preview = '';
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on')
+ $preview = ' class="preview"';
+ elseif (isset($_GET['testdata']) && $_GET['testdata'] == 'on')
+ $preview = ' class="preview"';
+ echo '<body ' . $preview . ' ' . $evoli_copy_disable . '>' . "\n";
+
+ // Zamenjamo class no_js z js -> test javacsripta za userje (javascript_warning)
+ echo "<script>" . "\n";
+ $tooltips_maxwitdh = "maxWidth: '880'";
+ if ($row['skin'] == 'Embed2')
+ $tooltips_maxwitdh = "maxWidth: '340'";
+ if ($row['skin'] == 'Otroci3' || $row['skin'] == 'Otroci4')
+ $tooltips_maxwitdh = "maxWidth: '680'";
+
+ echo "$(document).ready(function(){
+ $('html').removeClass('no_js').addClass('js');
+ $('.tooltip.mouseover').tooltipster({
+ theme: 'tooltipster-shadow',";
+ echo $tooltips_maxwitdh;
+ echo "
+ });
+ $('.tooltip.mouseclick').tooltipster({
+ theme: 'tooltipster-shadow',
+ trigger: 'click',";
+ echo $tooltips_maxwitdh;
+ echo " });";
+
+ // Tega ne rabimo vec, ker urejamo okvir slik direktno s css-jem (na parenta (.variabla) damo class checked)
+ //echo "$('div.variabla input:checkbox, div.variabla input:radio').on('change', function() { activateCehckboxImages($(this)); });"."\n";
+
+ # če smo v quick_view disejblamo vse elemente frme
+ if (get('quick_view') == true) {
+ echo "$('input:[type=radio], input:[type=checkbox], input:[type=text], select, textarea').attr('disabled',true);" . "\n";
+ }
+ echo " })" . "\n";
+ echo "</script>";
+
+ if ($row['user_from_cms'] == 2 && $row['user_from_cms_email'] == 1) { // vnos
+
+ $sql1 = sisplet_query("SELECT user_id FROM srv_user WHERE id = '" . get('usr_id') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sqlu = Model::db_select_user($row1['user_id']);
+ $rowu = mysqli_fetch_array($sqlu);
+
+ if (mysqli_num_rows($sqlu) > 0) {
+ echo '<div id="vnos">';
+ echo self::$lang['srv_recognized'] . ' <strong>' . $rowu['name'] . ' ' . $rowu['surname'] . '</strong><br>(' . $rowu['email'] . ')';
+ echo '</div>' . "\n";
+ }
+
+ }
+ }
+
+ /**
+ * @desc prikaze sistemske spremenljivke
+ */
+ public function displaySistemske()
+ {
+ $sql = sisplet_query("SELECT id, recnum FROM srv_user WHERE id='" . get('usr_id') . "'");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ $row = mysqli_fetch_array($sql);
+
+ echo ' <input type="hidden" id="javascript" name="javascript" value="0">';
+ echo ' <input type="hidden" id="srv_meta_anketa_id" name="srv_meta_anketa_id" value="' . get('anketa') . '">';
+
+ // Ce imamo vklopljen modul panel sproti belezimo tudi panel_status
+ if(SurveyInfo::checkSurveyModule('panel') == 1){
+
+ // Ce gre za prvo nastavimo na default vrednost, drugace beremo iz post-a
+ $sp = new SurveyPanel(get('anketa'));
+ $panel_status = (isset($_COOKIE['panel_status']) && $_COOKIE['panel_status'] != '') ? $_COOKIE['panel_status'] : $sp->getPanelSettings('status_default');
+
+ echo ' <input type="hidden" id="panel_status" name="panel_status" value="'.$panel_status.'">';
+ }
+
+ // Spremenljivke, ki se rabijo v JS
+ echo ' <script> ' . "\n";
+
+ echo ' var _recnum = \'' . $row['recnum'] . '\'; ' . "\n";
+ echo ' var _usr_id = \'' . $row['id'] . '\'; ' . "\n";
+ echo ' var srv_meta_anketa_id = ' . get('anketa') . '; ' . "\n";
+ echo ' var srv_site_url = \'' . self::$site_url . '\'; ' . "\n";
+ echo ' var _lang = \'' . self::$lang['language'] . '\'; ' . "\n";
+
+ echo ' var is_paused_slideshow = false; ' . "\n";
+ echo ' document.getElementById(\'javascript\').value = 1; ' . "\n";
+
+ echo ' </script> ' . "\n";
+
+ // Spremenljivke, ki se rabijo v JS za drag/drop
+ echo '
+ <script>
+ var draggableOnDroppable = []; // spremenljivka, ki belezi prisotnost odgovora na ustrezni povrsini pri Drag and Drop
+ var maxDragDrop = []; // spremenljivka, ki belezi max stevilo moznih odgovorov
+
+ var draggableOverDroppable = []; // spremenljivka, ki belezi prisotnost odgovora nad ustreznim okvirjem pri Drag and Drop
+ var default_var_height_1 = []; // belezi zacetno vrednost visine celotnega vprasanja po usklajevanju visine glede na prisotne kategorije odgovorov
+ var data_after_refresh = []; // belezi, ali je uporabnik refresh-al stran oz. se vraca na stran
+ var frame_total_height_right = []; // belezi visino okvirjev desnega bloka @ drag and drop grids
+ var draggableOver = [];
+ var last_vre_id = []; // belezi vre_id zadnjega draggable, ki smo ga premikali @ Drag and drop
+ var vre_id_global = []; // belezi vre_id trenutne kategorije odgovorov @ Drag and drop
+ var last_indeks = []; // belezi indeks zadnjega okvirja, kjer je bil draggable @ Drag and drop
+ var indeks_global = []; // belezi trenutni indeks okvirja @ Drag and drop
+ var last_drop = []; // belezi indeks zadnjega okvirja, kjer je bil draggable droppan @ Drag and drop
+ var num_grids_global = []; // belezi stevilo gridov za doloceno vprasanje
+ var draggable_global = [];
+ var cat_pushed = []; // belezi, ali je kategorijo odrinila druga kategorija odgovora @ Drag and drop
+ </script>
+ ';
+ }
+
+ public function themeEditor($themePreview = false){
+
+ if (isset($_GET['theme'])) $themePreview = true; // to ne bo vec
+ if (isset($_GET['theme-preview']) && $_GET['theme-preview'] == '1') $themePreview = true; // to je pri urejanju CSSa da se refresha mimo cachea
+
+ $row = SurveyInfo::getSurveyRow();
+
+ if (isset($_GET['theme_profile'])) {
+ $row['skin_profile'] = (int)$_GET['theme_profile'];
+ }
+ if (isset($_GET['theme'])) {//to ne bo vec
+ $row['skin'] = str_replace('.css', '', $_GET['theme']);
+ $row['skin_profile'] = 0;
+ }
+
+ // ni nastavljenih profilov, nastavimo navadno temo
+ if ($row['skin_profile'] == 0) {
+
+ // Ce ne gre za obstojeco anketo nastavimo default skin
+ if($row['skin'] == '')
+ $row['skin'] = '1kaBlue';
+
+ // moznost zip skinov
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $row['skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $row['skin'] . '/' . $row['skin'] . '.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ } else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $row['skin'] . '.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ }
+ // nastavljen je profil, nastavimo temo in potem še lastne nastavitve
+ else {
+
+ $sqla = sisplet_query("SELECT skin, logo FROM srv_theme_profiles WHERE id = '$row[skin_profile]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ // moznost zip skinov
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $rowa['skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $rowa['skin'] . '/' . $rowa['skin'] . '.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ } else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $rowa['skin'] . '.css' . ($themePreview || true ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+
+ $sqlt = sisplet_query("SELECT * FROM srv_theme_editor WHERE profile_id = '" . $row['skin_profile'] . "'");
+ if (mysqli_num_rows($sqlt) > 0) {
+
+ echo '<style>';
+
+ while ($rowt = mysqli_fetch_array($sqlt)) {
+
+ switch ($rowt['id']) {
+
+ case '1':
+ echo 'h1';
+ break;
+
+ case '2':
+ echo '.spremenljivka';
+ break;
+
+ case '3':
+ echo '.variable_holder';
+ break;
+
+ case '4':
+ echo 'table.grid_table tbody tr:nth-child(2n+1)';
+ break;
+
+ case '5':
+ echo 'div.spremenljivka';
+ break;
+
+ case '7':
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio,
+ input[type="radio"]+span.enka-checkbox-radio,
+ .custom_radio_picture.obarvan > label > span.enka-custom-radio:before
+ ';
+ break;
+
+ case '6':
+ echo '#container';
+ break;
+
+ case '8':
+ echo '.tooltipster-shadow';
+ break;
+
+ case '9':
+ echo 'abbr.tooltip';
+ break;
+ }
+
+ echo ' {';
+
+ switch ($rowt['type']) {
+
+ case '1':
+ if ($rowt['value'] > 0)
+ echo 'font-family: ' . SurveyThemeEditor::getFont($rowt['value']) . ';';
+ break;
+
+ case '2':
+ case '9':
+ case '15':
+ echo 'color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '3':
+ echo 'background: ' . $rowt['value'] . ';';
+ break;
+
+ case '4':
+ echo 'font-size: ' . $rowt['value'] . '%;';
+ break;
+
+ case '5':
+ if ($rowt['value'] == '0') {
+ echo 'border: 0;';
+ } elseif ($rowt['value'] == '2') {
+ echo 'border: 1px #B9C5D9 solid;';
+ } else {
+ echo 'border: 0;';
+ echo 'border-top: 1px #B9C5D9 solid;';
+ }
+ break;
+
+ case '7':
+ if ($rowt['value'] != '0')
+ echo 'font-size: ' . $rowt['value'] . 'px;';
+ break;
+
+ case '10':
+ echo 'border-color: ' . $rowt['value'] . ';';
+ break;
+
+ case '11':
+ echo 'border-width: ' . $rowt['value'] . 'px;';
+ break;
+
+ case '12':
+ echo 'border-radius: ' . $rowt['value'] . 'px;';
+ break;
+
+ case '13':
+ echo 'background-color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '14':
+ if ($rowt['value'] == 'bold')
+ echo 'font-weight: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'italic')
+ echo 'font-style: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'underline')
+ echo 'text-decoration: ' . $rowt['value'] . ' !important;';
+ break;
+
+
+ }
+
+ echo '}';
+
+ // Accessibility
+ if($rowt['type'] == '17' && $rowt['id'] == '10'){
+ if($rowt['value'] == '1'){
+
+ // Skrijemo barvne ikone
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio, input[type="radio"]+span.enka-checkbox-radio{
+ display: none !important;
+ }';
+
+ // Prikazemo navadne ikone
+ echo 'input[type="checkbox"], input[type="radio"] {
+ display: inline-block !important;
+ }';
+ }
+ }
+ }
+
+ echo '</style>';
+ }
+
+ // Izrisemo css za custom logo
+ if ($rowa['logo'] != '') {
+ $this->customLogoCSS($rowa['logo']);
+ }
+ }
+
+ // Za office in nature skina imamo random background
+ if($row['skin'] == '1kaOffice' || $row['skin'] == '1kaNature'){
+ $bg_number = rand(1,15);
+ echo '<style> html{ background-image: url(' . self::$site_url . 'main/survey/skins/'.$row['skin'].'/bg'.$bg_number.'.jpg); } </style>';
+ }
+ }
+
+ public function themeEditorMobileCustom(){
+
+ $row = SurveyInfo::getSurveyRow();
+
+ // Najprej nalozimo mobile template skin
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'public/css/main_mobile.css" media="all">' . "\n";
+
+
+ if (isset($_GET['theme_profile'])) {
+ $row['skin_profile_mobile'] = (int)$_GET['theme_profile'];
+ }
+ if (isset($_GET['theme'])) {
+ $themePreview = true;
+ $row['mobile_skin'] = str_replace('.css', '', $_GET['theme']);
+ }
+
+
+ // Fonti za mobilne skine (vse razen prvega default)
+ if($row['mobile_skin'] != 'Mobile')
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=Bree+Serif&subset=latin,latin-ext" rel="stylesheet" />';
+
+
+ // ni nastavljenih profilov, nastavimo navadno temo
+ if ($row['skin_profile_mobile'] == 0) {
+
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $row['mobile_skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/MobileBlue.css'.($themePreview ? '?foo=' . mt_rand() : '').'" media="all">' . "\n";
+ }
+ else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $row['mobile_skin'] . '.css'.($themePreview ? '?foo='. mt_rand() : '').'" media="all">' . "\n";
+ }
+ }
+ // nastavljen je profil, nastavimo temo in potem še lastne nastavitve
+ else {
+
+ $sqla = sisplet_query("SELECT skin FROM srv_theme_profiles_mobile WHERE id = '$row[skin_profile_mobile]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ if (!is_file(self::$site_path . 'main/survey/skins/' . $rowa['skin'] . '.css')) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/MobileBlue.css'.($themePreview ? '?foo=' . mt_rand() : '').'" media="all">' . "\n";
+ } else {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/' . $rowa['skin'] . '.css'.($themePreview || true ? '?foo='. mt_rand() : '').'" media="all">' . "\n";
+ }
+
+ $sqlt = sisplet_query("SELECT * FROM srv_theme_editor_mobile WHERE profile_id = '" . $row['skin_profile_mobile'] . "'");
+ if (mysqli_num_rows($sqlt) > 0) {
+
+ echo '<style>';
+
+ while ($rowt = mysqli_fetch_array($sqlt)) {
+
+ switch ($rowt['id']) {
+
+ case '1':
+ echo 'h1';
+ break;
+
+ case '2':
+ echo '.spremenljivka .naslov';
+ break;
+
+ case '3':
+ echo '.variable_holder, .variable_holder .variabla label';
+ break;
+
+ case '4':
+ echo 'table.grid_table tbody tr:nth-child(2n+1)';
+ break;
+
+ case '5':
+ echo '.spremenljivka';
+ break;
+
+ case '7':
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio,
+ input[type="radio"]+span.enka-checkbox-radio';
+ break;
+
+ case '6':
+ echo '#container h1, #footer_survey';
+ break;
+
+ case '8':
+ echo '.tooltipster-shadow';
+ break;
+
+ case '9':
+ echo 'abbr.tooltip';
+ break;
+ }
+
+ echo ' {';
+
+ switch ($rowt['type']) {
+
+ case '1':
+ if ($rowt['value'] > 0)
+ echo 'font-family: ' . SurveyThemeEditor::getFont($rowt['value']) . ' !important;';
+ break;
+
+ case '2':
+ case '9':
+ echo 'color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '3':
+ echo 'background: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '4':
+ echo 'font-size: ' . $rowt['value'] . '% !important;';
+ break;
+
+ case '5':
+ if ($rowt['value'] == '0') {
+ echo 'border: 0;';
+ } elseif ($rowt['value'] == '2') {
+ echo 'border: 1px #B9C5D9 solid;';
+ } else {
+ echo 'border: 0;';
+ echo 'border-top: 1px #B9C5D9 solid;';
+ }
+ break;
+
+ case '8':
+ if ($rowt['value'] != '0')
+ echo 'font-size: ' . $rowt['value'] . 'px !important;';
+ break;
+
+ case '10':
+ echo 'border-color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '11':
+ echo 'border-width: ' . $rowt['value'] . 'px !important;';
+ break;
+
+ case '12':
+ echo 'border-radius: ' . $rowt['value'] . 'px !important;';
+ break;
+
+ case '13':
+ echo 'background-color: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '14':
+ if ($rowt['value'] == 'bold')
+ echo 'font-weight: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'italic')
+ echo 'font-style: ' . $rowt['value'] . ' !important;';
+ if ($rowt['value'] == 'underline')
+ echo 'text-decoration: ' . $rowt['value'] . ' !important;';
+ break;
+
+ case '16':
+ echo 'color: ' . $rowt['value'] . ' !important;';
+ break;
+ }
+
+ echo '}';
+
+ // Accessibility
+ if($rowt['type'] == '17' && $rowt['id'] == '10'){
+ if($rowt['value'] == '1'){
+
+ // Skrijemo barvne ikone
+ echo 'input[type="checkbox"]+span.enka-checkbox-radio, input[type="radio"]+span.enka-checkbox-radio{
+ display: none !important;
+ }';
+
+ // Prikazemo navadne ikone
+ echo 'input[type="checkbox"], input[type="radio"] {
+ display: inline-block !important;
+ }';
+ }
+ }
+ }
+
+ echo '</style>';
+ }
+ }
+
+ // Izrisemo css za custom logo
+ $sqla = sisplet_query("SELECT logo FROM srv_theme_profiles WHERE id = '$row[skin_profile]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ if ($rowa['logo'] != '') {
+ $this->customLogoCSS($rowa['logo']);
+ }
+ }
+
+
+ // Funkcija ki nalozi custom temo narejeno po narocilu
+ private function loadCustomMadeSkin($custom_skin){
+
+ if (isset($_GET['theme'])) $themePreview = true; // to ne bo vec
+ if (isset($_GET['theme-preview']) && $_GET['theme-preview'] == '1') $themePreview = true; // to je pri urejanju CSSa da se refresha mimo cachea
+
+
+ // Custom narejen skin za Bled
+ if($custom_skin == 'Bled'){
+
+ // Font PT sans
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,700&subset=latin,latin-ext" rel="stylesheet">';
+
+ // Imamo različne backgrounde
+ $bg_number = rand(1,9);
+ echo '<style>
+ html{
+ background-image: url(' . self::$site_url . 'main/survey/skins/___po_narocilu/Bled/bg'.$bg_number.'.jpg);
+ }
+ </style>';
+
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/Bled.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+
+ // Premaknemo footer na dno
+ echo '<script>
+ footerBled();
+
+ function footerBled(){
+ var footerResize = function() {
+ if($("#outercontainer").height() <= $(window).height()-80){
+ $(\'#footer_survey\').css(\'position\', "absolute");
+ $(\'#footer_survey\').css(\'bottom\', "0px");
+ }
+ else{
+ $(\'#footer_survey\').css(\'position\', "auto");
+ $(\'#footer_survey\').css(\'bottom\', "auto");
+ }
+ };
+ $(window).resize(footerResize).ready(footerResize);
+ }
+ </script>';
+ }
+ // Custom skin za MJU anketo
+ elseif($custom_skin == 'MJU'){
+
+ // Font PT sans
+ echo '<link type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,700&subset=latin,latin-ext" rel="stylesheet">';
+
+ // mobitel
+ if (get('mobile') == 1) {
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/MJU_mobile.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ // tablica
+ elseif(get('mobile') == 2){
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/MJU_tablet.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ // navaden racunalnik
+ else{
+ echo ' <link rel="stylesheet" href="' . self::$site_url . 'main/survey/skins/___po_narocilu/MJU.css' . ($themePreview ? '?foo=' . mt_rand() : '') . '">' . "\n";
+ }
+ }
+ }
+
+
+ // Insertamo css za custom logo
+ private function customLogoCSS($logo){
+
+ // Najprej dobimo velikost originalne slike
+ $image_orig = self::$site_url . 'main/survey/uploads/' . $logo;
+ if (file_exists(survey_path('uploads/' . $logo))) {
+
+ $size_orig = @getimagesize($image_orig);
+
+ $css_bg_image = $image_orig;
+ $css_width = '';
+ $css_height = '';
+ $css_bg_size = 'contain !important';
+
+ // Ce gre za Gorenje prikazemo drug logo
+ if(Common::checkModule('gorenje')){
+ $css_bg_size = 'auto 50px !important';
+ }
+ // Ce slucajno ne moremo dobiti siza
+ elseif(!$size_orig){
+ $css_height = '100px';
+ $css_width = '250px';
+ }
+ // Ce je original visji kot 160 ga avtomatsko pomanjsamo
+ elseif($size_orig[1] > 160) {
+
+ $image = self::$site_url . 'function/thumb.php?src=' . self::$site_url . 'main/survey/uploads/' . $logo . '&h=100';
+ $size = @getimagesize($image);
+
+ if($size){
+ $css_bg_image = $image;
+ $css_width = $size[0].'px';
+ $css_height = '100px';
+ }
+ }
+ // Drugace pustimo default size logotipa
+ else{
+ $css_width = $size_orig[0].'px';
+ $css_height = $size_orig[1].'px';
+ }
+
+
+ // CSS za custom logo
+ echo '<style type="text/css">';
+
+ echo '#logo, #logo.english, #footer_survey #logo, #footer_survey #logo.english {';
+
+ echo ' background-image: url('.$css_bg_image.'); ';
+
+ if($css_width != '')
+ echo ' width: '.$css_width.'; ';
+
+ if($css_height != '')
+ echo ' height: '.$css_height.'; ';
+
+ if($css_bg_size != '')
+ echo ' background-size: '.$css_bg_size.'; ';
+
+ echo '}';
+
+ echo '#footer_survey #logo { max-height: 70px; max-width: 200px; }';
+
+ echo '#logo a, #footer_survey #logo a { display: none; }';
+
+ echo '</style>';
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/HelperController.php b/main/survey/app/Controllers/HelperController.php
new file mode 100644
index 0000000..58e6784
--- /dev/null
+++ b/main/survey/app/Controllers/HelperController.php
@@ -0,0 +1,747 @@
+<?php
+/***************************************
+ * Description: Notri so zbrane funkcije, ki jih večkrat lahko uporabimo v vseh razredih
+ * Autor: Robert Šmalc
+ * Created date: 29.01.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\HelperController as Helper;
+use App\Models\Model;
+use Cache;
+use Common;
+use enkaParameters;
+use Hierarhija\HierarhijaHelper;
+use MailAdapter;
+use SurveyInfo;
+use SurveySetting;
+use SurveyUnsubscribe;
+use UserAccess;
+
+class HelperController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ parent::getAllVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new HelperController();
+ }
+
+ /************************************************
+ * Detekcija za katere vrste naprave gre (mobilnik, tablica ali računalnik)
+ * 0 - računalnik oz. normalni pogled
+ * 1 - mobilnik
+ * 2 - tablica
+ * @param $_SERVER ['HTTP_USER_AGENT'];
+ * @return string
+ ************************************************/
+ public static function mobile()
+ {
+ $detect = New \Mobile_Detect();
+ $mobile = 0; // 0 - klasicna, 1 - mobilna, 2 - dlancniki
+ $ismobile = 0;
+
+ // detektiramo, ce gre za mobilni aparat
+ if ($detect->isMobile())
+ $ismobile = 1;
+
+ if ($ismobile == 1) {
+ if ($detect->isTablet())
+ $mobile = 2;
+ else
+ $mobile = 1;
+ }
+
+ // prednost pa ima rocno izbrana opcija - ce je nastavljena
+ if (isset($_COOKIE['mobile'])) {
+ $c = (int)$_COOKIE['mobile'];
+ if ($c > 0)
+ $mobile = $mobile;
+ else
+ $mobile = 0;
+ }
+
+ // Ce smo slucajno v preview-ju preverimo kateri preview prikazemo
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on') {
+ if (isset($_GET['mobile']) && $_GET['mobile'] == 1)
+ $mobile = 1;
+ elseif (isset($_GET['mobile']) && $_GET['mobile'] == 2)
+ $mobile = 2;
+ };
+
+ return $mobile;
+ }
+
+ /**
+ * @desc V podanem stringu poisce spremenljivke in jih spajpa z vrednostmi
+ */
+ public static function dataPiping($text)
+ {
+ // V kolikor imamo vključen modul hierarhija potem uporabimo ustrezno pajpanje za hierarhijo
+ if (SurveyInfo::getInstance()->checkSurveyModule('hierarhija'))
+ return HierarhijaHelper::dataPiping($text, get('anketa'));
+
+
+ Common::getInstance()->Init(get('anketa'));
+
+ return Common::getInstance()->dataPiping($text, get('usr_id'), get('loop_id'), get('lang_id'));
+
+ }
+
+ /**
+ * vrne IP naslov (tudi ce gre preko proxyja)
+ *
+ */
+ public static function remote_address()
+ {
+ return GetIP();
+ }
+
+ /************************************************
+ * Vrnemo ime ankete
+ *
+ * @param $show_page = 1 - ali prikažemo omenjen naslov na spletni strani
+ * @return string
+ ************************************************/
+ public function displayAkronim($show_page = 1)
+ {
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ $srv_novaanketa_kratkoime = null;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $survey_hide_title = SurveySetting::getInstance()->getSurveyMiscSetting('survey_hide_title');
+
+ if ($survey_hide_title == 1 /*&& $row['survey_type'] != 0*/)
+ return;
+
+ if (get('lang_id') != null) {
+ if (get('lang_id') != null)
+ $_lang = '_' . get('lang_id');
+ else
+ $_lang = '';
+
+ $srv_novaanketa_kratkoime = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_novaanketa_kratkoime' . $_lang);
+ }
+
+ if ($show_page == 1 && get('grupa') > 0) {
+ $sql1 = sisplet_query("SELECT naslov FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ $grupa = '<span> - ' . $row1['naslov'] . '</span>';
+ } else $grupa = '';
+
+ if ($srv_novaanketa_kratkoime != '')
+ return $srv_novaanketa_kratkoime . $grupa;
+ else
+ return (($row['akronim'] == null || $row['akronim'] == '') ? $row['naslov'] . $grupa : $row['akronim'] . $grupa);
+ }
+
+ /**
+ * @desc vrne array vseh spremenljivk vgnezdenih v podanem ifu
+ */
+ public static function getElements($if)
+ {
+ $elements = get('getElements');
+ $anketa = get('anketa');
+
+ if (array_key_exists($if, $elements)) {
+ return $elements[$if];
+ }
+
+ $array = array();
+
+ Cache::cache_all_srv_branching($anketa);
+
+ foreach (Cache::srv_branching_parent($anketa, $if) AS $k => $row) {
+
+ if ($row['element_spr'] > 0)
+ array_push($array, $row['element_spr']);
+ else
+ foreach (self::getElements($row['element_if']) AS $key)
+ array_push($array, $key);
+
+ }
+
+ return save('getElements[' . $if . ']', $array, 1);
+ }
+
+ /**
+ * @desc vrne ce obstaja parent z nastavitvijo horizontal pri blokih da prikazemo vprasanja vodoravno (horizontal==1) ali z razpiranjem (horizontal==2) ce je vklopljena nastavitev
+ */
+ public static function checkParentHorizontal($element){
+
+ Cache::cache_all_srv_branching(get('anketa'));
+
+ $parent = $element['parent'];
+
+ $rowb = Cache::srv_if($element['element_if']);
+ if ($rowb['horizontal'] == 1 || $rowb['horizontal'] == 2) {
+ return $rowb['horizontal'];
+ }
+ elseif ($parent == 0) {
+ return false;
+ }
+ elseif ($parent == 0) {
+ return false;
+ }
+ else {
+ $row = Cache::srv_branching(0, $parent);
+ return self::checkParentHorizontal($row);
+ }
+ }
+
+ public static function getGrupa($spremenljivka)
+ {
+ $grupa = get('getGrupa');
+
+ if (array_key_exists($spremenljivka, $grupa))
+ return $grupa[$spremenljivka];
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ return save('getGrupa[' . $spremenljivka . ']', $row['gru_id'], 1);
+ }
+
+ public static function getDatepickerRange($spremenljivka, $date_element)
+ {
+ # po potrebi pripravimo datum range
+ $row = Cache::srv_spremenljivka($spremenljivka);
+ $newParams = new enkaParameters($row['params']);
+ $min = $newParams->get('date_range_min');
+ $max = $newParams->get('date_range_max');
+ $range_string = null;
+
+ # ce imamo spodnji range
+ $range = ($min != "") ? $min : '-80';
+
+ $range .= ':';
+
+ # ce imamo zgornji range - plus je potrebno dodat posebej
+ if ($max == "")
+ $range .= '+10';
+ else if ($max < 100)
+ $range .= '+' . $max;
+ else
+ $range .= $max;
+
+ # ce imamo nastavljen spodnji ali zgornji range
+ $range_string = "$( \"{$date_element}\" ).datepicker( \"option\", \"yearRange\", \"{$range}\" );";
+
+ // Ce ni danasnji dan v rangu -> moramo posebej nastavit trenutni datum (zaradi jquery buga)
+ if (substr($max, 0, 1) == '-' || substr($min, 0, 1) == '+') {
+ $date = '1.1.' . ((int)date("Y") + (int)$min);
+ $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"defaultDate\", \"{$date}\" );";
+ } elseif ($min > date("Y") || $max < date("Y")) {
+ $date = '1.1.' . $min;
+ $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"defaultDate\", \"{$date}\" );";
+ }
+
+ // dodamo se, da je prvi dan v tednu ponedeljek
+ $range_string .= "$( \"{$date_element}\" ).datepicker( \"option\", \"firstDay\", 1 );";
+
+ # nastavimo datumski range
+ echo $range_string;
+ }
+
+ public static function getCustomCheckbox()
+ {
+
+ //ID skin_profile
+ $skin_id = SurveyInfo::getInstance()->getSurveyRow()['skin_profile'];
+
+ //srv_theme_editor -> velikost PC/mobilne ikone
+ $type = 7;
+
+ if (get('mobile') > 0)
+ $type = 8; //če gre za mobilnik ali tablico potem pridobimo ustrezne ikone za tole
+
+ $sql = sisplet_query("SELECT value FROM srv_theme_editor WHERE profile_id = '$skin_id' AND id='7' AND type='$type'");
+ $row = mysqli_fetch_array($sql);
+ if (!$row || empty($row) || is_null($row))
+ return 0;
+
+ return $row['value']; //vrnemo velikost custom radio/checkboxa
+ }
+
+ /**
+ * @desc poslje alerte o izpolnjeni anketi
+ */
+ public function alert()
+ {
+ global $site_path;
+
+ # kadar popravljamo obstoječe podatke ne pošiljamo več obvestil o končani anketi (Ajda)
+ if ($_GET['urejanje'] == 1) {
+ return;
+ }
+
+ // Ce smo v predogledu ali testiranju ne posiljamo obvestila
+ if ($_GET['preview'] == 'on') {
+ return;
+ }
+
+ // Preverimo ce imamo ustrezen paket kjer je na voljo obvescanje
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ if (!$userAccess->checkUserAccess($what='alert')){
+ return;
+ }
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'");
+ $rowAlert = mysqli_fetch_array($sqlAlert);
+
+ // array z emaili
+ $emails = array();
+ # TODO
+ # dodat tabelo, z emaili, za userje cms-ja če bi se želeli odjavit od obveščanja posamezne ankete
+ # ker sedaj nimamo povezave na njihov eemaile in se ne morejo odjaviti
+ # not bi blo fajn dat: anketa_id, email, code (kodo za preverjanje istovetnosti)
+ # in potem če klikne na link odjaviti in skopirati v tabelo: srv_survey_unsubscribe, da se uporabniku ne pošilja več
+
+ $ime = '';
+
+ // alert Avtorja in ostalih v dostopu
+ if ($rowAlert['finish_author'] == 1) {
+ $sqlInsertUID = Model::db_select_user($row['insert_uid']);
+ $rowInsertUID = mysqli_fetch_array($sqlInsertUID);
+
+
+ // polovimo se avtorje katerim je omogocen dostop in imajo nastavljeno da dobivajo obvestila - po novem med njimi ni nujno glavni avtor ankete
+ $sqlAlertAuthors = sisplet_query("SELECT u.email, u.id FROM users as u "
+ . " RIGHT JOIN (SELECT sd.uid, sd.alert_complete FROM srv_dostop as sd WHERE sd.ank_id='" . get('anketa') . "' AND sd.alert_complete = '1') AS dostop ON u.id = dostop.uid");
+ while ($rowAlertAuthors = mysqli_fetch_assoc($sqlAlertAuthors)) {
+
+ $sql1 = sisplet_query("SELECT alert_complete_if, uid AS id FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . $rowAlertAuthors['id'] . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ # kodo preberemo iz srv_users
+ $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND user_id = '" . $rowAlertAuthors['id'] . "'";
+ $c2q = sisplet_query($c2s);
+ list($c2) = mysqli_fetch_row($c2q);
+ # nastavimo password če še ni
+ $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND user_id = '" . $rowAlertAuthors['id'] . "' AND pass IS NULL";
+ $qrySqlUpd = sisplet_query($strSqlUpd);
+
+ // ce imamo if na posiljanje mailov
+ if ($row1['alert_complete_if'] > 0) {
+ if (Check::getInstance()->checkIf($row1['alert_complete_if'])) {
+ $emails[] = array('mail' => $rowAlertAuthors['email'], 'type' => 'author', 'uid' => $rowAlertAuthors['id']);
+ }
+ } else {
+ $emails[] = array('mail' => $rowAlertAuthors['email'], 'type' => 'author', 'uid' => $rowAlertAuthors['id']);
+ }
+ }
+ }
+ // alert respondenta (ki vpise svoj mail ob izpolnjevanju)
+ if ($rowAlert['finish_respondent'] == 1) {
+ // email
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='email' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sql11 = sisplet_query("SELECT finish_respondent_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'");
+ $row11 = mysqli_fetch_array($sql11);
+
+ # kodo preberemo iz srv_users
+ $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "'";
+ $c2q = sisplet_query($c2s);
+ list($c2) = mysqli_fetch_row($c2q);
+ # nastavimo password če še ni
+ $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "' AND pass IS NULL";
+ $qrySqlUpd = sisplet_query($strSqlUpd);
+
+ // Ce resujemo anketo v drugem jeziku pogledamo ce imamo nastavljen custom mail za tuje jezike
+ $sql_ac = sisplet_query("SELECT * FROM srv_alert_custom WHERE ank_id='" . get('anketa') . "' AND type='respondent_lang_" . get('lang_id') . "' AND uid='0'");
+ if (mysqli_num_rows($sql_ac) > 0) {
+ $row_ac = mysqli_fetch_array($sql_ac);
+ $emails[] = array('mail' => $row2['text'], 'type' => $row_ac['type'], 'uid' => '0', 'code' => $c2);
+ } // ce imamo if na posiljanje mailov
+ elseif ($row11['finish_respondent_if'] > 0) {
+ if (Check::getInstance()->checkIf($row11['finish_respondent_if'])) {
+ $emails[] = array('mail' => $row2['text'], 'type' => 'respondent', 'uid' => '0', 'code' => $c2);
+ }
+ } else {
+ $emails[] = array('mail' => $row2['text'], 'type' => 'respondent', 'uid' => '0', 'code' => $c2);
+ }
+
+ // ime
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='ime' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $ime = $row2['text'];
+
+ }
+
+ // alert respondenta prepoznanega iz sispleta
+ if ($rowAlert['finish_respondent_cms'] == 1) {
+ $sql1 = Model::db_select_user(self::$global_user_id);
+ $row1 = mysqli_fetch_array($sql1);
+
+ if ($row1['email'] != '') {
+
+ $sql11 = sisplet_query("SELECT finish_respondent_cms_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'");
+ $row11 = mysqli_fetch_array($sql11);
+
+ # kodo preberemo iz srv_users
+ $c2s = "SELECT SUBSTRING(cookie,1,6) FROM srv_user where ank_id ='" . get('anketa') . "' AND user_id = '" . get('usr_id') . "'";
+ $c2q = sisplet_query($c2s);
+ list($c2) = mysqli_fetch_row($c2q);
+
+ $strSqlUpd = "UPDATE srv_user SET pass='$c2' WHERE ank_id ='" . get('anketa') . "' AND user_id = '" . get('usr_id') . "' AND pass IS NULL";
+ $qrySqlUpd = sisplet_query($strSqlUpd);
+
+ // ce imamo if na posiljanje mailov
+ if ($row11['finish_respondent_cms_if'] > 0) {
+ if (Check::getInstance()->checkIf($row11['finish_respondent_cms_if'])) {
+ $emails[] = array('mail' => $row1['email'], 'type' => 'respondent_cms', 'uid' => '0', 'code' => $c2);
+ }
+ } else {
+ $emails[] = array('mail' => $row1['email'], 'type' => 'respondent_cms', 'uid' => '0', 'code' => $c2);
+ }
+
+ }
+
+ }
+
+ // alert na ostale maile
+ if ($rowAlert['finish_other'] == 1) {
+
+ $email = explode("\n", str_replace("\r", "", str_replace(",", "\r\n", str_replace(" ", "", $rowAlert['finish_other_emails']))));
+ if (count($email) > 0)
+ foreach ($email AS $mail) {
+
+ $sql11 = sisplet_query("SELECT finish_other_if FROM srv_alert WHERE ank_id='" . get('anketa') . "'");
+ $row11 = mysqli_fetch_array($sql11);
+
+ // ce imamo if na posiljanje mailov
+ if ($row11['finish_other_if'] > 0) {
+ if (Check::getInstance()->checkIf($row11['finish_other_if'])) {
+ $emails[] = array('mail' => $mail, 'type' => 'other', 'uid' => '0');
+ }
+ } else {
+ $emails[] = array('mail' => $mail, 'type' => 'other', 'uid' => '0');
+ }
+ }
+ }
+
+ // sestavimo sporocilo
+ if ($row['finish_respondent_cms'] == 1) {
+ $sql1 = Model::db_select_user(self::$global_user_id);
+ $row1 = mysqli_fetch_array($sql1);
+ $ime = '' . $row1['name'] . ' ' . $row1['surname'];
+ }
+
+ # meta_url
+ $sql_meta_strings = "SELECT referer FROM srv_user where ank_id ='" . get('anketa') . "' AND id = '" . get('usr_id') . "'";
+ $sql_meta_query = sisplet_query($sql_meta_strings);
+ list($meta_url) = mysqli_fetch_row($sql_meta_query);
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+
+ $text = ($rowAlert['finish_text'] == '') ? '[NAME] ' . self::$lang['srv_alert_msg'] . ' [SURVEY] [DATE] ("[URL]")'.$signature : $rowAlert['finish_text'];
+ $subject = ($rowAlert['finish_subject'] != '') ? $rowAlert['finish_subject'] : self::$lang['srv_alert_subject'];
+
+ $sqlu = sisplet_query("SELECT email FROM users WHERE id = '$row[insert_uid]'");
+ $rowu = mysqli_fetch_array($sqlu);
+ $MailReply = $rowu['email'];
+
+ if ($rowAlert['reply_to'] != '') $MailReply = $rowAlert['reply_to'];
+
+ // preprečimo večkratno pošiljanje na iste naslove
+ array_unique($emails);
+
+ # preverimo odjavljenost od prejemanja obvestil
+ $su = new SurveyUnsubscribe(get('anketa'));
+
+ // posljemo maile
+ foreach ($emails AS $mail_list) {
+ $mail = trim($mail_list['mail']);
+ $unsubscribed = $su->isUnsubscribedEmail($mail);
+
+
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(
+ serialize(
+ array('a' => 'pdf_results',
+ 'anketa' => get('anketa'),
+ 'usr_id' => get('usr_id'),
+ 'type' => '0',
+ 'pdf_usr_type' => $mail_list['type'],
+ 'pdf_usr_id' => $mail_list['uid']
+ )));
+
+ $rtf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(
+ serialize(
+ array('a' => 'rtf_results',
+ 'anketa' => get('anketa'),
+ 'b' => 'export',
+ 'usr_id' => get('usr_id'),
+ 'pdf_usr_type' => $mail_list['type'],
+ 'pdf_usr_id' => $mail_list['uid']
+ )));
+
+
+ if ($mail != '' && $unsubscribed == false && (strlen($mail) > 1)) {
+
+ $sql_ac = sisplet_query("SELECT subject, text FROM srv_alert_custom WHERE ank_id='" . get('anketa') . "' AND type='{$mail_list['type']}' AND uid='{$mail_list['uid']}'");
+ if (mysqli_num_rows($sql_ac) > 0) {
+ $row_ac = mysqli_fetch_array($sql_ac);
+ $s = $row_ac['subject'];
+ $t = $row_ac['text'];
+ } else {
+ $s = $subject;
+ $t = $text;
+ }
+ // naredimo še data piping za odgovore
+ $t = Helper::dataPiping($t);
+
+ #zamenjamo morebitne sistemske variable
+ $t = str_replace(
+ array('[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[RTF]',
+ '[META_REFERER_URL]',
+ '[DURATION]'
+ ),
+ array($ime,
+ $row['akronim'], #$row['naslov'],
+ date("d.m.Y, H:i:s"),
+ //'<a href="'.self::$site_url.'a/'.get('anketa').'">'.self::$site_url.'a/'.get('anketa').'</a>',
+ '<a href="' . SurveyInfo::getSurveyLink() . '">' . SurveyInfo::getSurveyLink() . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '</a>',
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . $rtf_url . '">' . self::$lang['srv_alert_link_rtf'] . '</a>',
+ '<a href="' . $meta_url . '">' . $meta_url . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'
+ ),
+ $t);
+
+ $s = str_replace(
+ array('[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[RTF]',
+ '[DURATION]'),
+ array($ime,
+ $row['naslov'],
+ date("d.m.Y, H:i:s"),
+ //self::$site_url.'a/'.get('anketa'),
+ SurveyInfo::getSurveyLink(),
+ self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa'),
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . $rtf_url . '">' . self::$lang['srv_alert_link_rtf'] . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'),
+ $s);
+
+ if ($mail_list['code'] == null || trim($mail_list['code']) == '') {
+ # v tabelo srv_survey_unsubscribe_codes dodamo email in kodo za možnost odjave od obveščanja
+ $uc = $su->generateCodeForEmail($mail);
+ $unsubscribe = self::$site_url . 'admin/survey/unsubscribe.php?anketa=' . get('anketa') . '&uc=' . $uc . '&em=' . base64_encode($mail);
+ } else {
+ $unsubscribe = self::$site_url . 'admin/survey/unsubscribe.php?anketa=' . get('anketa') . '&code=' . $mail_list['code'];
+ }
+
+ $t = str_replace(
+ array('#UNSUBSCRIBE#', '[UNSUBSCRIBE]'),
+ array('<a href="' . $unsubscribe . '">' . self::$lang['user_bye_hl'] . '</a>',
+ '<a href="' . $unsubscribe . '">' . self::$lang['user_bye_hl'] . '</a>',)
+ , $t);
+
+
+ try {
+ $MA = new MailAdapter(get('anketa'), $type='alert');
+ $MA->addRecipients($mail);
+
+ // Shranimo email from in reply to (da ju potem nazaj nastavimo - drugace povozimo nastavitve od vabil)
+ $mailFromBCK = $MA->getMailFrom();
+ $mailReplyToBCK = $MA->getMailReplyTo();
+
+ // Nastavimo na raziskave - obvescanje je iz raziskave@1ka.si ce se ni nastavljeno posebej v smtp nastavitvah
+ $MA->setMailReplyTo($MailReply);
+ if ($mailFromBCK == '' || $mailFromBCK == 'info@1ka.si')
+ $MA->setMailFrom('raziskave@1ka.si');
+
+ // Posljemo mail
+ $result = $MA->sendMail(stripslashes($t), $s);
+
+ // Nazaj nastavimo posiljatelja (za nastavitve v vabilih)
+ $MA->setMailReplyTo($mailReplyToBCK);
+ $MA->setMailFrom($mailFromBCK);
+ } catch (Exception $e) {
+ }
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * @desc poslje alert o dosezeni kvoti za evoli - team meter
+ */
+ public function alertTeamMeter()
+ {
+ global $site_path;
+
+ # kadar popravljamo obstoječe podatke ne pošiljamo več obvestil o končani anketi (Ajda)
+ if ($_GET['urejanje'] == 1) {
+ return;
+ }
+
+ // Ce smo v predogledu ali testiranju ne posiljamo obvestila
+ if ($_GET['preview'] == 'on') {
+ return;
+ }
+
+
+ // Preverimo ce smo dosegli kvoto
+ $sqlGroupTM = sisplet_query("SELECT d.vre_id FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='" . get('anketa') . "' AND d.usr_id='" . get('usr_id') . "' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ $sqlTM = sisplet_query("SELECT tm.*, v.vrstni_red AS skupina FROM srv_evoli_teammeter tm, srv_vrednost v
+ WHERE tm.ank_id='" . get('anketa') . "' AND tm.skupina_id='" . $rowGroupTM['vre_id'] . "' AND tm.skupina_id=v.id");
+ $rowTM = mysqli_fetch_array($sqlTM);
+
+ // Preverimo ce smo slucajno ze posiljali porocilo
+ $datum_posiljanja = $rowTM['datum_posiljanja'];
+
+ // Kvota je dosezena - POSLJEMO OBVESTILO
+ if ($rowTM['kvota_max'] == $rowTM['kvota_val'] && $datum_posiljanja == '0000-00-00 00:00:00') {
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sqlAlert = sisplet_query("SELECT * FROM srv_alert WHERE ank_id = '" . get('anketa') . "'");
+ $rowAlert = mysqli_fetch_array($sqlAlert);
+
+ // Podpis
+ $signature = Common::getEmailSignature();
+
+ $text = ($rowAlert['finish_text'] == '') ? '[NAME] ' . self::$lang['srv_alert_msg'] . ' [SURVEY] [DATE] ("[URL]")'.$signature : $rowAlert['finish_text'];
+ $subject = ($rowAlert['finish_subject'] != '') ? $rowAlert['finish_subject'] : self::$lang['srv_alert_subject'];
+
+ $MailReply = $rowTM['email'];
+
+ if ($rowAlert['reply_to'] != '') $MailReply = $rowAlert['reply_to'];
+
+ // Mail posljemo avtorju skupine (podjetja)
+ $mail = $rowTM['email'];
+
+ $pdf_url = self::$site_url . 'admin/survey/izvoz.php?dc=' . base64_encode(
+ serialize(
+ array('m' => 'pdf_teammeter',
+ 'anketa' => get('anketa'),
+ 'skupina' => $rowTM['skupina']
+ )));
+
+ if ($mail != '' && (strlen($mail) > 1)) {
+
+ $s = $subject;
+ $t = $text;
+
+ // naredimo še data piping za odgovore
+ $t = Helper::dataPiping($t);
+
+ #zamenjamo morebitne sistemske variable
+ $t = str_replace(
+ array(
+ '[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[DURATION]'
+ ),
+ array(
+ $ime,
+ $row['akronim'], #$row['naslov'],
+ date("d.m.Y, H:i:s"),
+ '<a href="' . SurveyInfo::getSurveyLink() . '">' . SurveyInfo::getSurveyLink() . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '">' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '</a>',
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'
+ ),
+ $t);
+
+ $s = str_replace(
+ array(
+ '[NAME]',
+ '[SURVEY]',
+ '[DATE]',
+ '[SITE]',
+ '[URL]',
+ '[PDF]',
+ '[DURATION]'
+ ),
+ array(
+ $ime,
+ $row['naslov'],
+ date("d.m.Y, H:i:s"),
+ SurveyInfo::getSurveyLink(),
+ self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa'),
+ '<a href="' . $pdf_url . '">' . self::$lang['srv_alert_link_pdf'] . '</a>',
+ '<a href="' . self::$site_url . 'admin/survey/index.php?anketa=' . get('anketa') . '&amp;a=trajanje">' . self::$lang['srv_activate_duration'] . '</a>'
+ ),
+ $s);
+
+ try {
+ $MA = new MailAdapter(get('anketa'), $type='alert');
+ $MA->addRecipients($mail);
+
+ // Shranimo email from in reply to (da ju potem nazaj nastavimo - drugace povozimo nastavitve od vabil)
+ $mailFromBCK = $MA->getMailFrom();
+ $mailReplyToBCK = $MA->getMailReplyTo();
+
+ // Nastavimo na raziskave - obvescanje je iz raziskave@1ka.si ce se ni nastavljeno posebej v smtp nastavitvah
+ $MA->setMailReplyTo($MailReply);
+ if ($mailFromBCK == '' || $mailFromBCK == 'info@1ka.si')
+ $MA->setMailFrom('raziskave@1ka.si');
+
+ // Posljemo mail
+ $result = $MA->sendMail(stripslashes($t), $s);
+
+ // Nazaj nastavimo posiljatelja (za nastavitve v vabilih)
+ $MA->setMailReplyTo($mailReplyToBCK);
+ $MA->setMailFrom($mailFromBCK);
+ }
+ catch (Exception $e) {
+ }
+
+ // Updatamo timestamp posiljanja
+ $sql = sisplet_query("UPDATE srv_evoli_teammeter SET datum_posiljanja=NOW() WHERE id='".$rowTM['id']."'");
+ }
+ }
+
+ return;
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/InitClass.php b/main/survey/app/Controllers/InitClass.php
new file mode 100644
index 0000000..f0c7dc9
--- /dev/null
+++ b/main/survey/app/Controllers/InitClass.php
@@ -0,0 +1,1230 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 04.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\BodyController as Body;
+use App\Controllers\CheckController as Check;
+use App\Controllers\DisplayController as Display;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use App\Models\SaveSurvey;
+use Common;
+use Mobile_Detect;
+use SurveyInfo;
+use SurveySetting;
+use SurveySlideshow;
+use GDPR;
+use MAZA;
+use UserAccess;
+
+
+class InitClass extends Controller
+{
+ protected $get;
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+
+ //inicializiramo $variable v $this, da jih lažje prikličemo
+ parent::getAllVariables();
+
+ if (!get('printPreview')) {
+ return $this->loadIfPrintPreviewFalse();
+ } else {
+ return $this->loadIfPrintPreviewTrue();
+ }
+ }
+
+ /************************************************
+ * Print preview je izključen
+ ************************************************/
+ private function loadIfPrintPreviewFalse()
+ {
+ // cist na zacetku preverimo referer. Ce je prisel od kje drugje (napacno skopiran link itd...) ga preusmerimo na prvo stran ankete
+ if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], self::$site_url) === false && !isset($_GET['code']) && !isset($_GET['return']) && !isset($_GET['params'])) {
+
+ $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!"));
+ save('anketa', $anketa);
+
+ // Pri ul evalvaciji tega ne pustimo, ker drugace narobe preusmeri
+ if (Common::checkModule('evalvacija') == '0') {
+
+ // to more bit, ker zgleda da pri redirectu browser ne nastavi novega refererja... (tudi websm anketa ne rabi tega - vedno mora skocit na ustrezno stran)
+ if ($_COOKIE['ref'] != get('anketa') && !(get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1')) {
+
+ // prenesemo sistemske spremenljivke, ki so podane preko URLja
+ $sql1 = sisplet_query("SELECT s.id, s.variable FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND s.sistem='1' AND (s.tip='4' OR s.tip='21' OR s.tip='1')");
+ $g = '';
+ while ($row1 = mysqli_fetch_array($sql1))
+ if (isset($_GET[$row1['variable']])) $g .= '&' . $row1['variable'] . '=' . $_GET[$row1['variable']];
+
+ $g .= Header::getSurveyParams();
+
+ //$redirect_url = self::$site_url."a/".get('anketa').$g;
+ $redirect_url = SurveyInfo::getSurveyLink(false, false) . $g;
+ $request_url = 'http' . ($_SERVER['HTTPS'] ? 's' : null) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+
+ if ($redirect_url != $request_url) { // to je extra check, da pridejo skozi in se ne vrtijo v neskoncni zanki tudi ljudje (paranoiki :) ) brez cookiejev
+ setcookie('ref', get('anketa')); // cookie z referalom
+
+ header("Location: " . $redirect_url);
+ die();
+ }
+ }
+ }
+ }
+
+ // ce se je vrnil na anketo preko URLja
+ if (isset($_GET['return'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ if (isset($_GET['anketa']) || isset($_POST['anketa'])) {
+
+ $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!"));
+ save('anketa', $anketa);
+
+ // Preverimo ce gre za POSEBNO webSM anketo (ki ne shranjuje nicesar - samo direktno preusmeri na ustrezno stran)
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1')
+ $this->jeWebSMSurvey();
+
+ // polovimo podatke o anketi
+ SurveyInfo::getInstance()->SurveyInit(get('anketa'));
+ if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
+ save('db_table', '_active');
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ // Ce anketa sploh ne obstaja
+ if (!$rowa) {
+ Display::getInstance()->displayNapaka(self::$lang['no_survey']);
+ die();
+ }
+
+ // Ce nima dostopa do ankete
+ if (!((self::$admin_type <= $rowa['odgovarja'] && self::$admin_type >= 0) || ($rowa['odgovarja'] == 4))) {
+ Display::getInstance()->displayNapaka(self::$lang['no_access']);
+ die();
+ }
+
+
+ // pretecena anketa, kontroliramo datum na: starts in expire
+ $stringe = "SELECT id , CURDATE(), starts, expire FROM srv_anketa WHERE id='" . get('anketa') . "' AND starts <= CURDATE() AND expire >= CURDATE()";
+ $sqle = sisplet_query($stringe);
+
+ // Tudi ce je zakljucena pustimo prikaz pri nastavljenem glas_end -> preklop arhiva statistike pri glasovanju - drugace izpisemo obvestilo o zakljucku
+ if (!(isset($_GET['preview']) && $_GET['preview'] == 'on') && ($rowa['active'] < 1 or mysqli_num_rows($sqle) == 0) && (!isset($_GET['glas_end']) && (!isset($_GET['urejanje']))))
+ $this->anketaEnd($rowa);
+
+
+ // Preverimo ce je nastavljen staticen uvod (ki ne belezi nicesar) - da se pri embeddanih anketah ne shranjujejo vsi obiskovalci ampak se user ustvari sele na prvi strani po uvodu
+ if ($rowa['intro_static'] > 0 && $rowa['show_intro'] == 1 && count($_POST) == 0 && !isset($_GET['grupa'])) {
+
+ // inicializiramo jezik za multilang anketo
+ Language::getInstance()->multilang_init();
+
+ // konec ukvarjanja s cookieji, prikazemo header
+ Header::getInstance()->header();
+
+ Body::getInstance()->displayStaticIntroduction();
+ die();
+ } // Ce imamo staticen uvod s captcho in smo kliknili na naslednjo stran, najprej preverimo captcho
+ elseif ($rowa['intro_static'] == 2 && $rowa['show_intro'] == 1 && count($_POST) != 0 && isset($_GET['grupa']) && $_GET['grupa'] == '0') {
+ Check::getInstance()->check_captcha_intro();
+ }
+
+
+ // ali je respondent avtor ankete (zaradi posebnih opcij prepoznave)
+ $sqlUserAutor = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id='" . get('anketa') . "' AND uid='" . self::$global_user_id . "'");
+ if (mysqli_num_rows($sqlUserAutor) > 0)
+ save('userAutor', true);
+
+ // Ce imamo nastavljeno da vedno zahtevamo kodo
+ if (isset($_GET['code']) && $rowa['usercode_required'] == 1) {
+ unset($_GET['code']);
+ }
+
+ // pogledamo na kolk je nastavljen expire za cookie v nastavitvi ankete
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ save('cookie_expire', $row['cookie']);
+
+ if ($row['cookie'] == 0) {
+ $this->expire = 0;
+ } elseif ($row['cookie'] == -1) {
+ if ($rowa['user_from_cms'] == 1) {
+ $this->expire = time() - 3600;
+ } else {
+ $this->expire = 0;
+ }
+ } elseif ($row['cookie'] == 1) {
+ $this->expire = time() + 3600;
+ } else {
+ $this->expire = time() + 2500000;
+ }
+
+ // Preberimo cookie stringiii
+ $this->cookie = null;
+
+ // da delata oba načina nastavljanja piškotkov, neglede na nastavitve
+ if (isset($_GET['survey-' . get('anketa')]))
+ $this->cookie = $_GET['survey-' . get('anketa')]; // Pri nastavitvi brez cookie-ja se cookie string prenaša preko URL-ja
+ if (isset($_COOKIE['survey-' . get('anketa')]))
+ $this->cookie = $_COOKIE['survey-' . get('anketa')]; // Obicajen cookie
+
+
+ // EVALVACIJA - Ce je nov respondent preverimo ce se je vrnil (zapis v tabeli eval_data_userCookie) in mu nastavimo ustrezen cookie da ga preusmerimo na ustrezno stran
+ if (Common::checkModule('evalvacija') == '1' && $this->cookie == null)
+ $this->cookie = $this->evlavacijaNovRespondent();
+
+ // HIERARHIJA - UČITELJ, preverimo, če je učitelj ponovno prišel nazaj
+ if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2 && is_null($this->cookie))
+ $this->cookie = $this->hierarhijaPreveriCeSeJeUciteljVrnilPonovnoResevatiAnketo();
+
+ // poskrbimo za user ID
+ //
+ // tuki je kookie ze nastavljen in ga samo preberemo
+ if ($this->cookie != null)
+ $this->cookieExist($this->cookie);
+
+ // kukija se ni, ga bomo pa nastavil
+ if ($this->cookie == null)
+ $this->cookieIsNull();
+
+
+ // tukaj bomo dodatno preverjali, ce slucajno kje&kdaj pride do napake da usr_id ni postavljen
+ if (get('usr_id') == 0) {
+ $get = '';
+ foreach ($_GET AS $key => $val) {
+ if ($get != '')
+ $get .= ', ';
+ $get .= $key . ': "' . $val . '"';
+ }
+
+ $post = '';
+ foreach ($_POST AS $key => $val) {
+ if ($post != '')
+ $post .= ', ';
+ $post .= $key . ': "' . $val . '"';
+ }
+ $kuki = '';
+ foreach ($_COOKIE AS $key => $val) {
+ if ($kuki != '')
+ $kuki .= ', ';
+ $kuki .= $key . ': "' . $val . '"';
+ }
+ $text = 'GET: ' . $get . '; POST: ' . $post . '; COOKIE: ' . $kuki;
+
+ $sql_log = sisplet_query("SELECT value FROM srv_survey_misc WHERE sid = '" . get('anketa') . "' AND what = 'usr_id_error'");
+ $row_log = mysqli_fetch_array($sql_log);
+ $text = $row_log['value'] . "\n" . $text;
+
+ sisplet_query("REPLACE INTO srv_survey_misc (sid, what, value) VALUES ('" . get('anketa') . "', 'usr_id_error', '" . $text . "')");
+ }
+
+ // inicializiramo jezik za multilang anketo
+ Language::getInstance()->multilang_init();
+
+ // konec ukvarjanja s cookieji, prikazemo header
+ Header::getInstance()->header();
+
+ //prikaz konca ankete - posebej statistika pri glasovanju
+ if (isset($_GET['glas_end'])) {
+
+ Body::getInstance()->displayKonecGlasovanje();
+
+ } else {
+ if (isset($_GET['loop_id'])) save('loop_id', $_GET['loop_id']);
+
+ // nismo se poslali kaksno stran z odgovori
+ if (count($_POST) == 0) {
+
+ // Preverimo kvoto pri Evoli Team Meter
+ if (SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter')
+ ) {
+
+ // Ce imamo nastavljeno skupino
+ if (isset($_GET['skupina'])) {
+
+ $skupina_id = $_GET['skupina'];
+
+ $sqlGroupTM = sisplet_query("SELECT kvota_val, kvota_max, date_to FROM srv_evoli_teammeter WHERE ank_id='" . get('anketa') . "' AND skupina_id='" . $skupina_id . "'");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ // Ce je kvota ze dosezena
+ if ($rowGroupTM['kvota_val'] >= $rowGroupTM['kvota_max']) {
+ Body::getInstance()->displayKonecEvoliTM();
+ die();
+ }
+
+ // Ce je datum ze presezen
+ if (strtotime($rowGroupTM['date_to']) < time() - (60 * 60 * 24)) {
+ $date_to = date('d.m.Y', strtotime($rowGroupTM['date_to']));
+ Body::getInstance()->displayKonecEvoliTM($date_to);
+ die();
+ }
+ }
+ }
+
+ if (isset($_GET['grupa']))
+ save('grupa', $_GET['grupa']);
+
+ if ($rowa['show_intro'] == 0 && !isset($_GET['grupa'])) {
+ $this->set_userstatus(3);
+ SaveSurvey::saveSistemske();
+ save('grupa', Find::getInstance()->findNextGrupa());
+ }
+
+ if (get('grupa') == 'end') {
+ $this->set_userstatus(6);
+
+ Body::getInstance()->displayKonec();
+
+ }
+ elseif (get('displayAllPages')) {
+
+ Body::getInstance()->displayAllPages();
+
+
+ }
+ // prikazemo ustrezno stran / grupo
+ elseif (get('grupa') > 0) {
+
+ $preskok = false;
+
+ // pogledamo ce preskocimo kaksno stran zaradi branchinga
+ while (!Check::getInstance()->checkGrupa() && get('grupa') > 0 && $_GET['disableif'] != 1) {
+
+ SaveSurvey::getInstance()->posted(1);
+ save('grupa', Find::getInstance()->findNextGrupa());
+ $preskok = true;
+ }
+
+ if ($preskok) SaveSurvey::getInstance()->posted_commit(); // pri preskokih se ne shranjuje sproti v bazo, ampak na koncu, vse naenkrat
+
+ if (get('grupa') > 0) {
+ Body::getInstance()->displayAnketa();
+ } else {
+ $this->set_userstatus(6);
+ Body::getInstance()->displayKonec();
+ }
+
+ // prikazemo uvodni nagovor - introduction
+ } else {
+
+ // nastavimo status -- kliknil je na anketo
+ $this->set_userstatus(3);
+
+ Body::getInstance()->displayIntroduction();
+ }
+ }
+ // poslani so bili odgovori
+ else {
+
+ save('grupa', $_GET['grupa']);
+
+ // Preverimo ce gre za gdpr anketo in ce je sprejel pogoje za sodelovanje
+ if(GDPR::isGDPRSurveyTemplate(get('anketa'))){
+
+ // Ni sprejel pogojev za sodelovanje - vrzemo na zakljucek
+ if(isset($_POST['gdpr']) && $_POST['gdpr_accept'] == '0'){
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ // Ni oznacil ali sprejema pogoje
+ elseif(isset($_POST['gdpr']) && !isset($_POST['gdpr_accept'])){
+ Body::getInstance()->displayIntroduction();
+ die();
+ }
+ }
+
+ if (get('grupa') == 'end') {
+ $this->set_userstatus(6);
+
+ Body::getInstance()->displayKonec();
+
+ }
+ else {
+ // ce je nastavljena grupa (se pravi ni prva stran) in ce nismo v predogledu ankete
+ if (get('grupa') > 0 || get('displayAllPages')) {
+ // nastavimo status -- izpolnjuje anketo
+ $this->set_userstatus(5);
+
+ // shrani poslano stran v bazo
+ SaveSurvey::getInstance()->posted();
+
+ } else { // prva stran z vprasanji
+
+ $s = sisplet_query("REPLACE INTO srv_user_grupa" . get('db_table') . " (gru_id, usr_id, time_edit) VALUES ('0', '" . get('usr_id') . "', NOW())");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+ $this->set_userstatus(4);
+ }
+
+ if (get('loop_AW') == 0 && get('loop_id') == null) {
+ $grupa = Find::getInstance()->findNextGrupa();
+ }
+ elseif (get('loop_AW') == 1) {
+ $grupa = get('grupa');
+ }
+ elseif (get('loop_id') != null) {
+ $grupa = get('grupa');
+ save('loop_id', Find::getInstance()->findNextLoopId(), 1);
+ if (get('loop_id') == null)
+ $grupa = Find::getInstance()->findNextGrupa();
+ }
+
+ if (get('displayAllPages')) {
+
+ echo ' <script>' . "\n";
+ echo ' window.close();' . "\n";
+ if(Common::checkModule('gorenje'))
+ echo ' document.location.href=\'https://surveys.gorenje.com/\';' . "\n";
+ else
+ echo ' document.location.href=\'https://www.1ka.si/\';' . "\n";
+ echo ' </script>' . "\n";
+
+ }
+ elseif ($grupa > 0) {
+
+ save('grupa', $grupa);
+
+ if (get('loop_AW') == 0 && get('loop_id') == null)
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . Header::getSurveyParams() . get('cookie_url') . '');
+ elseif (get('loop_AW') == 1)
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&ime=' . get('ime_AW') . Header::getSurveyParams() . get('cookie_url') . '');
+ elseif (get('loop_id') != null)
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&loop_id=' . get('loop_id') . Header::getSurveyParams() . get('cookie_url') . '');
+
+ }
+ else {
+
+ // nastavimo status -- anketo je izpolnil do konca
+ $this->set_userstatus(6);
+
+ //prikaz konca ankete - pri glasovanju izpisujemo posebej zakljucek in statistiko
+ if ($rowa['survey_type'] == 0) {
+ Body::getInstance()->displayKonecGlasovanje();
+ } else {
+ Body::getInstance()->displayKonec();
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ // prisli smo cez vse silne procedure in redirecte, lahko pobrisemo cookie za referer, ker ga (upam) ne rabimo vec
+ setcookie('ref', '', time() - 5000); // pobrisemo cookie
+ }
+
+ /**
+ * Preverimo, če učitelj rešuje anketo in če že ima usr_id shranjen v bazi ali ga še ni
+ *
+ * @return mixed $cookie
+ */
+ private function hierarhijaPreveriCeSeJeUciteljVrnilPonovnoResevatiAnketo()
+ {
+ $url = base64_decode(urldecode($this->get->enc));
+
+ $cookie = sisplet_query("SELECT su.cookie AS cookie FROM srv_hierarhija_koda AS shk LEFT JOIN srv_user AS su ON (shk.srv_user_id = su.id) WHERE url='" . $url . "'", "obj")->cookie;
+ return $cookie;
+ }
+
+ /************************************************
+ * Naložimo v kolikor imamo vkloplje print preview TRUE
+ ************************************************/
+ private function loadIfPrintPreviewTrue()
+ {
+ $anketa = (isset($_GET['anketa'])) ? $_GET['anketa'] : ((isset($_POST['anketa'])) ? $_POST['anketa'] : die("Missing anketa id!"));
+ if (get('anketa') != $anketa)
+ save('anketa', $anketa);
+
+ // polovimo podatke o anketi
+ \SurveyInfo::getInstance()->SurveyInit(get('anketa'));
+ if (\SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
+ save('db_table', '_active');
+
+ \SurveySetting::getInstance()->Init(get('anketa'));
+ save('usr_id', $_REQUEST['usr_id']);
+
+ Language::getInstance()->multilang_init();
+ }
+
+
+ /************************************************
+ * Če gre za posebno testno anketo WebSMSruvey
+ ************************************************/
+ private function jeWebSMSurvey()
+ {
+
+ // inicializiramo jezik za multilang anketo
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ if (isset($_GET['language'])) { // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu)
+ $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$_GET[language]'");
+ $rowl = mysqli_fetch_array($sqll);
+ save('lang_id', $rowl['lang_id']);
+ } elseif (isset($_POST['language'])) { // jezik podan v POSTu (ce si ga user spremeni na prvi strani)
+ save('lang_id', $_POST['language']);
+ }
+ if (get('lang_id') == null) { // ni bil podan preko GETa in ni shranjen v bazi -- priredimo default jezik
+ $_GET['language'] = self::$lang['id']; // to damo samo zato, da se shrani ID default jezika v bazo, namesto -1 (ker pri default jeziku ne podamo nič preko URLja)
+ // get('lang_id') mora se vedno ostati null !
+ } else { // zamenjamo jezik
+ $file = lang_path(get('lang_id'));
+ if (@include($file))
+ $_SESSION['langX'] = lang_path(get('lang_id'), 1);
+ }
+
+ // prikazemo header
+ Header::getInstance()->header();
+
+ if (!isset($_GET['grupa'])) {
+
+ if ($row['show_intro'] == 1) {
+ Body::getInstance()->displayIntroduction();
+ } else {
+ $grupa = save('grupa', Find::getInstance()->findNextGrupa(), 1);
+
+ if ($grupa > 0) {
+ if (isset($_GET['language']))
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&language=' . $_GET['language'] . '');
+ else
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '');
+ } else {
+ Body::getInstance()->displayKonec();
+ }
+ }
+ } else {
+ save('grupa', $_GET['grupa']);
+
+ // pogledamo ce preskocimo kaksno stran zaradi branchinga
+ while (!Check::getInstance()->checkGrupa() && get('grupa') > 0 && $_GET['disableif'] != 1) {
+ save('grupa', Find::getInstance()->findNextGrupa());
+ }
+
+ // nismo se poslali kaksno stran z odgovori
+ if (count($_POST) == 0) {
+ if (get('grupa') > 0)
+ Body::getInstance()->displayAnketa();
+ else
+ Body::getInstance()->displayKonec();
+ } // poslani so bili odgovori
+ else {
+ $grupa = Find::getInstance()->findNextGrupa();
+ save('grupa', $grupa, 1);
+
+ if ($grupa > 0) {
+ if (isset($_GET['language']))
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '&language=' . $_GET['language'] . '');
+ else
+ header('Location: ' . SurveyInfo::getSurveyLink(false, false) . '&grupa=' . get('grupa') . '');
+ } else {
+ Body::getInstance()->displayKonec();
+ }
+ }
+ }
+
+ die();
+ }
+
+ /************************************************
+ * Tudi ce je zakljucena pustimo prikaz pri nastavljenem glas_end -> preklop arhiva statistike pri glasovanju - drugače izpišemo obvestilo o zaključku
+ ************************************************/
+ private function anketaEnd($rowa)
+ {
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ SurveySetting::getInstance()->init(get('anketa'));
+
+ if ($rowa['active'] > 0) {
+
+ // preverimo začetek in konec
+ $sqlDates = sisplet_query("SELECT id, starts, expire, (IF(CURDATE() >= starts, true, false)) as boolStarts, (IF(CURDATE() <= expire, true, false)) as boolExpire FROM srv_anketa WHERE id='" . get('anketa') . "'");
+ $rowDates = mysqli_fetch_assoc($sqlDates);
+ if (!$rowDates['boolStarts']) {
+
+ $srv_survey_non_active_notStarted = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_notStarted' . $_lang);
+ if ($srv_survey_non_active_notStarted == '') $srv_survey_non_active_notStarted = self::$lang['srv_survey_non_active_notStarted'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active_notStarted . $rowDates['starts']);
+ }
+ if (!$rowDates['boolExpire']) {
+
+ $srv_survey_non_active_expired = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_expired' . $_lang);
+ if ($srv_survey_non_active_expired == '') $srv_survey_non_active_expired = self::$lang['srv_survey_non_active_expired'];
+
+ Display::getInstance()->displayNapaka(self::$lang['srv_survey_non_active_expired'] . $rowDates['expire']);
+ }
+ } elseif ($rowa['active'] == 0) {
+
+ # anketa ni aktivna, preverimo ali je bila sploh aktivirana
+ $str = "SELECT count(*) FROM srv_activity WHERE sid = '" . get('anketa') . "'";
+ $qry = sisplet_query($str);
+ list($count_activity) = mysqli_fetch_row($qry);
+ if ($count_activity > 0) {
+
+ $srv_survey_non_active = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active' . $_lang);
+ if ($srv_survey_non_active == '') $srv_survey_non_active = self::$lang['srv_survey_non_active'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active);
+ } else {
+
+ $srv_survey_non_active_notActivated = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_notActivated' . $_lang);
+ if ($srv_survey_non_active_notActivated == '') $srv_survey_non_active_notActivated = self::$lang['srv_survey_non_active_notActivated'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active_notActivated);
+ }
+ } else {
+
+ $srv_survey_deleted = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_deleted' . $_lang);
+ if ($srv_survey_deleted == '') $srv_survey_deleted = self::$lang['srv_survey_deleted'];
+
+ Display::getInstance()->displayNapaka($srv_survey_deleted);
+ }
+
+ die();
+ }
+
+
+ // EVALVACIJA - Ce je nov respondent preverimo ce se je vrnil (zapis v tabeli eval_data_userCookie) in mu nastavimo ustrezen cookie da ga preusmerimo na ustrezno stran
+ private function evlavacijaNovRespondent()
+ {
+ $student = (isset($_GET['sifstud'])) ? $_GET['sifstud'] : 0;
+ $predmet = (isset($_GET['sifpredm'])) ? $_GET['sifpredm'] : -1; // Ce resuje splosno anketo ni predmeta -> predmet = -1
+
+ if ($student > 0) {
+ $sqlE = sisplet_query("SELECT u.cookie AS cookie FROM eval_data_userCookie adu, srv_user u
+ WHERE adu.ank_id='" . get('anketa') . "' AND adu.student='" . $student . "' AND adu.predmet='" . $predmet . "'
+ AND u.ank_id='" . get('anketa') . "' AND u.id=adu.usr_id");
+ if (mysqli_num_rows($sqlE) > 0) {
+ $rowE = mysqli_fetch_array($sqlE);
+ $cookie = $rowE['cookie'];
+ return $cookie;
+ }
+ }
+ }
+
+
+ /************************************************
+ * Če cookie obstaja ga samo preberemo
+ ************************************************/
+ protected $cookie;
+
+ private function cookieExist($cookie)
+ {
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ $sql = sisplet_query("SELECT id, user_id FROM srv_user WHERE cookie='$cookie' AND deleted='0' LIMIT 1");
+ $row = mysqli_fetch_array($sql);
+
+ if ($row['id'] > 0) {
+
+ save('usr_id', $row['id']);
+
+
+ // cookie se enkrat nastavmo, ce se je kaj spreminjal nastavitve expire-ja
+ $this->set_cookie('survey-' . get('anketa'), $cookie, $this->expire);
+
+ // v primeru da je cookie ze bil postavljen, pa da se ni bilo povezave s sisplet userjem, ga 'povezemo'
+ if ($rowa['user_from_cms'] >= 1)
+ if ($row['user_id'] == 0 && self::$global_user_id > 0)
+ $sql = sisplet_query("UPDATE srv_user SET user_id = '" . self::$global_user_id . "' WHERE cookie = '$cookie'");
+
+ // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore
+ // Dodano v pogoj da se to izvede samo ce nima nastavljene grupe (drugace dela narobe klik nazaj na zakljucku, preklop med bloki...)
+ if ($rowa['return_finished'] == 0 && !isset($_GET['grupa']) && !isset($_GET['urejanje']) && !isset($_GET['return'])) {
+ $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'");
+ $rows = mysqli_fetch_array($sqls);
+ if ($rows['status'] == 6) { // Koncal anketo
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ }
+
+ // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo
+ if (!isset($_GET['grupa'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ } else { // dodatno preverjanje, ce se slucajno kaj sfizi, pa da ni tega cookieja v bazi, ga moramo se enkrat nastavit
+ $this->cookie = null;
+ }
+ }
+
+ /************************************************
+ * Cookie ni nastavljen is null
+ ************************************************/
+
+ private function cookieIsNull()
+ {
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ //preverjamo limit stevila glasov
+ if ((!isset($_GET['preview']) || $_GET['preview'] != 'on') && ($rowa['vote_limit'] == 1 || $rowa['vote_limit'] == 2)) {
+
+ // preverimo ce smo presegli limit
+ // Stetje samo ustreznih odgovorov
+ if ($rowa['vote_limit'] == 2)
+ $sqlVotes = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='" . get('anketa') . "' AND (last_status='5' OR last_status='6') AND lurker='0' AND deleted='0'");
+ // Stetje vseh odgovorov
+ else
+ $sqlVotes = sisplet_query("SELECT COUNT(id) FROM srv_user WHERE ank_id='" . get('anketa') . "' AND deleted='0'");
+
+ $rowVotes = mysqli_fetch_assoc($sqlVotes);
+
+ if ($rowa['vote_count'] <= $rowVotes['COUNT(id)']) {
+ //$this->display->displayNapaka(self::$lang['srv_survey_non_active_voteLimit'].' ('.$rowa['vote_count'].')');
+
+ $srv_survey_non_active_voteLimit = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_survey_non_active_voteLimit' . $_lang);
+ if ($srv_survey_non_active_voteLimit == '') $srv_survey_non_active_voteLimit = self::$lang['srv_survey_non_active_voteLimit'];
+
+ Display::getInstance()->displayNapaka($srv_survey_non_active_voteLimit);
+ die();
+ }
+ }
+
+ // splosna koda za dostop do ankete (brez prepoznave userja) - dodatno preverimo ce je ta funkcionalnost na voljo v paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ $sqlp = sisplet_query("SELECT password FROM srv_password WHERE ank_id='" . get('anketa') . "'");
+ if (mysqli_num_rows($sqlp) > 0 && $userAccess->checkUserAccess($what='password')) {
+
+ $ok = false;
+
+ while ($rowp = mysqli_fetch_array($sqlp)) {
+
+ if (isset($_POST['password']) && $rowp['password'] == $_POST['password'] /*|| $_COOKIE['password_' .get('anketa')] == $rowp['password']*/) {
+ setcookie('password_' . get('anketa'), $rowp['password']);
+ $ok = true;
+ }
+ }
+
+ if (!$ok) {
+ Header::getInstance()->header();
+ Body::getInstance()->displayIntroduction();
+ die();
+ }
+ }
+
+ // preverimo, ce blokiramo IP (to nardimo, samo ce se ni kukija - drugac bi ga takoj zablokiral (ce pa je kuki se ga pa itak prepoza pa potem shendla))
+ if ($rowa['block_ip'] > 0) {
+ $sqlip = sisplet_query("SELECT id FROM srv_user WHERE ank_id='" . get('anketa') . "' AND ip='" . Helper::remote_address() . "' AND time_edit >= NOW() - INTERVAL $rowa[block_ip] MINUTE");
+ if (mysqli_num_rows($sqlip) > 0) { // je ze dostopal iz tega IPja
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ }
+
+ if (self::$global_user_id == 0) {
+ $row1['id'] = 0;
+ }
+ else {
+ $sql1 = sisplet_query("SELECT id, cookie FROM srv_user WHERE user_id = '" . self::$global_user_id . "' AND user_id > 0 AND ank_id = '" . get('anketa') . "'");
+
+ if(mysqli_num_rows($sql1) > 0)
+ $row1 = mysqli_fetch_array($sql1);
+ else
+ $row1['id'] = 0;
+ }
+
+ // ce je izbrana povezava s sisplet userjem in da smo najdl cookie za trenutnega userja, potem nastavimo ta cookie
+ if ($row1['id'] > 0 && $rowa['user_from_cms'] == 1) {
+
+ $rand = $row1['cookie'];
+
+ $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire);
+
+ save('usr_id', $row1['id']);
+
+
+ // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore
+ if ($rowa['return_finished'] == 0) {
+ $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'");
+ $rows = mysqli_fetch_array($sqls);
+ if ($rows['status'] == 6) { // Koncal anketo
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+ die();
+ }
+ }
+
+ // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo
+ if (!isset($_GET['grupa'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ // userji iz baze
+ } elseif (
+ ($rowa['user_base'] == 1) &&
+ #če imamo neindividualizirana vabila - poslana preko vabil, vendar bez kode in zato brez sledenja (uporabnik se pri pošiljanju NE prenese iz srv_invitations_recipients v srv_user)
+ $rowa['individual_invitation'] != 0 &&
+ ( // Omogoči anketo tudi respodentom, ki niso v bazi
+ ($rowa['usercode_skip'] == 0) // Ne (vsi grejo sem not, ker morajo nujno vnesti kodo)
+ || ($rowa['usercode_skip'] == 1 /*&& (isset($_POST['usercode']) or isset($_GET['code']))*/) // Da (sem not grejo samo, ce so vnesli kodo, da jih prepoznamo, sicer grejo na else in dobijo nov cookie)
+ || ($rowa['usercode_skip'] == 2 && (!get('userAutor') || (isset($_POST['usercode']) or isset($_GET['code'])))) // Samo avtor (ce ni avtor ankete, gre sem noter in mora vnesti kodo. Avtor ankete pa gre sem notr samo ce je podana koda, sicer gre na else in dobi nov cookie)
+
+ // Respondenti naj vedno vnesejo kodo: Da
+ || ($rowa['usercode_required'] == 1 && $rowa['usercode_skip'] != 1 &&
+ ( // Omogoči anketo tudi respodentom, ki niso v bazi
+ $rowa['usercode_skip'] == 0 // Ne (vsi grejo sem not, ker morajo nujno vnesti kodo)
+ || ($rowa['usercode_skip'] == 2 && !get('userAutor') /*&& ( !$userAutor || $userAutor || (isset($_POST['usercode']) or isset($_GET['code'])) )*/) // Samo avtor (ce ni avtor ankete, gre sem noter in mora vnesti kodo. Avtor ankete pa gre sem notr samo ce je podana koda, sicer gre na else in dobi nov cookie)
+ ) // ^ tale pogoj zgoraj se ni cist ok, ker mora tudi avtor vnesti kodo - AVTORJU NI TREBA VNEST KODE CE JE TO VKLOPLJENO - dodan && !get('userAutor')
+ )
+ )
+ ) {
+ if (isset($_POST['usercode']) or isset($_GET['code'])) {
+
+ if (isset($_POST['usercode']))
+ $usercode = strtolower($_POST['usercode']);
+ elseif (isset($_GET['code']))
+ $usercode = strtolower($_GET['code']);
+ else
+ die();
+
+ $sql2 = sisplet_query("SELECT id, recnum, cookie FROM srv_user WHERE TRIM(pass) = '$usercode' AND ank_id='".get('anketa')."' AND deleted='0'");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ $row2 = mysqli_fetch_array($sql2);
+
+ // Pravilna koda
+ if (mysqli_num_rows($sql2) > 0) {
+
+ // Ce imamo vklopljen modul za volitve preskocimo kar nekaj korakov (anonimizacija)
+ if(!SurveyInfo::checkSurveyModule('voting')){
+
+ // Dodatno preverimo ce koda se ni potekla
+ $sqlC = sisplet_query("SELECT * FROM srv_invitations_recipients WHERE ank_id='".get('anketa')."' AND TRIM(password)='".$usercode."' AND DATE(NOW())>DATE(date_expired) AND date_expired!='0000-00-00 00:00:00'");
+ if(mysqli_num_rows($sqlC) > 0){
+ Display::getInstance()->displayNapaka(self::$lang['srv_expiredcode']);
+ die();
+ }
+
+ # nastavimo še da je uporabnik odgovoril na anketo za nov način e-mail vabil
+ sisplet_query("UPDATE srv_invitations_recipients SET responded = '1', date_responded = NOW() WHERE ank_id='" . get('anketa') . "' AND TRIM(password) ='$usercode' AND responded = '0'");
+
+ sisplet_query("COMMIT");
+ }
+
+ $rand = $row2['cookie'];
+
+ $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire);
+
+ save('usr_id', $row2['id']);
+
+
+ // Preverimo ce imamo vklopljeno da uporabnik nadaljuje kjer je ostal - potem ga preusmerimo na pravo stran
+ Check::getInstance()->check_cookie_return();
+
+ if ($row2['recnum'] == 0) {
+
+ if (isset($_POST['referer']))
+ $referer = $_POST['referer'];
+ elseif (isset($_SERVER['HTTP_REFERER']))
+ $referer = $_SERVER['HTTP_REFERER'];
+ else
+ $referer = 0;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip');
+ $browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser');
+ $referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal');
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+
+ if ($ip == 0) $_ip = Helper::remote_address(); else $ip = "";
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+ if ($referal == 0) $_referer = $referer; else $_referer = '';
+ if ($browser == 0) $_useragent = $_SERVER['HTTP_USER_AGENT']; else $_useragent = '';
+
+ // Ce dovolimo useragent in ce je instaliran browscap
+ $_browser = '';
+ $_device = 0;
+ $_os = '';
+ if ($_useragent != '' && get_cfg_var('browscap')) {
+
+ $browser_detect = get_browser($_useragent, true);
+ $detect = New Mobile_Detect();
+ $detect->setUserAgent($_useragent);
+
+ // Detect browserja
+ if ($browser_detect['browser'] == 'Default Browser')
+ $_browser = self::$lang['srv_para_graph_other'];
+ else
+ $_browser = $browser_detect['browser'] . ' ' . $browser_detect['version'];
+
+ // Detect naprave (pc, mobi, tablet, robot)
+ if ($detect->isMobile()) {
+ if ($detect->isTablet())
+ $_device = 2;
+ else
+ $_device = 1;
+ } elseif ($browser_detect['crawler'] == 1)
+ $_device = 3;
+ else
+ $_device = 0;
+
+ // Detect operacijskega sistema
+ if ($browser_detect['platform'] == 'unknown')
+ $_os = self::$lang['srv_para_graph_other'];
+ else
+ $_os = $browser_detect['platform'];
+ }
+
+ $recnum = 0;
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ $s = sisplet_query("UPDATE srv_user SET recnum = MAX_RECNUM('" . get('anketa') . "'), time_insert=" . $_time_insert . ", language='" . get('language') . "', ip='" . $_ip . "', useragent='" . $_useragent . "', device='" . $_device . "', browser='" . $_browser . "', os='" . $_os . "' WHERE id = '" . get('usr_id') . "'");
+ if (!$s) {
+ echo 'err3432' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+
+ // Preverimo, ce je ze koncal anketo (in se kasneje vrnil), ce lahko se ureja svoje odgovore
+ if ($rowa['return_finished'] == 0) {
+ $sqls = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id='" . get('usr_id') . "'");
+ $rows = mysqli_fetch_array($sqls);
+
+ if ($rows['status'] == 6) { // Koncal anketo
+ Header::getInstance()->header();
+ Body::getInstance()->displayKonec();
+
+ die();
+ }
+ }
+
+
+ // ce ze ima kuki in ni poslana grupa pomeni, da se je vrnil se enkrat resevat anketo
+ if (!isset($_GET['grupa'])) {
+ Check::getInstance()->check_cookie_return();
+ }
+
+ }
+ else { // koda ne obstaja
+
+ //#TODO Tukaj preverimo userja iz novih e-mail vabil
+
+ if ($rowa['usercode_skip'] != 1 && !($_GET['preview'] == 'on' && isset($_GET['disablecode']) && $_GET['disablecode'] == 1)) {
+
+ // Pri Ne in Samo avtor prikazemo obvestilo, pri Da spustimo naprej in kreiramo nov cookie
+ SurveySetting::getInstance()->init(get('anketa'));
+ $srv_wrongcode = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_wrongcode' . $_lang);
+ if ($srv_wrongcode == '') $srv_wrongcode = self::$lang['srv_wrongcode'];
+
+ Display::getInstance()->displayNapaka($srv_wrongcode);
+ die();
+ }
+ }
+
+ } else {
+
+ # če imamo formo
+ if ($rowa['survey_type'] == 1) {
+ # TODO.. Mitja, tu je treba vse pravilno pohandlat.. men se niti sanja ne kak in kaj
+ # problem pri formi je da ko enkrat pošlješ email vabilo, potem vedno prikazuje header
+ // TODO: kolk casa je ze tole tukaj? :) -mitja
+ # TODO: ziher več kot leto in pol. :) tak da ni neskončno pomembno
+ }
+ else {
+
+ // baza respondentov - ce ni poslana koda
+ Language::getInstance()->multilang_init();
+ Header::getInstance()->header();
+ Body::getInstance()->displayIntroduction();
+
+ die();
+ }
+ }
+
+ }
+
+ // drugace gremo kreirat nov cookie
+ if (get('usr_id') == null) {
+
+ // izberemo random hash, ki se ni v bazi
+ do {
+ $rand = md5(mt_rand(1, mt_getrandmax()) . '@' . Helper::remote_address());
+ $sql = sisplet_query("SELECT id FROM srv_user WHERE cookie = '$rand'");
+ } while (mysqli_num_rows($sql) > 0);
+
+ $this->set_cookie('survey-' . get('anketa'), $rand, $this->expire);
+
+ // ce je izbrana povezava s sisplet userjem, ga povezemo
+ if ($rowa['user_from_cms'] >= 1) {
+ $sqlu = Model::db_select_user(self::$global_user_id);
+ $rowu = mysqli_fetch_array($sqlu);
+ } else
+ $rowu['id'] = 0;
+
+ if (isset($_GET['preview']) && $_GET['preview'] == 'on') {
+ $preview = 1;
+ } else {
+ $preview = 0;
+ }
+ # če smo v prezentaciji (slideshow) in ne beležimo vnosov jih označimo kot preview = 1
+ if (isset($rowa['slideshow']) && $rowa['slideshow'] == 1) {
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+ # če beležimo vnose: save_entries == 1
+ if ($ss_setings['save_entries'] == 0) {
+ $preview = 1;
+ }
+ }
+
+ $testdata = 0;
+ if (isset($_GET['testdata']) && $_GET['testdata'] == 'on') {
+ $preview = 0;
+ $testdata = 1;
+ }
+
+
+ if (isset($_POST['referer']))
+ $referer = $_POST['referer'];
+ elseif (isset($_SERVER['HTTP_REFERER']))
+ $referer = $_SERVER['HTTP_REFERER'];
+ else
+ $referer = 0;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $ip = SurveySetting::getInstance()->getSurveyMiscSetting('survey_ip');
+ $browser = SurveySetting::getInstance()->getSurveyMiscSetting('survey_browser');
+ $referal = SurveySetting::getInstance()->getSurveyMiscSetting('survey_referal');
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+
+ if ($ip == 0) $_ip = Helper::remote_address(); else $ip = "";
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+ if ($referal == 0) $_referer = $referer; else $_referer = '';
+ if ($browser == 0) $_useragent = $_SERVER['HTTP_USER_AGENT']; else $_useragent = '';
+
+ // Ce dovolimo useragent in ce je instaliran browscap
+ $_browser = '';
+ $_device = 0;
+ $_os = '';
+ if ($_useragent != '' && get_cfg_var('browscap')) {
+
+ $browser_detect = get_browser($_useragent, true);
+ $detect = New Mobile_Detect();
+ $detect->setUserAgent($_useragent);
+
+ // Detect browserja
+ if ($browser_detect['browser'] == 'Default Browser')
+ $_browser = self::$lang['srv_para_graph_other'];
+ else
+ $_browser = $browser_detect['browser'] . ' ' . $browser_detect['version'];
+
+ // Detect naprave (pc, mobi, tablet, robot)
+ if ($detect->isMobile()) {
+ if ($detect->isTablet())
+ $_device = 2;
+ else
+ $_device = 1;
+ } elseif ($browser_detect['crawler'] == 1)
+ $_device = 3;
+ else
+ $_device = 0;
+
+ // Detect operacijskega sistema
+ if ($browser_detect['platform'] == 'unknown')
+ $_os = self::$lang['srv_para_graph_other'];
+ else
+ $_os = $browser_detect['platform'];
+ }
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ $recnum = 0;
+
+ $sql = sisplet_query("INSERT INTO srv_user (id, ank_id, preview, testdata, cookie, user_id, ip, time_insert, recnum, referer, useragent, device, browser, os, language) VALUES (0, '" . get('anketa') . "', '$preview', '$testdata', '$rand', '$rowu[id]', '" . $_ip . "', " . $_time_insert . ", MAX_RECNUM('" . get('anketa') . "'), '" . $_referer . "', '" . $_useragent . "', '" . $_device . "', '" . $_browser . "', '" . $_os . "', '" . get('language') . "')");
+ if (!$sql) {
+ echo 'err3431' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ save('usr_id', mysqli_insert_id($GLOBALS['connect_db']), 1);
+
+
+ //sisplet_query("COMMIT");
+ # če je testni vnos in če že imamo skreirano datoteko s podatki v kateri še ni označeno da imamo testem je potrebno generirati na novo
+ if ((int)$testdata > 0) {
+ $head_file_name = self::$site_path . 'admin/survey/SurveyData/export_header_' . get('anketa') . '.dat';
+ if (file_exists($head_file_name)) {
+ $header = unserialize(file_get_contents($head_file_name));
+ if ((int)$header['_settings']['hasTestData'] == 0) {
+ unlink($head_file_name);
+ }
+ }
+ }
+
+ //potrebuje se za modul MAZA - za povezavo respondenta med tebelama maza_app_users in srv_user
+ if(SurveyInfo::checkSurveyModule('maza')){
+ //error_log(json_encode($_GET));
+ $maza = new MAZA(get('anketa'));
+ //check if id and identifier match
+ if($_GET['maza_user_id'] && ($maza->maza_validate_user($_GET['maza_user_id'], $_GET['maza_identifier']))){
+ //update last_active of user
+ $maza->maza_update_user_active($_GET['maza_user_id']);
+ //insert pair of users id's in DB table
+ $maza->maza_save_srv_user($_GET['maza_user_id'], get('usr_id'), $_GET['maza_srv_version'], $_GET['maza_tgeofence_id'], $_GET['maza_tactivity_id'], $_GET['maza_mode']);
+ }
+ }
+
+ // EVALVACIJA - Ce je nov respondent se to zapise v posebno tabelo, da ga prepoznamo naslednjic brez cookija (da lahko nadaljuje kjer je ostal)
+ if (Common::checkModule('evalvacija') == '1') {
+ $student = (isset($_GET['sifstud'])) ? $_GET['sifstud'] : 0;
+ $predmet = (isset($_GET['sifpredm'])) ? $_GET['sifpredm'] : -1; // Ce resuje splosno anketo ni predmeta -> predmet = -1
+
+ if ($student > 0)
+ sisplet_query("INSERT INTO eval_data_userCookie (ank_id, usr_id, student, predmet) VALUES ('" . get('anketa') . "', '" . get('usr_id') . "', '" . $student . "', '" . $predmet . "')");
+ }
+
+ // V kolikor gre za hierarhijo in je respondent učitelj, potem usr_id shranimo, da lahko obnovimo anketo
+ if (Common::checkModule('hierarhija') == '1' && SurveyInfo::checkSurveyModule('hierarhija') == 2) {
+ $url = base64_decode(urldecode($this->get->enc));
+ $polje = sisplet_query("SELECT koda, vloga FROM srv_hierarhija_koda WHERE url='" . $url . "'", "obj");
+
+ if ($polje->vloga == 'ucitelj')
+ sisplet_query("UPDATE srv_hierarhija_koda SET srv_user_id='" . get('usr_id') . "' WHERE url='" . $url . "'");
+
+ // V kolikor gre za super šifro potem shranimo v bazo, uporabnika in katero anketo je reševal.
+ if (!empty($this->get->supersifra)) {
+ $kode = sisplet_query("SELECT kode FROM srv_hierarhija_supersifra WHERE koda='".$this->get->supersifra."'", "obj");
+ $kode = unserialize($kode->kode);
+
+ sisplet_query("INSERT INTO
+ srv_hierarhija_supersifra_resevanje
+ (user_id, supersifra, koda, status)
+ VALUES
+ ('".get('usr_id')."', '".$this->get->supersifra."', '".$kode[$this->get->resujem]."', 1)
+ ");
+
+ }
+
+ }
+ }
+ }
+
+ /**
+ * nastavi cookie, oz. v primeru ankete brez cookieja, nastavi spremenljivko za url
+ */
+ protected $anketa, $rand, $expire;
+
+ private function set_cookie($anketa, $rand, $expire)
+ {
+
+ $cookie_ok = isset($_COOKIE['cookie_ok']) ? $_COOKIE['cookie_ok'] : '';
+
+ // ce je nastavljeno na brez piskotka ali se ni potrdil shranjevanja piskotkov
+ if (get('cookie_expire') == -1 or $cookie_ok != 1) { // cookie prenasamo preko URLja
+ save('cookie_url', '&' . $anketa . '=' . $rand); // ta string se bo dodal vsem URLjem na konec
+ // &amp; dodamo naknadno samo tam, kjer se pise v html (v header() more bit samo &)
+ } else {
+ setcookie($anketa, $rand, $expire); // ce je cookie, ga obicajno nastavimo
+ }
+ }
+
+ /**
+ * @desc nastavi status za trenutnega userja
+ */
+ private function set_userstatus($status)
+ {
+ $sql_userbase = sisplet_query("SELECT MAX(tip) AS tip FROM srv_userbase WHERE usr_id = '" . get('usr_id') . "'");
+ if (!$sql_userbase) echo mysqli_error($GLOBALS['connect_db']);
+ $row_userbase = mysqli_fetch_array($sql_userbase);
+
+ if ($row_userbase['tip'] > 0) {
+ $tip = $row_userbase['tip'];
+ }
+ else {
+ $tip = 0;
+ }
+
+ $sqlu = sisplet_query("SELECT MAX(status) AS status FROM srv_userstatus WHERE usr_id = '" . get('usr_id') . "'");
+ if (!$sqlu) echo mysqli_error($GLOBALS['connect_db']);
+ $rowu = mysqli_fetch_array($sqlu);
+
+ $sqlu = sisplet_query("SELECT inv_res_id FROM srv_user WHERE id = '" . get('usr_id') . "' AND inv_res_id IS NOT NULL");
+ $inv_res_id = null;
+ if (mysqli_num_rows($sqlu) > 0) {
+ # userj je dodan preko novih vabil zato updejtamo status še tam
+ $row_inv_res_id = mysqli_fetch_assoc($sqlu);
+ $inv_res_id = (int)$row_inv_res_id['inv_res_id'];
+ }
+
+ // spremenimo tip
+ if ($status > $rowu['status'] && is_numeric(get('usr_id'))) {
+
+ $s = sisplet_query("REPLACE INTO srv_userstatus (usr_id, tip, status, datetime) VALUES ('" . get('usr_id') . "', '$tip', '$status', NOW())");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ $s = sisplet_query("UPDATE srv_user SET last_status = '$status', time_edit = " . $_time_insert . ", language='" . get('language') . "' WHERE id = '" . get('usr_id') . "'");
+ if (!$s) {
+ echo mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ # updejtamo še status pri respondentih.
+ if ((int)$inv_res_id > 0) {
+ # userj je dodan preko novih vabil zato updejtamo status še tam
+ $sqlString = "UPDATE srv_invitations_recipients SET last_status='$status' WHERE ank_id='" . get('anketa') . "' AND id ='$inv_res_id' ";
+ $u = sisplet_query($sqlString);
+ }
+
+ // updatamo samo datum - tip se ni spremenil
+ } else {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', self::$lang['id']);
+
+ # osvežimo datum spremembe
+ sisplet_query("UPDATE srv_user SET time_edit = " . $_time_insert . ", language='" . get('language') . "' WHERE id='" . get('usr_id') . "'");
+
+ }
+
+ // Ce ne belezimo parapodatka za cas responsa, anonimno zabelezimo cas zadnjega responsa
+ if(SurveySetting::getInstance()->getSurveyMiscSetting('survey_date') == 1) {
+ sisplet_query("UPDATE srv_anketa SET last_response_time=NOW() WHERE id='".get('anketa')."'");
+ }
+
+ # dodamo še tracking arhivov vabil
+ if (get('user_inv_archive') > 0 && $inv_res_id > 0) {
+
+ # ignoriramo podvojene kluče
+ $s = sisplet_query("INSERT IGNORE INTO srv_invitations_tracking
+ (inv_arch_id, time_insert, res_id, status)
+ VALUES
+ ('" . (int)get('user_inv_archive') . "',NOW(),'$inv_res_id','$status')
+ ");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+ }
+ else {
+ }
+
+ # potrebno bo osvežit seznam anket
+ Model::setUpdateSurveyList();
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/JsController.php b/main/survey/app/Controllers/JsController.php
new file mode 100644
index 0000000..c9699f8
--- /dev/null
+++ b/main/survey/app/Controllers/JsController.php
@@ -0,0 +1,2835 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 08.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Models\Model;
+use Cache;
+use enkaParameters;
+use Mobile_Detect;
+use SurveyAdvancedParadataLog;
+use SurveyInfo;
+use SurveySetting;
+use SurveySlideshow;
+use Common;
+use SurveyPanel;
+
+class JsController extends Controller
+{
+
+ public function __construct($var = null)
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new JsController();
+ }
+
+ // izpise kodo za JS sledenje, ce je nastavljena
+ public static function js_tracking()
+ {
+
+ $row = SurveyInfo::getSurveyRow();
+
+ if ($row['js_tracking'] != '') {
+ echo '<!-- JS tracking code -->';
+ echo $row['js_tracking'];
+ echo '<!-- / JS tracking code -->';
+ }
+
+ }
+
+ /**
+ * @desc generira JavaScript za alert pri vprasanjih z reminderjem
+ */
+ public function generateSubmitJS()
+ {
+ global $lang;
+ global $site_url;
+ global $secret_captcha;
+ global $admin_type;
+
+ // Dodaten text pri alertu ce smo v testnem vnosu
+ $test_alert = (isset($_GET['testdata']) && $_GET['testdata'] == 'on') ? '\n\n' . $lang['srv_remind_preview'] : '';
+
+ // Custom texti za opozorila...
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_remind_sum_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_sum_hard' . $_lang);
+ if ($srv_remind_sum_hard == '') $srv_remind_sum_hard = $lang['srv_remind_sum_hard'];
+ $srv_remind_sum_hard = strip_tags(addslashes(stripslashes($srv_remind_sum_hard))).$test_alert;
+ $srv_remind_sum_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_sum_soft' . $_lang);
+ if ($srv_remind_sum_soft == '') $srv_remind_sum_soft = $lang['srv_remind_sum_soft'];
+ $srv_remind_sum_soft = strip_tags(addslashes(stripslashes($srv_remind_sum_soft))).$test_alert;
+ $srv_remind_num_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_num_hard' . $_lang);
+ if ($srv_remind_num_hard == '') $srv_remind_num_hard = $lang['srv_remind_num_hard'];
+ $srv_remind_num_hard = strip_tags(addslashes(stripslashes($srv_remind_num_hard))).$test_alert;
+ $srv_remind_num_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_num_soft' . $_lang);
+ if ($srv_remind_num_soft == '') $srv_remind_num_soft = $lang['srv_remind_num_soft'];
+ $srv_remind_num_soft = strip_tags(addslashes(stripslashes($srv_remind_num_soft))).$test_alert;
+
+ $srv_remind_text_num_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_text_num_hard' . $_lang);
+ if ($srv_remind_text_num_hard == '') $srv_remind_text_num_hard = $lang['srv_remind_text_num_hard'];
+ $srv_remind_text_num_hard = strip_tags(addslashes(stripslashes($srv_remind_text_num_hard))).$test_alert;
+ $srv_remind_text_num_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_text_num_soft' . $_lang);
+ if ($srv_remind_text_num_soft == '') $srv_remind_text_num_soft = $lang['srv_remind_text_num_soft'];
+ $srv_remind_text_num_soft = strip_tags(addslashes(stripslashes($srv_remind_text_num_soft))).$test_alert;
+
+ //za minimalno stevilo izbranih checkbox-ov
+ $srv_remind_checkbox_min_violated_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_checkbox_min_violated_hard' . $_lang);
+ if ($srv_remind_checkbox_min_violated_hard == '') $srv_remind_checkbox_min_violated_hard = $lang['srv_remind_checkbox_min_violated_hard'];
+ $srv_remind_checkbox_min_violated_hard = strip_tags(addslashes(stripslashes($srv_remind_checkbox_min_violated_hard))).$test_alert;
+
+ $srv_remind_checkbox_min_violated_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_checkbox_min_violated_soft' . $_lang);
+ if ($srv_remind_checkbox_min_violated_soft == '') $srv_remind_checkbox_min_violated_soft = $lang['srv_remind_checkbox_min_violated_soft'];
+ $srv_remind_checkbox_min_violated_soft = strip_tags(addslashes(stripslashes($srv_remind_checkbox_min_violated_soft))).$test_alert;
+ //za minimalno stevilo izbranih checkbox-ov - konec
+
+ $srv_remind_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard' . $_lang);
+ if ($srv_remind_hard == '') $srv_remind_hard = $lang['srv_remind_hard'];
+ $srv_remind_hard = strip_tags(addslashes(stripslashes($srv_remind_hard))).$test_alert;
+ $srv_remind_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft' . $_lang);
+ if ($srv_remind_soft == '') $srv_remind_soft = $lang['srv_remind_soft'];
+ $srv_remind_soft = strip_tags(addslashes(stripslashes($srv_remind_soft))).$test_alert;
+
+ $srv_remind_hard_99 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-99' . $_lang);
+ if ($srv_remind_hard_99 == '') $srv_remind_hard_99 = $lang['srv_remind_hard_-99'];
+ $srv_remind_hard_99 = strip_tags(addslashes(stripslashes($srv_remind_hard_99))).$test_alert;
+ $srv_remind_soft_99 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-99' . $_lang);
+ if ($srv_remind_soft_99 == '') $srv_remind_soft_99 = $lang['srv_remind_soft_-99'];
+ $srv_remind_soft_99 = strip_tags(addslashes(stripslashes($srv_remind_soft_99))).$test_alert;
+ $srv_remind_hard_98 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-98' . $_lang);
+ if ($srv_remind_hard_98 == '') $srv_remind_hard_98 = $lang['srv_remind_hard_-98'];
+ $srv_remind_hard_98 = strip_tags(addslashes(stripslashes($srv_remind_hard_98))).$test_alert;
+ $srv_remind_soft_98 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-98' . $_lang);
+ if ($srv_remind_soft_98 == '') $srv_remind_soft_98 = $lang['srv_remind_soft_-98'];
+ $srv_remind_soft_98 = strip_tags(addslashes(stripslashes($srv_remind_soft_98))).$test_alert;
+ $srv_remind_hard_97 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_-97' . $_lang);
+ if ($srv_remind_hard_97 == '') $srv_remind_hard_97 = $lang['srv_remind_hard_-97'];
+ $srv_remind_hard_97 = strip_tags(addslashes(stripslashes($srv_remind_hard_97))).$test_alert;
+ $srv_remind_soft_97 = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_-97' . $_lang);
+ if ($srv_remind_soft_97 == '') $srv_remind_soft_97 = $lang['srv_remind_soft_-97'];
+ $srv_remind_soft_97 = strip_tags(addslashes(stripslashes($srv_remind_soft_97))).$test_alert;
+ $srv_remind_hard_multi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_hard_multi' . $_lang);
+ if ($srv_remind_hard_multi == '') $srv_remind_hard_multi = $lang['srv_remind_hard_multi'];
+ $srv_remind_hard_multi = strip_tags(addslashes(stripslashes($srv_remind_hard_multi))).$test_alert;
+ $srv_remind_soft_multi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_soft_multi' . $_lang);
+ if ($srv_remind_soft_multi == '') $srv_remind_soft_multi = $lang['srv_remind_soft_multi'];
+ $srv_remind_soft_multi = strip_tags(addslashes(stripslashes($srv_remind_soft_multi))).$test_alert;
+
+ $srv_remind_captcha_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_captcha_soft' . $_lang);
+ if ($srv_remind_captcha_soft == '') $srv_remind_captcha_soft = $lang['srv_remind_captcha_soft'];
+ $srv_remind_captcha_soft = strip_tags(addslashes(stripslashes($srv_remind_captcha_soft))).$test_alert;
+ $srv_remind_captcha_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_captcha_hard' . $_lang);
+ if ($srv_remind_captcha_hard == '') $srv_remind_captcha_hard = $lang['srv_remind_captcha_hard'];
+ $srv_remind_captcha_hard = strip_tags(addslashes(stripslashes($srv_remind_captcha_hard))).$test_alert;
+
+ $srv_remind_email_soft = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_email_soft' . $_lang);
+ if ($srv_remind_email_soft == '') $srv_remind_email_soft = $lang['srv_remind_email_soft'];
+ $srv_remind_email_soft = strip_tags(addslashes(stripslashes($srv_remind_email_soft))).$test_alert;
+ $srv_remind_email_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_remind_email_hard' . $_lang);
+ if ($srv_remind_email_hard == '') $srv_remind_email_hard = $lang['srv_remind_email_hard'];
+ $srv_remind_email_hard = strip_tags(addslashes(stripslashes($srv_remind_email_hard))).$test_alert;
+
+ $srv_alert_number_toobig = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_alert_number_toobig' . $_lang);
+ if ($srv_alert_number_toobig == '') $srv_alert_number_toobig = $lang['srv_alert_number_toobig'];
+ $srv_alert_number_toobig = strip_tags(addslashes(stripslashes($srv_alert_number_toobig))).$test_alert;
+ $srv_alert_number_exists = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_alert_number_exists' . $_lang);
+ if ($srv_alert_number_exists == '') $srv_alert_number_exists = $lang['srv_alert_number_exists'];
+ $srv_alert_number_exists = strip_tags(addslashes(stripslashes($srv_alert_number_exists))).$test_alert;
+
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ $srv_remind_checkbox_max_violated_hard = SurveySetting::getInstance()->getSurveyMiscSetting('srv_remind_checkbox_max_violated_hard' . $_lang);
+ if ($srv_remind_checkbox_max_violated_hard == '') $srv_remind_checkbox_max_violated_hard = $lang['srv_remind_checkbox_max_violated_hard'];
+ $srv_remind_checkbox_max_violated_hard = strip_tags(addslashes(stripslashes($srv_remind_checkbox_max_violated_hard))).$test_alert;
+
+
+ echo ' <script> ' . "\n";
+
+ ?>
+ var lang_srv_alert_number_exists = "<?= $srv_alert_number_exists ?>";
+ var lang_srv_alert_number_toobig = "<?= $srv_alert_number_toobig ?>";
+ var lang_srv_remind_checkbox_max_violated_hard = "<?= $srv_remind_checkbox_max_violated_hard ?>";
+ <?
+
+ $survey_hint = SurveySetting::getInstance()->getSurveyMiscSetting('survey_hint');
+ if ($survey_hint == '') $survey_hint = 1;
+
+ echo ' // generateSubmitJS() ' . "\n";
+ ?>
+ function submitAlert (id, action, type, bol, validation, txt, alert_sum, alert_num, alert_validation) {
+
+ if (validation == true) {
+
+ if (<?= $survey_hint ?> == 1) {
+
+ // pri tabelah izberemo celo spremenljivko
+ if ( ! $(id).hasClass('spremenljivka') ) {
+ id = '#' + $(id).closest('.spremenljivka')[0].id;
+ }
+
+ if (type == 'require' || type == 'require2' || type == 'require3' || type == 'require4' || type == 'require5') {
+ if ( $(id)[0].getAttribute('data-vrstni_red') >= max_vrstni_red ) return;
+ } else {
+ if ( $(id)[0].getAttribute('data-vrstni_red') > max_vrstni_red ) return;
+ }
+
+ var text;
+ if (type == 'require')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard) ?>';
+ if (type == 'require2')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_99) ?>';
+ if (type == 'require3')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_98) ?>';
+ if (type == 'require4')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_97) ?>';
+ if (type == 'require5')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_hard_multi) ?>';
+ if (type == 'limit')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_num_hard) ?>';
+ if (type == 'text_limit')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_text_num_hard) ?>';
+ if (type == 'validation')
+ text = txt;
+ if (type == 'checkbox_min_limit')
+ text = '<?= str_replace('\n', '<br />', $srv_remind_checkbox_min_violated_hard) ?>';
+
+ if (action == 'add') {
+ if ($(id+' div.validation_alert.'+type+'').length == 0){
+
+ $(id).append('<div class="validation_alert '+type+'">'+text+'</div>');
+
+ // Ce je opozorilo izven ekrana (ozki ekran, mobitel, tablica...) ga prikazemo na desni
+ $('div.validation_alert').each(function(){
+ if($(this).offset().left < 0){
+ $(this).addClass('alignRight');
+ }
+ });
+ }
+ showMissing(id);
+ }
+ else {
+ $(id+' div.validation_alert.'+type+'').remove();
+ }
+ }
+ }
+ else {
+ if (action == 'add') {
+ $(id).addClass('required_'+type);
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo opozorilo
+ <?if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){?>
+ dodaj_opozorilo(alert_sum, alert_num, alert_validation, bol, id);
+ <?}?>
+
+ showMissing(id);
+ }
+ else {
+ $(id).removeClass('required_'+type);
+ }
+ }
+ }
+
+ function isEmail(email) {
+ var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
+ return regex.test(email);
+ }
+
+ function showMissing(id) {
+ $(id).find('.missing').slideDown();
+ }
+ <?
+
+ echo ' function submitForm(parent_if, validation) { ' . "\n";
+ echo ' if (is_paused_slideshow == true) return false' . "\n";
+ echo ' var hard = true; ' . "\n";
+ echo ' var soft = true; ' . "\n";
+ echo ' var vsota = true; ' . "\n";
+ echo ' var num = true; ' . "\n";
+ echo ' var text_num = true; ' . "\n";
+ echo ' var checkbox_min_limit_alert = false; ' . "\n";
+
+
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND gru_id != '0' AND reminder > 0 ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ echo ' try { ' . "\n";
+
+ // katero spremenljivko bomo nastavili
+ if ($row['reminder'] == 1) {
+ $bol = 'soft';
+ } else {
+ $bol = 'hard';
+ }
+
+ // ce prikazujemo naknadno vec moznosti (recimo nevem in neustrezno)
+ if (($row['alert_show_99'] == 1 && $row['alert_show_98'] == 1) || ($row['alert_show_99'] == 1 && $row['alert_show_97'] == 1) || ($row['alert_show_98'] == 1 && $row['alert_show_97'] == 1)) {
+ $require = 'require5';
+ } // ce prikazujemo naknadno ne vem
+ elseif ($row['alert_show_99'] == 1) {
+ $require = 'require2';
+ } // ce prikazujemo naknadno zavrnil
+ elseif ($row['alert_show_98'] == 1) {
+ $require = 'require3';
+ } // ce prikazujemo naknadno neustrezno
+ elseif ($row['alert_show_97'] == 1) {
+ $require = 'require4';
+ } else {
+ $require = 'require';
+ }
+
+ // najprej damo pogoj, da se uposteva, samo ce je vprasanje vidno (ker je lahko v ifu)
+ //echo ' if ( $(\'#spremenljivka_'.$row['id'].'\').css(\'display\') != \'none\' ) { '."\n";
+ echo ' if ( document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
+
+ // radio in checkbox
+ if ($row['tip'] <= 2 && ($row['orientation'] != 8 || get('mobile') == 1)) {
+
+ if ($row['tip'] == 1)
+ $ime = 'vrednost_' . $row['id'];
+ else
+ $ime = 'vrednost_' . $row['id'] . '[]';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+
+ echo ' var bol = false; ' . "\n";
+
+ // ce je samo 1 (spodnja procedura ne prime, je treba posebej)
+ echo ' if (len == undefined) { ' . "\n";
+
+ echo ' if (obj.checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ // sicer gremo normalno čez vse
+ //preureditev za pregled textboxa za drugo
+ echo ' } else { ' . "\n";
+
+ echo ' var bolTextBox = [] ' . "\n"; //polje, ki shranjuje info o boolean za "drugo"
+
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked){ ' . "\n"; //ce je odgovor izbran
+ echo ' bol = true; ' . "\n";
+
+ //urejanje za textbox za drugo
+ echo ' var drugo_temp = obj[i].id.replace("vrednost", "textfield"); ' . "\n";
+ echo ' if($("#"+drugo_temp).length){ ' . "\n";
+ echo ' var drugo_text_empty = true; ' . "\n";
+ echo ' if($("#"+drugo_temp).val() != ""){ ' . "\n";
+ echo ' drugo_text_empty = false; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' if (drugo_text_empty){ ' . "\n";
+ echo ' bolTextBox[i] = false; ' . "\n";
+ echo ' }else{ ' . "\n";
+ echo ' bolTextBox[i] = true; ' . "\n";
+ echo ' } ' . "\n";
+
+ echo ' } ' . "\n";
+ //urejanje za textbox za drugo - konec
+ echo ' } ' . "\n"; //konec if (obj[i].checked)
+ echo ' } ' . "\n"; //konec for
+
+ //ce polje za textbox "drugo" ni prazno, ustrezno uredi spremenljivko bol
+ echo ' if(bolTextBox.indexOf(false)>0){ ' . "\n";
+ echo ' bol = false; ' . "\n";
+ echo ' } ' . "\n";
+ //ce polje za textbox "drugo" ni prazno, ustrezno uredi spremenljivko bol - konec
+
+
+ echo ' } ' . "\n";
+ //preureditev za pregled textboxa za drugo - konec
+
+
+ // Posebna funkcionalnost za ministrstvo za obrambo, ker se mudi (q5,q6,q8,q9,q11,q14)
+ if($site_url == 'https://www.1ka.si/' && get('anketa') == '180402' && in_array($row['id'], array('10654896', '10654916', '10668668', '10677046', '10668603', '10657205'))){
+
+ // Minimalno št. checkboxov (3 oz. 5)
+ if(in_array($row['id'], array('10654896', '10654916', '10668668', '10677046'))){
+ $cnt_special = ($row['id'] == '10668668') ? 5 : 3;
+
+ echo ' var cnt_special = 0; ' . "\n";
+
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked) ' . "\n";
+ echo ' cnt_special ++; ' . "\n";
+ echo ' } ' . "\n";
+
+ echo ' if (cnt_special != '.$cnt_special.') ' . "\n";
+ echo ' bol = false; ' . "\n";
+ }
+
+ // Kliknil drugo brez vnosa v text polje
+ if(in_array($row['id'], array('10654896', '10668603', '10657205'))){
+
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked){ ' . "\n";
+ echo ' var drugo_temp = obj[i].id.replace("vrednost", "textfield"); ' . "\n";
+ echo ' if($("#"+drugo_temp).length){ ' . "\n";
+
+ echo ' var drugo_text_empty = true; ' . "\n";
+
+ echo ' if($("#"+drugo_temp).val() != "") ' . "\n";
+ echo ' drugo_text_empty = false; ' . "\n";
+
+ echo ' if (drugo_text_empty) ' . "\n";
+ echo ' bol = false; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+
+
+ echo ' if (!bol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' }' . "\n";
+
+ }
+ //drag and drop - kategorije en in vec odgovorov
+ if ($row['tip'] <= 2 && ($row['orientation'] == 8 && get('mobile') != 1)) {
+ $ime = 'vrednost_' . $row['id'];
+ echo '
+ var bol = false;
+ var prisotno = $("#half2_frame_dropping_' . $row['id'] . '").children("div").attr("value");
+ if (prisotno){
+ bol = true;
+ }
+ if (!bol) {
+ ' . $bol . ' = false;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }
+ ';
+
+
+ // dropdown
+ } elseif ($row['tip'] == 3) {
+
+ $ime = 'vrednost_' . $row['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ } //tabele @ drag and drop
+ elseif (($row['tip'] == 6 && $row['enota'] == 9) || ($row['tip'] == 16 && $row['enota'] == 9)) {
+ echo '
+ //console.log("Drag and drop Tabela en odgovorov");
+ var bol = true;
+ var prisotno = $("#half_frame_dropping_' . $row['id'] . '").children("div").attr("value");
+ if (prisotno){
+ bol = false;
+ }
+ if (!bol) {
+ ' . $bol . ' = false;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
+ }
+
+
+ ';
+
+ // tabele
+ //} elseif ($row['tip'] == 6 || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20) {
+ } elseif (($row['tip'] == 6 && $row['enota'] != 9) || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20) {
+
+ echo ' var totalbol = true; ';
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' AND other!='1' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ // Pri postopnem resevanju multigrida tega nimamo, ker drugace ne dela ok (ker deluje na principu da so vse vrstice razen tekoce display:none;)
+ if ($row['dynamic_mg'] == 0) {
+ echo ' if ( document.getElementById(\'vrednost_if_' . $row1['id'] . '\').style.display != \'none\' ) { ' . "\n";
+ }
+
+ // dropdown
+ if ($row['enota'] == 2) { // zakaj je tole? pride do bugov, ce je ostala enota nastavljena na ostalih tipih
+
+ // todo
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+
+ // multi radio
+ //} elseif ($row['tip'] == 6) {
+ } elseif ($row['tip'] == 6 && $row['enota'] != 9) {
+
+ $ime = 'vrednost_' . $row1['id'];
+
+ // Pri postopnem resevanju moramo skrite z ifom posebej izlociti iz preverjanja
+ if ($row['dynamic_mg'] != 0) {
+ echo ' if( !$(\'#vrednost_if_' . $row1['id'] . '\').hasClass(\'if_hide\') ){ ' . "\n";
+ }
+
+ //echo 'console.log("Klasična tabela!"); ';
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+ echo ' var bol = false; ' . "\n";
+
+ // ce je samo 1 (spodnja procedura ne prime, je treba posebej)
+ echo ' if (len == undefined) { ' . "\n";
+
+ echo ' if (obj.checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ // sicer gremo normalno čez vse
+ echo ' } else { ' . "\n";
+
+ echo ' for (i=0; i<len; i++) ' . "\n";
+ echo ' if (obj[i].checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ // Pri dvojnih tabelah moramo posebej preverjati se desno stran
+ echo ' var bol2 = true; ' . "\n";
+ if ($row['enota'] == 3) {
+ $ime2 = 'vrednost_' . $row1['id'].'_part_2';
+
+ echo ' var obj2 = document.forms[\'vnos\'].elements[\'' . $ime2 . '\']; ' . "\n";
+ echo ' var len2 = obj2.length; ' . "\n";
+ echo ' var bol2 = false; ' . "\n";
+
+ echo ' for (i=0; i<len2; i++) ' . "\n";
+ echo ' if (obj2[i].checked) ' . "\n";
+ echo ' bol2 = true; ' . "\n";
+ }
+
+ echo ' if (!bol || !bol2) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // Pri postopnem resevanju moramo skrite z ifom posebej izlociti iz preverjanja
+ if ($row['dynamic_mg'] != 0) {
+ echo ' } ' . "\n";
+ }
+
+ // multicheck
+ //} elseif ($row['tip'] == 16) {
+ } elseif ($row['tip'] == 16 && $row['enota'] != 9) {
+
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var bol = false; ' . "\n";
+
+ echo ' for (var i=1; i<=' . $row['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.checked || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo ' if (!bol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // tabela besedilo in tabela number
+ } elseif ($row['tip'] == 19 || $row['tip'] == 20) {
+
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var bol = false; ' . "\n";
+
+ echo ' for (var i=1; i<=' . $row['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.value != "" || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo ' if (!bol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' totalbol = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ }
+
+ // Pri postopnem resevanju multigrida tega nimamo, ker drugace ne dela ok
+ if ($row['dynamic_mg'] == 0) {
+ echo ' } ' . "\n";;
+ }
+ }
+
+ echo ' if (validation) { ';
+ echo ' if (!totalbol) ';
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' else ';
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ';
+
+ // besedilo *
+ } elseif ($row['tip'] == 21) {
+
+ // captcha
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $captcha = ($spremenljivkaParams->get('captcha') ? $spremenljivkaParams->get('captcha') : 0);
+
+ if ($captcha == 1) {
+ ?>
+ var response = grecaptcha.getResponse();
+
+ if (response.gelgth != 0 || validation==true) {
+ // ok
+ }
+ else {
+ <?
+ if ($bol == 'soft') {
+ ?>
+ if (!confirm('<?=$srv_remind_captcha_soft?>'))
+ return;
+ <?
+ }
+ else {
+ ?>
+ alert('<?=$srv_remind_captcha_hard?>');
+ return;
+ <?
+ }
+ ?>
+ }
+ <?
+ }
+
+ //for ($i=0; $i<$row['text_kosov']; $i++) {
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $ime = 'vrednost_' . $row['id'] . '_kos_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "" && obj.disabled == false) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'validation\', \'' . $bol . '\', validation); ' . "\n";
+
+ // Email validation
+ $emailVerify = ($spremenljivkaParams->get('emailVerify') ? $spremenljivkaParams->get('emailVerify') : 0);
+ if ($emailVerify == 1) {
+ echo ' } else if(isEmail(obj.value) == false) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'validation\', \'' . $bol . '\', validation, \'' . ($bol == 'soft' ? $srv_remind_email_soft : $srv_remind_email_hard) . '\'); ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation); ' . "\n";
+
+ echo ' } else if(isEmail(obj.value) == true) { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'validation\', \'' . $bol . '\', validation, \'' . ($bol == 'soft' ? $srv_remind_email_soft : $srv_remind_email_hard) . '\'); ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation); ' . "\n";
+ }
+
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // textbox, compute, quota
+ } elseif ($row['tip'] == 4 || $row['tip'] == 22 || $row['tip'] == 25 || $row['tip'] == 8) {
+
+ $ime = 'vrednost_' . $row['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "" && obj.disabled == false) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // number
+ } elseif ($row['tip'] == 7) {
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost';
+
+ echo ' var obj1 = document.getElementById(\'' . $ime . '_1\'); ' . "\n";
+ if ($row['size'] == 2)
+ echo ' var obj2 = document.getElementById(\'' . $ime . '_2\'); ' . "\n";
+ if ($row['size'] == 1)
+ echo ' if (obj1.value == "" && obj1.disabled == false) { ' . "\n";
+ elseif ($row['size'] == 2)
+ echo ' if ((obj1.value == "" && obj1.disabled == false) || (obj2.value == "" && obj2.disabled == false)) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // razvrscanje - ostevilcevanje
+ elseif ($row['tip'] == 17 && ($row['design'] == 1 || get('mobile') > 0)) {
+
+ // max stevilo vnesenih vrednosti
+ $max = $row['ranking_k'];
+
+ // nimamo omejenega stevila vnosov (morajo biti vnesena vsa stevila)
+ if ($max == 0) {
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+ // imamo omejeno stevilo vnosov
+ else {
+ echo ' var count = ' . $max . '; ' . "\n";
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value != "") ' . "\n";
+ echo ' count --; ' . "\n";
+ }
+
+ echo ' if (count > 0) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+ // razvrscanje - prestavljanje
+ elseif ($row['tip'] == 17 && ($row['design'] == 0)) {
+
+ //max stevilo vnesenih vrednosti
+ $max = $row['ranking_k'];
+
+ //nimamo omejenega stevila vnosov (morajo biti vnesena vsa stevila)
+ if ($max == 0) {
+ $sql1 = sisplet_query("SELECT COUNT(id) FROM srv_vrednost WHERE spr_id='$row[id]'");
+ $row1 = mysqli_fetch_array($sql1);
+ $max = $row1['COUNT(id)'];
+ }
+
+ $ime = 'half2_' . $row['id'];
+ echo ' var count = $(\'#' . $ime . '\').children().size(); ' . "\n";
+
+ echo ' if (count < \'' . $max . '\') { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ // razvrscanje - heatmap
+ elseif ($row['tip'] == 17 && ($row['design'] == 3)) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]'");
+ while($row1 = mysqli_fetch_array($sql1)){
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ }
+
+ // vsota
+ elseif ($row['tip'] == 18) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id'];
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // sn
+ } elseif ($row['tip'] == 9) {
+
+ echo ' var obj = document.getElementById(\'txt1\'); ' . "\n";
+ echo ' if (obj.value == "") { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+
+ // kombinirana tabela
+ } elseif ($row['tip'] == 24) {
+
+ $first_spr = 0;
+
+ $sqlm = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grid_multiple gm WHERE s.id=gm.spr_id AND gm.parent = '$row[id]' ORDER BY gm.vrstni_red ASC");
+ $rowm = mysqli_fetch_array($sqlm);
+ $first_spr = $rowm['id'];
+
+ $sql1 = sisplet_query("SELECT id, vrstni_red FROM srv_vrednost WHERE spr_id='$first_spr' ORDER BY vrstni_red");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ // Preverjamo ce je if na trenutni vrstici
+ $vrednost = '';
+ $sqlVrednostIf = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' AND if_id>0 AND vrstni_red='".$row1['vrstni_red']."'");
+ if(mysqli_num_rows($sqlVrednostIf) > 0){
+ $rowVrednostIf = mysqli_fetch_array($sqlVrednostIf);
+ $vrednost = 'vrednost_if_' . $rowVrednostIf['id'];
+ }
+ echo ' if ( !$(\'#'.$vrednost.'\').length || document.getElementById(\'' . $vrednost . '\').style.display != \'none\' ) { ' . "\n";
+
+ echo ' var totalBol = true; ' . "\n";
+
+ mysqli_data_seek($sqlm, 0);
+ while ($rowm = mysqli_fetch_array($sqlm)) {
+
+ $sql2 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$rowm[id]' AND vrstni_red='$row1[vrstni_red]'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ // dropdown
+ if ($rowm['tip'] == 6 && $rowm['enota'] == 2) {
+
+ // todo
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = true; ' . "\n";
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' bol = false; ' . "\n";
+ echo ' }' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+ //selectbox
+ } elseif ($rowm['tip'] == 6 && $rowm['enota'] == 6) {
+
+ // todo
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = true; ' . "\n";
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj.value > 0) { ' . "\n";
+ echo ' bol = false; ' . "\n";
+ echo ' }' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ // multi radio
+ } elseif ($rowm['tip'] == 6) {
+
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = false; ' . "\n";
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+
+
+ // ce je samo 1 (spodnja procedura ne prime, je treba posebej)
+ echo ' if (len == undefined) { ' . "\n";
+
+ echo ' if (obj.checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ // sicer gremo normalno čez vse
+ echo ' } else { ' . "\n";
+
+ echo ' for (i=0; i<len; i++) ' . "\n";
+ echo ' if (obj[i].checked) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ // multicheck
+ } elseif ($rowm['tip'] == 16) {
+
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = false; ' . "\n";
+ echo ' for (var i=1; i<=' . $rowm['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.checked || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ // tabela besedilo in tabela number
+ } elseif ($rowm['tip'] == 19 || $rowm['tip'] == 20) {
+
+ $ime = 'multi_' . $rowm['id'] . '_' . $row2['id'];
+
+ echo ' var bol = false; ' . "\n";
+ echo ' for (var i=1; i<=' . $rowm['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ echo ' if (obj.value != "" || obj.disabled) ' . "\n";
+ echo ' bol = true; ' . "\n";
+
+ echo ' } ' . "\n";
+ echo ' if (bol==false) totalBol = false; ' . "\n";
+
+ }
+ }
+
+ echo ' if (!totalBol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else {' . "\n";
+ echo ' submitAlert(\'#vrednost_if_' . $row1['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' }' . "\n";
+
+ echo ' } '."\n";;
+ }
+ // Lokacija - maps
+ } elseif ($row['tip'] == 26) {
+
+ $ime = 'vrednost_' . $row['id'] . '[]';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ // Heatmap
+ } elseif ($row['tip'] == 27) {
+
+ $ime = 'vrednost_' . $row['id'] . '[]';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if (!obj) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ // konec pogoja, ce je vprasanje vidno
+ echo ' } //-- if display != none ' . "\n";
+
+ echo ' } catch (e) {} ' . "\n";
+
+ }
+
+
+ // Alert za EVOLI departmente
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter')
+ )
+ $evoli_teammeter = true;
+ else
+ $evoli_teammeter = false;
+
+ if($evoli_teammeter){
+ echo ' var obj = document.forms[\'vnos\'].elements[\'evoli_tm_department\']; ' . "\n";
+
+ echo ' if (typeof(obj) != "undefined" && obj != null) { ' . "\n";
+
+ echo ' if (obj.value == 0) { ' . "\n";
+ echo ' hard = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_evoli_tm_department\', \'add\', \'require\', \'hard\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_evoli_tm_department\', \'remove\', \'require\', \'hard\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ echo ' } ' . "\n";
+ }
+
+
+ // posebno testiranje za vsoto in num ce smo presegli limit
+ //$sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='".get('grupa')."' AND vsota_reminder > 0 ORDER BY vrstni_red ASC");
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND gru_id != '0' AND (tip='18' OR tip='7' OR tip='20' OR tip='21') ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($row['vsota_reminder'] > 0) {
+
+ if ($row['vsota_reminder'] == 1) {
+ $bol_vsota = 'soft';
+ } else {
+ $bol_vsota = 'hard';
+ }
+
+ // najprej damo pogoj, da se uposteva, samo ce je vprasanje vidno (ker je lahko v ifu)
+ //echo ' if ( $(\'#spremenljivka_'.$row['id'].'\').css(\'display\') != \'none\' ) { ' ."\n";
+ echo ' if ( document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
+
+ // vsota
+ if ($row['tip'] == 18) {
+ $ime = 'spremenljivka_' . $row['id'] . '_vsota';
+
+ echo ' var obj = document.forms[\'vnos\'].elements[\'' . $ime . '\']; ' . "\n";
+ echo ' if ( (obj.value > ' . $row['vsota_limit'] . ' && !$(obj).hasClass("def") && ' . $row['vsota_limit'] . ' != 0) || (obj.value < ' . $row['vsota_min'] . ' && !$(obj).hasClass("def") && ' . $row['vsota_min'] . ' != 0) ){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false;' . "\n";
+ echo ' vsota = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, true, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'limit\', \'' . $bol_vsota . '\', validation, false, true, false, false); ' . "\n";
+ echo ' } ' . "\n";
+
+ } // multinumber
+ elseif ($row['tip'] == 20) {
+
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $ime = 'vrednost_' . $row1['id'];
+
+ echo ' var bol = false; ' . "\n";
+
+ echo ' for (var i=1; i<=' . $row['grids'] . '; i++) { ' . "\n";
+ echo ' obj = document.getElementById(\'' . $ime . '_grid_\'+i); ' . "\n";
+
+ if ($row['num_useMax'] == 1) {
+ echo ' if (obj.value > ' . $row['vsota_limit'] . ' && obj.value != \'\' && ' . $row['num_useMax'] . ' == 1){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['num_useMin'] == 1) {
+ echo ' if (obj.value < ' . $row['vsota_min'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+
+ echo ' } ' . "\n";
+ }
+ }
+ // number in text
+ else {
+ //za text se ne gleda value amapak value.length
+ $length = $row['tip'] == 21 ? '.length' : '';
+ $num_var = $row['tip'] == 21 ? 'text_' : '';
+
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_1';
+
+ ///echo ' var obj = document.forms[\'vnos\'].elements[\''.$ime.'\']; ' ."\n";
+ echo ' var obj = document.getElementById(\'' . $ime . '\'); ' . "\n";
+
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+
+ if ($row['num_useMax'] == 1) {
+ echo ' if (obj.value'.$length.' > ' . $row['vsota_limit'] . ' && obj.value != \'\' && ' . $row['num_useMax'] . ' == 1){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['num_useMin'] == 1) {
+ echo ' if (obj.value'.$length.' < ' . $row['vsota_min'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['size'] > 1) {
+ $ime = 'spremenljivka_' . $row['id'] . '_vrednost_2';
+
+ //echo ' var obj = document.forms[\'vnos\'].elements[\''.$ime.'\']; ' ."\n";
+ echo ' var obj = document.getElementById(\'' . $ime . '\'); ' . "\n";
+
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+
+ if ($row['num_useMax2'] == 1) {
+ echo ' if (obj.value'.$length.' > ' . $row['num_max2'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+
+ if ($row['num_useMin2'] == 1) {
+ echo ' if (obj.value'.$length.' < ' . $row['num_min2'] . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' '.$num_var.'num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \''.$num_var.'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+ }
+
+ if($row['tip'] == 7){
+ //Alert za mobile slider *************************************
+ echo '
+ //console.log(' . $row['ranking_k'] . ');
+ //console.log(' . $row['id'] . ');
+ ';
+
+ if ($row['ranking_k'] == '1' && get('mobile') != 0) {
+ echo '
+ //console.log(' . $row['ranking_k'] . ');
+ //console.log(' . $row['id'] . ');
+ ';
+
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+ echo ' if (obj.value > ' . $slider_MaxNumLabel . ' && obj.value != \'\'){ ' . "\n";
+ echo ' ' . $bol_vsota . ' = false; ' . "\n";
+ echo ' num = false; ' . "\n";
+ echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'limit\', \'' . $bol_vsota . '\', validation, false, false, true, false); ' . "\n";
+ //echo ' } else { ' ."\n";
+ //echo ' $(\'#spremenljivka_'.$row['id'].'\').removeClass(\'required\'); ' ."\n";
+ echo ' } ' . "\n";
+ }
+ }
+ }
+
+ // konec pogoja, ce je vprasanje vidno
+ echo ' } //-- if display != none ' . "\n";
+
+ }
+
+ }
+
+
+ // posebno testiranje ce respondent ni izbral minimalnega stevila checkbox-ov
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND gru_id != '0' AND (tip='2') ORDER BY vrstni_red ASC");
+
+ while ($row = mysqli_fetch_array($sql)) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $checkbox_min_limit = ($spremenljivkaParams->get('checkbox_min_limit') ? $spremenljivkaParams->get('checkbox_min_limit') : 0);
+ $checkbox_min_limit_reminder = ($spremenljivkaParams->get('checkbox_min_limit_reminder') ? $spremenljivkaParams->get('checkbox_min_limit_reminder') : 0);
+
+ if ($checkbox_min_limit > 0) { //ce je minimalni limit nastavljen
+
+ if ($checkbox_min_limit_reminder == 1) {
+ $bol_min_limit = 'soft';
+ } else {
+ $bol_min_limit = 'hard';
+ }
+
+ // najprej damo pogoj, da se uposteva, samo ce je vprasanje vidno (ker je lahko v ifu)
+ echo ' if ( document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
+
+ echo ' var checkbox_min_limit = '.$checkbox_min_limit.'; ' . "\n";
+ echo ' var checkbox_min_limit_reminder = '.$checkbox_min_limit_reminder.'; ' . "\n";
+
+ //ce je checkbox in ni drag drop, preveri, koliko je oznacenih odgovorov
+ if($row['tip'] == 2 && ($row['orientation'] != 8 || get('mobile') == 1)){
+
+ echo ' obj = document.forms[\'vnos\'].elements[\'vrednost_\'+'.$row['id'].'+\'[]\']; ' . "\n";
+ echo ' var len = obj.length; ' . "\n";
+ echo ' var count = 0; ' . "\n";
+ echo ' for (i=0; i<len; i++){ ' . "\n";
+ echo ' if (obj[i].checked){ ' . "\n";
+ echo ' count++; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' if (count < checkbox_min_limit){
+ checkbox_min_limit_alert = true;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ } ' . "\n";
+ }
+ //ce je check box in drag drop, preveri, koliko je oznacenih odgovorov
+ elseif($row['tip'] == 2 && $row['orientation'] == 8){
+ echo '
+ var prisotno = $("#half2_frame_dropping_' . $row['id'] . '").children("div").attr("value");
+ var len = $("#half2_frame_dropping_' . $row['id'] . '").children().length;
+
+ if(len < checkbox_min_limit){
+ checkbox_min_limit_alert = true;
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ }else{
+ submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'checkbox_min_limit\', \'' . $bol_min_limit . '\', validation, false, true, false, false);
+ }
+ ';
+ }
+ // konec pogoja, ce je vprasanje vidno
+ echo '} //-- if display != none ' . "\n";
+ }
+ }
+
+
+ if (isset($_GET['disablealert']) && $_GET['disablealert'] == 1) {
+ echo ' vsota = true; ' . "\n";
+ echo ' hard = true; ' . "\n";
+ echo ' soft = true; ' . "\n";
+ }
+
+ echo ' if ( validation ) { ';
+
+ // validacija
+ $sqlv = sisplet_query("SELECT v.* FROM srv_validation v, srv_spremenljivka s WHERE v.spr_id=s.id AND s.gru_id='" . get('grupa') . "' AND s.gru_id != '0' AND v.reminder>'0'");
+ while ($rowv = mysqli_fetch_array($sqlv)) {
+
+ if ($rowv['reminder'] == 1) {
+ $bol = 'soft';
+ } else {
+ $bol = 'hard';
+ }
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo opozorilo
+ if(SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ echo 'odstrani_opozorilo(\'#spremenljivka_' . $rowv['spr_id'] . '\', false, false, true); ';
+ }
+
+ echo 'submitAlert(\'#spremenljivka_' . $rowv['spr_id'] . '\', \'remove\', \'validation\', \'' . $bol . '\', validation, false, false, false, true); ';
+ }
+
+ if (mysqli_num_rows($sqlv) > 0) mysqli_data_seek($sqlv, 0);
+
+ while ($rowv = mysqli_fetch_array($sqlv)) {
+ if ($rowv['reminder'] == 1) {
+ $bol = 'soft';
+ } else {
+ $bol = 'hard';
+ }
+
+ ?>
+ if ( <? $this->generateCondition($rowv['if_id']); ?> ) {
+
+ <?
+ // Ce imamo vklopljene napredne parapodatke zabelezimo opozorilo
+ if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled()){
+ ?>
+ <?= ' dodaj_opozorilo_val(\'' . $bol . '\', \'#spremenljivka_' . $rowv['spr_id'] . '\'); ' ?>
+ <?
+ }?>
+
+ <?= ' submitAlert(\'#spremenljivka_' . $rowv['spr_id'] . '\', \'add\', \'validation\', \'' . $bol . '\', validation, \'' . $rowv['reminder_text'] . '\', false, false, true); ' ?>
+
+ }
+ <?
+ }
+
+ echo ' } else { ';
+
+ //alert za preseg limita vsote
+ echo ' if (!vsota) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_sum_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_sum_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za preseg limita stevila
+ echo ' if (!num) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_num_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_num_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za preseg limita besedila
+ echo ' if (!text_num) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_text_num_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_text_num_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za premalo izbranih checkboxov
+ echo ' if (checkbox_min_limit_alert) { ' . "\n";
+ echo ' if (checkbox_min_limit_reminder == 2) { ' . "\n";
+ echo ' alert(\'' . $srv_remind_checkbox_min_violated_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (checkbox_min_limit_reminder == 1) { ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_checkbox_min_violated_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+ //alert za ostale tipe
+ echo ' if(text_num && num && vsota) { ' . "\n";
+ echo ' if (!hard) { ' . "\n";
+ echo ' if(\'' . $require . '\' == \'require2\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_99 . '\'); ' . "\n";
+ echo ' else if(\'' . $require . '\' == \'require3\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_98 . '\'); ' . "\n";
+ echo ' else if(\'' . $require . '\' == \'require4\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_97 . '\'); ' . "\n";
+ echo ' else if(\'' . $require . '\' == \'require5\') ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard_multi . '\'); ' . "\n";
+ echo ' else ' . "\n";
+ echo ' alert(\'' . $srv_remind_hard . '\'); ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } else if (!soft) { ' . "\n";
+ echo ' if(\'' . $require . '\' == \'require2\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_99 . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else if(\'' . $require . '\' == \'require3\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_98 . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else if(\'' . $require . '\' == \'require4\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_97 . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else if(\'' . $require . '\' == \'require5\'){ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft_multi . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' }else{ ' . "\n";
+ echo ' if (!confirm(\'' . $srv_remind_soft . '\')) { ' . "\n";
+ echo ' return; ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+ echo ' } ' . "\n";
+
+
+ // validacija
+ $sqlv = sisplet_query("SELECT v.* FROM srv_validation v, srv_spremenljivka s WHERE v.spr_id=s.id AND s.gru_id='" . get('grupa') . "' AND s.gru_id != '0'");
+ while ($rowv = mysqli_fetch_array($sqlv)) {
+
+ ?>
+ if ( <? $this->generateCondition($rowv['if_id']); ?> ) {
+
+ <? if ($rowv['reminder'] == 1) {
+
+ ?> $('#spremenljivka_<?= $rowv['spr_id'] ?>').addClass('required'); <?
+ /*?> if ( ! confirm('<?= $rowv['reminder_text'] ?>') ) return; else $('#spremenljivka_<?= $rowv['spr_id'] ?>').removeClass('required'); <?*/
+ /*?> console.log('Soft validacija se je sprozila za spremenljivko: <?= $rowv['spr_id'] ?>'); if ( ! confirm('<?= $rowv['reminder_text'] ?>') ) return; else $('#spremenljivka_<?= $rowv['spr_id'] ?>').removeClass('required'); <?*/
+ ?> if ( ! confirm('<?= $rowv['reminder_text'] ?>') ) return; else $('#spremenljivka_<?= $rowv['spr_id'] ?>').removeClass('required'); <?
+
+ } elseif ($rowv['reminder'] == 2) {
+
+ ?> $('#spremenljivka_<?= $rowv['spr_id'] ?>').addClass('required'); <?
+ /*?> alert('<?= $rowv['reminder_text'] ?>'); return; <?*/
+ /*?> console.log('Hard validacija se je sprozila za spremenljivko: <?= $rowv['spr_id'] ?>'); alert('<?= $rowv['reminder_text'] ?>'); return; <?*/
+ ?> alert('<?= $rowv['reminder_text'] ?>'); return; <?
+
+ } ?>
+
+ }
+ <?
+
+ }
+
+ // preverjanje, da vnese inicialke
+ $question_resp_comment_inicialke = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_inicialke');
+ $question_resp_comment_inicialke_alert = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_inicialke_alert');
+ if ($question_resp_comment_inicialke == 1 && $question_resp_comment_inicialke_alert == 2) {
+ ?>
+ if ( !check_inicialke() ) {
+ alert('<?= $lang['srv_enter_inicialke'] ?>');
+ preview_popup_open();
+ return;
+ }
+ <?php
+ } elseif ($question_resp_comment_inicialke == 1 && $question_resp_comment_inicialke_alert == 1) {
+ ?>
+ if ( !check_inicialke() ) {
+ if ( !confirm('<?= $lang['srv_enter_inicialke2'] ?>') ) {
+ preview_popup_open();
+ return;
+ }
+ }
+ <?php
+ }
+
+ echo ' if (parent_if == undefined) { ' . "\n";
+
+ // Ce imamo vklopljene napredne parapodatke zabelezimo cas post-a
+ if(SurveyAdvancedParadataLog::getInstance()->paradataEnabled() && SurveyAdvancedParadataLog::getInstance()->collectPostTime()){
+ echo 'logEvent(\'page\', \'unload_page\', function(){
+ $("form[name=vnos]").submit();
+ });';
+ }
+ else{
+ echo ' $("form[name=vnos]").submit(); ' . "\n";
+ }
+
+ echo ' } else { ' . "\n";
+ echo ' $.post($(\'form[name=vnos]\').attr(\'action\'), $(\'form[name=vnos]\').serialize(), function () { ' . "\n";
+ echo ' $.post(\'' . $site_url . 'main/survey/ajax.php?a=grupa_for_if\', {anketa:' . get('anketa') . ', parent_if: parent_if}, function (data) { ' . "\n";
+ echo ' window.location.href = \'' . SurveyInfo::getSurveyLink(false, false) . '&grupa=\'+data+\'' . Header::getSurveyParams() . get('cookie_url') . '\'; ' . "\n";
+ echo ' }) ' . "\n";
+ echo ' } ) ' . "\n";
+ echo ' } ' . "\n";
+
+ // if validation else
+ echo ' } ';
+
+ echo ' } ' . "\n";
+ //echo 'spr_id_indeks = 0; ' . "\n"; //za sledenje opozoril
+ echo ' </script> ' . "\n";
+
+
+ $sqlG = sisplet_query("SELECT spol FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'");
+ $rowG = mysqli_fetch_array($sqlG);
+
+ $sql1 = sisplet_query("SELECT MAX(vrstni_red) AS vrstni_red FROM srv_grupa WHERE ank_id = '" . get('anketa') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ //namesto naprej in nazaj se pri glasovanju izrise gumb potrdi oz. gumba moski/zenska pri izbiri spola
+ if ($rowa['survey_type'] == 0) {
+
+ if (!get('printPreview')) {
+ if ($rowG['spol'] == 0) {
+
+ $srv_potrdi = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_potrdi'.$_lang);
+ if ($srv_potrdi == '') $srv_potrdi = $lang['srv_potrdi'];
+
+ echo ' <div class="buttons">
+ <input class="next" type="submit" value="' . $srv_potrdi . '" onclick="submitForm(); return false;">
+ </div>' . "\n";
+ } else {
+ echo ' <div class="buttons">
+ <input class="next" type="submit" name="submit" value="' . $lang['glasovanja_spol_moski'] . '" onclick="submitForm(); return false;">
+ <input class="next" type="submit" name="submit" value="' . $lang['glasovanja_spol_zenska'] . '" onclick="submitForm(); return false;">
+ </div>' . "\n";
+ }
+ }
+
+ //namesto naprej in nazaj izrise pri formi gumb poslji
+ } elseif ($rowa['survey_type'] == 1) {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_forma_send' . $_lang);
+ if ($srv_nextpage == '') $srv_nextpage = $lang['srv_forma_send'];
+
+ if (!get('printPreview')) {
+ echo ' <div class="buttons">';
+ echo ' <input class="next" type="submit" value="' . $srv_nextpage . '" onclick="submitForm(); return false;">
+ </div>' . "\n";
+ }
+
+ } else {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE ID = '" . get('grupa') . "'");
+ $rowg = mysqli_fetch_array($sqlg);
+
+ // Smo na zadnji strani
+ if ($row1['vrstni_red'] == $rowg['vrstni_red']) {
+
+ // Dodatno preverimo ce imamo loop
+ if(isset($_GET['loop_id']) && $_GET['loop_id'] > 0){
+
+ // Ce obstaja naslednji loop izpisemo "naslednja stran" in ne "zadnja stran"
+ if(Find::getInstance()->findNextLoopId() > 0){
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage' . $_lang);
+ if ($srv_nextpage == '') $srv_nextpage = $lang['srv_nextpage'];
+ }
+ else{
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_lastpage' . $_lang);
+ if ($srv_nextpage == '') $srv_nextpage = $lang['srv_lastpage'];
+ }
+ }
+ else{
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_lastpage' . $_lang);
+ if ($srv_nextpage == '') $srv_nextpage = $lang['srv_lastpage'];
+ }
+ }
+ else {
+ $srv_nextpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_nextpage' . $_lang);
+ if ($srv_nextpage == '') $srv_nextpage = $lang['srv_nextpage'];
+ }
+
+ $srv_prevpage = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_prevpage' . $_lang);
+ if ($srv_prevpage == '') $srv_prevpage = $lang['srv_prevpage'];
+
+ $display_backlink = SurveySetting::getInstance()->getSurveyMiscSetting('display_backlink');
+
+ if (!get('printPreview')) {
+ echo '<div class="buttons" id="buttons_gru_' . get('grupa') . '">';
+ //echo ' <input class="prev" type="submit" value="'.$lang['srv_prevpage'].'" onclick="document.location.href=\'index.php?anketa='.get('anketa').''.($this->findPrevGrupa()>0?'&grupa='.$this->findPrevGrupa().'':'').get('cookie_url').'\'; return false;">
+ if ($row['show_intro'] == 1 || $rowg['vrstni_red'] > 1) {
+ #echo '<input class="prev" type="button" value="'.$srv_prevpage.'" onclick="history.back()">';
+
+ if (!SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+
+ // Posebej za WebSM anketo - back naredimo tako, da poiscemo prejsnjo stran
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+
+ $grupa = Find::findPrevGrupa();
+ $grupa = ($grupa > 0) ? '&grupa=' . $grupa : '';
+
+ $lang_s = (isset($_GET['language'])) ? '&language=' . $_GET['language'] : '';
+ $language = save('language', $lang_s, 1);
+
+ $link = SurveyInfo::getSurveyLink(false, false) . $grupa . $language;
+
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="location.href=\'' . $link . '\';">';
+ } elseif ($display_backlink != '0') {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">';
+ }
+ } else {
+
+ # če smo v slideshowu prikazujemo gumb nazaj ali naprej na zahtevo
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+
+ if ($ss_setings['back_btn'] == 1) {
+ echo '<input class="prev" type="button" value="' . $srv_prevpage . '" onclick="javascript:history.go(-1)">';
+ }
+ }
+ }
+
+ if (SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+ # če smo v prezentaciji in imamo nastavljen pause button
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+
+ if ($ss_setings['pause_btn'] == 1) {
+ echo '<input id="btn_pause_on" class="pause" type="button" value="' . $lang['srv_slideshow_btn_pause_on'] . '" onclick="slide_timer_pause_ON();">';
+ echo '<input id="btn_pause_off" class="pause display_none" type="button" value="' . $lang['srv_slideshow_btn_pause_off'] . '" onclick="slide_timer_pause_OFF();">';
+ }
+ }
+ if (!SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+ echo ' <input class="next" type="submit" value="' . $srv_nextpage . '" onclick="submitForm(); return false;">';
+ } else {
+ # če smo v slideshowu prikazujemo gumb nazaj ali naprej na zahtevo
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+ if ($ss_setings['next_btn'] == 1) {
+ echo ' <input class="next" type="submit" value="' . $srv_nextpage . '" onclick="submitForm(); return false;">';
+ }
+ }
+
+ echo '</div>' . "\n";
+ }
+ }
+ }
+
+ /**
+ * @desc poklice generatorje JS kode za branching
+ */
+ public function generateBranchingJS()
+ {
+ echo '<script> ' . "\n";
+
+ echo ' function checkBranching () { ' . "\n";
+
+ $this->generateComputeJS();
+
+ // ce je preverjanje pogojev izklopljeno
+ if ($_GET['disableif'] != 1) {
+
+ $this->generateBranching();
+
+ $this->generateVrednostIf();
+ }
+
+ // sprotna validacija v balonckih
+ echo ' submitForm(undefined, true); ';
+
+ // Popravek footerja pri temi Bled
+ $row = SurveyInfo::getSurveyRow();
+ if($row['skin'] == 'Bled'){
+ echo ' footerBled(); ' . "\n";
+ }
+
+ echo ' } //-- function checkBranching() ' . "\n";
+
+
+ echo ' checkBranching(); ' . "\n";
+
+ echo '</script> ' . "\n";
+ }
+
+ /**
+ * zgenerira koda za compute spremenljivke, ki si vrednost napolnijo samodejno iz calculation izraza
+ *
+ */
+ public function generateComputeJS()
+ {
+
+ if (get('generateComputeJS') != '') {
+
+ echo 'try { ' . "\n";
+ echo ' ' . get('generateComputeJS') . "\n";
+ echo '} catch (e) {} ' . "\n";
+ }
+
+ }
+
+ /**
+ * za podano spremenljivko zgenerira compute kodo, ki se shrani v začasno spremenljivko, da se na koncu izpiše s funkcijo generateComputeJS()
+ *
+ * @param mixed $spremenljivka
+ */
+ public function generateCompute($spremenljivka)
+ {
+
+ // vrednost kalkulacije za ife
+ add('generateComputeJS', "document.getElementById('vrednost_" . $spremenljivka . "').value = " . $this->generateCalculationJS(-$spremenljivka) . "; \n\r");
+
+ // vrednost se zapise v class .data-piping-SPR_ID za data-piping da se v zivo refresha
+ add('generateComputeJS', " var val; if ( ! isNaN(document.getElementById('vrednost_" . $spremenljivka . "').value) ) val = document.getElementById('vrednost_" . $spremenljivka . "').value; else val = ''; \n\r");
+ add('generateComputeJS', " $('.data-piping-$spremenljivka').html( val ); \n\r");
+ }
+
+ /**
+ * @desc zgenerira kodo za IFe na vrednostih (podifi)
+ */
+ public function generateVrednostIf()
+ {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ $sql = sisplet_query("SELECT v.*, s.tip AS tip, s.id AS spr_id, s.dynamic_mg AS dynamic_mg, s.vsota_limit, s.design, s.params FROM srv_vrednost v, srv_spremenljivka s WHERE v.if_id>'0' AND v.spr_id=s.id AND s.gru_id='" . get('grupa') . "' AND s.gru_id != '0'");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ // Ce je odgovor skrit ga nikoli ne prikazemo in preskocimo kar celotno proceduro za to vrednost
+ if($row['hidden'] == '1'){
+ continue;
+ }
+
+ //stavek za pobiranje informacij o tipu in orienataciji spremenljivke, potrebno za nadaljnje notranje pogoje za drag and drop
+ $sqldd = sisplet_query("SELECT id, enota, orientation FROM srv_spremenljivka WHERE id = '$row[spr_id]'");
+ while ($rowdd = mysqli_fetch_array($sqldd)) {
+ $spremenljivka_dd = $rowdd['id'];
+ $orientation_dd = $rowdd['orientation'];
+ $enota_dd = $rowdd['enota'];
+ }
+
+ // vsota - treba je se enkrat pognati racunanje
+ if ($row['tip'] == 18) {
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[spr_id]' AND vrstni_red>0");
+ $max = mysqli_num_rows($sql1);
+ $sum = ' calcSum(\'' . $row['spr_id'] . '\', \'' . $max . '\', \'' . $row['vsota_limit'] . '\'); ' . "\n";
+ }
+ else
+ $sum = '';
+
+
+ // dinamicni multigrid (za mobilne naprave)
+ if ($row['tip'] == 6 && $enota_dd != 9 && $enota_dd != 3 && $row['dynamic_mg'] > 0) {
+
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' dynamicMultigridSwitchIf(1, ' . $row['id'] . ', ' . $row['spr_id'] . '); ' . "\n";
+
+ echo ' } else { ' . "\n";
+
+ echo ' dynamicMultigridSwitchIf(0, ' . $row['id'] . ', ' . $row['spr_id'] . '); ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ // Navaden multigrid
+ else if ($row['tip'] == 6 && $enota_dd != 9 && $enota_dd != 3) {
+
+ echo ' try { ' . "\n";
+
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ // Element je viden
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' var el = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n";
+ echo ' el.parentNode.removeChild( el );' . "\n";
+
+ // Element ni viden
+ echo ' } else { ' . "\n";
+
+ // ker je element neviden, dodamo novega hidz vrednostjo -2
+ echo ' var el = document.getElementById(\'vrednost_if_' . $row['id'] . '\');' . "\n";
+ echo ' var hiddenEl = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n";
+ echo ' var parent = el.parentNode.parentNode.parentNode;' . "\n";
+
+ // V kolikor je hidden polje že postavljeno potem ga ponovno ne ustvarjamo -> se izognemo podvojenim vpisom v bazi
+ echo ' if(!hiddenEl){' . "\n";
+ echo 'var newElement = document.createElement(\'input\');' . "\n";
+ echo ' newElement.setAttribute("id", "branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '");' . "\n";
+ echo ' newElement.setAttribute("name", "cond_vrednost_' . $row['id'] . '");' . "\n";
+ echo ' newElement.setAttribute("value", "-2");' . "\n";
+ echo ' newElement.setAttribute("type", "hidden");' . "\n";
+ echo ' parent.appendChild(newElement);' . "\n";
+ echo ' }' . "\n";
+
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ // checkbox in ne drag and drop
+ else if ($row['tip'] == 2 && ($row['orientation'] != 8 || get('mobile') == 1)) {
+
+ if ($spremenljivka_dd == $row['spr_id'] && ($orientation_dd == 8 || $enota_dd == 9)) {//ce je drag and drop
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+ echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ else {
+ echo ' try { ' . "\n";
+
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ // Element je viden
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' var el = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n";
+ echo ' el.parentNode.removeChild( el );' . "\n";
+
+ // Element ni viden
+ echo ' } else { ' . "\n";
+
+ // ker je element neviden, dodamo novega hidz vrednostjo -2
+ echo ' var el = document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\');' . "\n";
+ echo ' var hiddenEl = document.getElementById("branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '")' . "\n";
+ echo ' var parent = el.parentNode.parentNode.parentNode;' . "\n";
+
+ // V kolikor je hidden polje že postavljeno potem ga ponovno ne ustvarjamo -> se izognemo podvojenim vpisom v bazi
+ echo ' if(!hiddenEl){' . "\n";
+ echo 'var newElement = document.createElement(\'input\');' . "\n";
+ echo ' newElement.setAttribute("id", "branch_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '");' . "\n";
+ echo ' newElement.setAttribute("name", "cond_vrednost_' . $row['spr_id'] . '[]");' . "\n";
+ echo ' newElement.setAttribute("value", "' . $row['id'] . '");' . "\n";
+ echo ' newElement.setAttribute("type", "hidden");' . "\n";
+ echo ' parent.appendChild(newElement);' . "\n";
+ echo ' }' . "\n";
+
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+
+ }
+ // roleta
+ else if ($row['tip'] == 3) {
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'vrednost_' . $row['spr_id'] . '_chzn_o_' . $row['vrstni_red'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+ echo ' document.getElementById(\'vrednost_' . $row['spr_id'] . '_chzn_o_' . $row['vrstni_red'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ // ranking premikanje
+ else if ($row['tip'] == 17 && $row['design'] == 2) {
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+
+ echo ' $(\'#spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n";
+ echo ' $(\'#frame_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ // ranking prestavljanje
+ else if ($row['tip'] == 17 && $row['design'] == 0) {
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+
+ echo ' $(\'#spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n";
+ echo ' $(\'#frame_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ else {
+ if ($spremenljivka_dd == $row['spr_id'] && ($orientation_dd == 8 || $enota_dd == 9)) {//ce je drag and drop
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+ echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ else {
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
+ }
+
+ // Po notranjih pogojih prikazemo ponavljanje naslovne vrstice za tabele ce je to vklopljeno
+ if($row['tip'] == 6 || $row['tip'] == 16){
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+
+ if($grid_repeat_header > 0){
+ echo ' gridRepeatHeader(\''.$grid_repeat_header.'\', \''.$row['spr_id'].'\'); ';
+ }
+ }
+ }
+ }
+
+ /**
+ * @desc zgenerira kodo za branching
+ */
+ public function generateBranching($parent = 0)
+ {
+ Cache::cache_all_srv_branching(get('anketa'));
+ Cache::cache_all_srv_if(get('anketa'));
+
+ foreach (Cache::srv_branching_parent(get('anketa'), $parent) AS $k => $row) {
+
+ if ($row['element_if'] > 0) {
+
+ $rowb = Cache::srv_if($row['element_if']);
+
+ // build conditions
+ //echo 'console.log("V generateBranching");';
+ echo ' try { ' . "\n";
+
+ echo ' if (';
+
+ if ($rowb['tip'] == 0) { // if
+
+ if ($rowb['enabled'] == 1)
+ echo 'true';
+ elseif ($rowb['enabled'] == 2)
+ echo 'false';
+ else
+ $this->generateCondition($row['element_if']);
+
+ } else { // blok
+
+ if ($rowb['enabled'] != 2)
+ echo 'true';
+ else
+ echo 'false';
+
+ }
+ echo ' ) { ' . "\n";
+
+ // ko prikazujemo, prikazemo samo trenutni nivo
+ foreach (Cache::srv_branching_parent(get('anketa'), $row['element_if']) AS $k1 => $row1) {
+
+ if ($row1['element_spr'] > 0) {
+
+ if (Helper::getGrupa($row1['element_spr']) == get('grupa')) {
+
+ $rowc = Model::select_from_srv_spremenljivka($row1['element_spr']);
+ if ($rowc['tip'] != 22 && $rowc['tip'] != 25) { // spremenljivka tipa compute in quota je izvzeta iz pogojev
+
+ echo ' try { ' . "\n";
+ echo ' document.getElementById(\'spremenljivka_' . $row1['element_spr'] . '\').style.display = "block"; ' . "\n";
+ echo ' document.getElementById(\'visible_' . $row1['element_spr'] . '\').value = \'1\'; ' . "\n";
+
+ // Dodamo class da je vprasanje v bloku
+ echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child\'); ' . "\n";
+
+ // Dodamo class ce je vprasanje v bloku in je prikazano horizontalno
+ if (Helper::checkParentHorizontal($row1) == 1) {
+ echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'horizontal_block\'); ' . "\n";
+ }
+ // Dodamo class ce je vprasanje v bloku in je prikazano z razpiranjem
+ if (Helper::checkParentHorizontal($row1) == 2) {
+ echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'expendable_block\'); ' . "\n";
+ }
+
+ // Dodamo class z id-jem bloka
+ echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child_'.$row['element_if'].'\'); ' . "\n";
+
+
+ //Uros - samo za tip 26
+ //ker se mapa ne kreira vredu, ce je hidden, jo je ob prikazu treba resizat ter nastavit bounds mape
+ echo '
+ if('.$rowc['tip'].' == 26){
+ //resize map, ker je zaradi display=none postala velika 0
+ var map = document.getElementById("map_"+' . $row1['element_spr'] . ').gMap;
+ google.maps.event.trigger(map, \'resize\');
+ //ce je 0 ali 1 marker, centriraj kot nastavi admin, drugace prilagodi markerjem
+ if (st_markerjev[' . $row1['element_spr'] . '] == 0){
+ if(map.centerInMapKoordinate){
+ map.setCenter({lat: parseFloat(map.centerInMapKoordinate.center.lat),
+ lng: parseFloat(map.centerInMapKoordinate.center.lng)});
+ }
+ else
+ centrirajMap(map.centerInMap, map);
+ }
+ else
+ map.fitBounds(bounds[' . $row1['element_spr'] . ']);
+ }';
+
+ echo ' } catch (e) {} ' . "\n";
+
+ }
+ }
+
+ }
+ }
+
+ $this->generateBranching($row['element_if']);
+
+ // Ce imamo vklopljen modul panel moramo nastaviti status panelista glede na izpolnjen if
+ if(SurveyInfo::checkSurveyModule('panel') == 1){
+
+ $sp = new SurveyPanel(get('anketa'));
+ $panel_if = $sp->getPanelIf($row['element_if']);
+
+ if($panel_if != ''){
+ echo '$(\'#panel_status\').val(\''.$panel_if.'\'); ' . "\n";
+ }
+ }
+
+ echo ' } else { ' . "\n";
+
+ // ko skrivamo, skrijemo vse (tudi podnivoje) (zato klic rekurzivne funkcije)
+ foreach (Helper::getElements($row['element_if']) AS $key) {
+
+ if (Helper::getGrupa($key) == get('grupa')) {
+
+ $rowc = Model::select_from_srv_spremenljivka($key);
+ if ($rowc['tip'] != 22 && $rowc['tip'] != 25) { // spremenljivka tipa compute in quota je izvzeta iz pogojev
+
+ echo ' try { ' . "\n";
+ echo ' document.getElementById(\'spremenljivka_' . $key . '\').style.display = "none"; ' . "\n";
+ echo ' document.getElementById(\'visible_' . $key . '\').value = \'0\'; ' . "\n";
+
+ // Dodamo class da je vprasanje v bloku
+ echo ' $(\'#spremenljivka_' . $row1['element_spr'] . '\').addClass(\'block_child\'); ' . "\n";
+
+ // Dodamo class ce je vprasanje v bloku in je prikazano horizontalno
+ if (Helper::checkParentHorizontal($row) == 1) {
+ echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'horizontal_block\'); ' . "\n";
+ }
+ // Dodamo class ce je vprasanje v bloku in je prikazano z razpiranjem
+ if (Helper::checkParentHorizontal($row) == 2) {
+ echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'expendable_block\'); ' . "\n";
+ }
+
+ // Dodamo class z id-jem bloka
+ echo ' $(\'#spremenljivka_' . $key . '\').addClass(\'block_child_' . $row['element_if'] . '\'); ' . "\n";
+ echo ' } catch (e) {} ' . "\n";
+
+ }
+ }
+ }
+
+ echo ' } ' . "\n";
+
+ echo ' } catch (e) {} ' . "\n";
+
+
+ // RANDOMIZACIJA VSEBINE BLOKA
+ // Randomiziramo vprasanja v bloku (ce imamo to vklopljeno)
+ if ($rowb['random'] >= 0) {
+
+ $questions = [];
+
+ foreach (Cache::srv_branching_parent(get('anketa'), $rowb['id']) AS $key => $val) {
+ if ($val['element_spr'] > 0) {
+ $questions[] = $val['element_spr'];
+ }
+ }
+
+ // Ce imamo nastavljen prikaz samo dolocenega stevila vprasanj
+ $spr_count = ($rowb['random'] > 0) ? $rowb['random'] : count($questions);
+
+ // Napolnimo seed za posameznega respondenta (da dobi vsakic isti vrstni red)
+ mt_srand((int)get('usr_id') + (int)$rowb['id']);
+
+ // Zgeneriramo random vrstni red
+ $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($questions)));
+ array_multisort($order, $questions);
+
+ $order_in_block = json_encode($questions);
+
+ echo ' blockRandomizeQuestions(\''.$rowb['id'].'\', \''.$order_in_block.'\', \''.get('usr_id').'\', \''.$spr_count.'\'); ' . "\n";
+ }
+ // Randomiziramo bloke v bloku (ce imamo to vklopljeno)
+ elseif ($rowb['random'] == -2) {
+
+ $blocks = [];
+
+ foreach (Cache::srv_branching_parent(get('anketa'), $rowb['id']) AS $key => $val) {
+ if ($val['element_if'] > 0) {
+
+ $if_el = Cache::srv_if($val['element_if']);
+
+ // blok
+ if ($if_el['tip'] == 1) {
+ $blocks[] = $if_el['id'];
+ }
+ }
+ }
+
+ // Napolnimo seed za posameznega respondenta (da dobi vsakic isti vrstni red)
+ mt_srand((int)get('usr_id') + (int)$rowb['id']);
+
+ // Zgeneriramo random vrstni red
+ $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($blocks)));
+ array_multisort($order, $blocks);
+
+ $order_in_block = json_encode($blocks);
+
+ echo ' blockRandomizeBlocks(\'' . $rowb['id'] . '\', \'' . $order_in_block . '\', \'' . get('usr_id') . '\'); ' . "\n";
+ }
+ }
+ }
+
+ // dodamo crte pri blokih, kjer so vprasanja postavljena horizontalno
+ echo ' blockHorizontalLine(); ' . "\n";
+ }
+
+ /**
+ * @desc zgenerira pogoje za JS branching
+ */
+ public function generateCondition($if)
+ {
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ $echo = '';
+ $sql = Cache::srv_condition($if);
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+ $i = 0;
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($i++ != 0)
+ if ($row['conjunction'] == 0)
+ $echo .= ' && ';
+ else
+ $echo .= ' || ';
+
+ if ($row['negation'] == 1)
+ $echo .= ' ! ';
+
+ for ($i = 1; $i <= $row['left_bracket']; $i++)
+ $echo .= ' ( ';
+
+ // obicajne spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ $row2 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+ $row1 = Model::select_from_srv_spremenljivka($row['spr_id']);
+ // multigrid
+ } elseif ($row['vre_id'] > 0) {
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE id = '$row[vre_id]'");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+ $row1 = mysqli_fetch_array($sql1);
+ } else
+ $row1 = null; //�ud not hepen
+
+
+ // kombinirana tabela
+ if (in_array($row2['tip'], array(6, 16, 19, 20)) && $row2['gru_id'] == '-2') {
+
+ if (in_array($row2['tip'], array(6, 16))) {
+ $sql3 = sisplet_query("SELECT * FROM srv_condition_grid c WHERE cond_id='$row[id]'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ if ($rowa['mass_insert'] != 1 || $row2['tip'] != 6 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje
+
+ // Ce imamo if pogoj za -1 -> neodgovor
+ if ($row3['grd_id'] == '-1') {
+ $condition = '';
+
+ // loop cez vse gride in preverimo ce je kaksen odkljukan
+ $sqlG = sisplet_query("SELECT id, part, other FROM srv_grid WHERE spr_id='$row2[id]'");
+ while ($rowG = mysqli_fetch_array($sqlG)) {
+ if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) {
+ if ($rowG['other'] == 0)
+ $condition .= '!document.getElementById(\'multi_' . $row2['id'] . '_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked ';
+ else
+ $condition .= '!document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked ';
+
+ } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) {
+ $condition .= '!document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $rowG['id'] . '\' ';
+ }
+ $condition .= ' && ';
+ }
+ $echo .= '(' . substr($condition, 0, -3) . ')';
+ } else {
+ if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) {
+
+ $sql4 = sisplet_query("SELECT part, other FROM srv_grid WHERE spr_id='$row2[id]' AND id='$row3[grd_id]'");
+ $row4 = mysqli_fetch_array($sql4);
+
+ if ($row4['other'] == 0)
+ $echo .= 'document.getElementById(\'multi_' . $row2['id'] . '_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked ';
+ else
+ $echo .= 'document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked ';
+
+ } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) {
+ $echo .= 'document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'multi_' . $row2['id'] . '_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $row3['grd_id'] . '\' ';
+ }
+ }
+
+ // masovni vnos
+ } else {
+ $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\').value == "' . $row3['grd_id'] . '"';
+ }
+
+ }
+ } elseif (in_array($row2['tip'], array(19, 20))) {
+ $echo .= ' ( ';
+
+ $echo .= ' document.getElementById(\'multi_' . $row2['id'] . '_' . $row['vre_id'] . '_grid_' . $row['grd_id'] . '\').value';
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 2)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 3)
+ $echo .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $echo .= ' > ';
+ elseif ($row['operator'] == 5)
+ $echo .= ' >= ';
+
+
+ //if ($row['text'] == '')
+ $echo .= '"' . $row['text'] . '"';
+ /*else
+ $echo .= $row['text'];*/
+
+ $echo .= ' ) ';
+ }
+
+ // radio, checkbox, dropdown in multigrid (brez drag and drop)
+ } elseif ((($row2['tip'] <= 3 && ($row2['orientation'] != 8 || get('mobile') == 1)) || ($row2['tip'] == 6 || $row2['tip'] == 16) && ($row2['enota'] != 9)) && ($row['spr_id'] || $row['vre_id'])) {
+
+ if ($row['operator'] == 0)
+ $echo .= ' ';
+ else
+ $echo .= ' ! ';
+
+ $echo .= ' ( ';
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+
+ $sql3 = sisplet_query("SELECT c.vre_id, v.id, v.vrstni_red, v.other FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ if ($rowa['mass_insert'] != 1 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje
+
+ // Ce imamo if pogoj za -1 -> neodgovor
+ if ($row3['vre_id'] == '-1') {
+ $condition = '';
+
+ // loop cez vse odgovore in preverimo ce je kaksen odkljukan
+ $sqlV = sisplet_query("SELECT id, other FROM srv_vrednost WHERE spr_id='$row[spr_id]'");
+ while ($rowV = mysqli_fetch_array($sqlV)) {
+ if ($row2['tip'] <= 2 && ($row2['orientation'] != 8 || get('mobile') == 1)) {
+ if ($rowV['other'] >= 0)
+ $condition .= '!document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $rowV['id'] . '\').checked ';
+ else
+ $condition .= '!document.getElementById(\'missing_value_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $rowV['id'] . '\').checked ';
+ } else {
+ $condition .= '!document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == \'' . $rowV['id'] . '\' ';
+ }
+ $condition .= ' && ';
+ }
+ $echo .= '(' . substr($condition, 0, -3) . ')';
+ } else {
+ //if ($row2['tip'] <= 2) {
+ if ($row2['tip'] <= 2 && ($row2['orientation'] != 8 || get('mobile') == 1)) {
+ if ($row3['other'] >= 0)
+ $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').checked ';
+ else
+ $echo .= 'document.getElementById(\'missing_value_spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').checked ';
+ } else {
+ $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == \'' . $row3['id'] . '\' ';
+ }
+ }
+
+ // masovni vnos
+ } else {
+ if ($row2['tip'] != 2) { // radio, dropdown
+ $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value == "' . $row3['vrstni_red'] . '"';
+ } else { // checkbox
+ $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row3['id'] . '\').value == "1"';
+ }
+ }
+ }
+
+ // multigrid
+ } elseif ($row['vre_id'] > 0) {
+ $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ if ($rowa['mass_insert'] != 1 || $row2['tip'] != 6 || $_GET['m'] == 'quick_edit') { // normalno izpolnjevanje
+
+ // Ce imamo if pogoj za -1 -> neodgovor
+ if ($row3['grd_id'] == '-1') {
+ $condition = '';
+
+ // loop cez vse gride in preverimo ce je kaksen odkljukan
+ $sqlG = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row2[id]'");
+ while ($rowG = mysqli_fetch_array($sqlG)) {
+ if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3) {
+ if ($rowG['other'] == 0)
+ $condition .= '!document.getElementById(\'vrednost_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked ';
+ else
+ $condition .= '!document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $rowG['id'] . ($rowG['part'] > 1 ? '_part_2' : '') . '\').checked ';
+
+ //} elseif ($row2['enota'] == 2) {
+ } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) {
+ $condition .= '!document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $rowG['id'] . '\' ';
+ }
+ $condition .= ' && ';
+ }
+ $echo .= '(' . substr($condition, 0, -3) . ')';
+ } else {
+ if ($row2['enota'] == 0 || $row2['enota'] == 1 || $row2['enota'] == 3 || $row2['enota'] == 4 || $row2['enota'] == 8) {
+
+ $sql4 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row2[id]' AND id='$row3[grd_id]'");
+ $row4 = mysqli_fetch_array($sql4);
+
+ if ($row4['other'] == 0)
+ $echo .= 'document.getElementById(\'vrednost_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked ';
+ else
+ $echo .= 'document.getElementById(\'grid_missing_value_' . $row1['id'] . '_grid_' . $row3['grd_id'] . ($row4['part'] > 1 ? '_part_2' : '') . '\').checked ';
+
+ //} elseif ($row2['enota'] == 2) {
+ } elseif ($row2['enota'] == 2 || $row2['enota'] == 6) {
+ $echo .= 'document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].options[document.getElementsByName(\'vrednost_' . $row1['id'] . '\')[0].selectedIndex].value == \'' . $row3['grd_id'] . '\' ';
+ }
+ }
+
+ // masovni vnos
+ } else {
+ $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\').value == "' . $row3['grd_id'] . '"';
+ }
+
+ }
+ }
+
+ $echo .= ' ) ';
+ //drag and drop @ kategorije en odgovor
+ } elseif ($row2['tip'] == 1 && ($row2['orientation'] == 8 && get('mobile') != 1)) {
+
+ if ($row['operator'] == 0)
+ $echo .= ' ';
+ else
+ $echo .= ' ! ';
+
+ $echo .= ' ( ';
+ //SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id
+ $sql3 = sisplet_query("SELECT c.vre_id FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ //if ($row2['design'] == 0 && get('mobile') == 0)
+ $echo .= ' $("#half2_frame_dropping_' . $row2['id'] . '").children("div").attr("value") == ' . $row3['vre_id'];
+
+ //half2_frame_dropping_4271, half2_frame_dropping_1_4276 //spremenljivka_4276_vrednost_22811
+
+ }
+
+ $echo .= ' ) ';
+ //drag and drop @ kategorije vec odgovorov
+ } elseif ($row2['tip'] == 2 && ($row2['orientation'] == 8 && get('mobile') != 1)) {
+ $z = 0;
+ if ($row['operator'] == 0)
+ $echo .= ' ';
+ else
+ $echo .= ' ! ';
+
+ $echo .= ' ( ';
+ //SELECT * FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id
+ $sql3 = sisplet_query("SELECT c.vre_id FROM srv_condition_vre c, srv_vrednost v WHERE cond_id='$row[id]' AND c.vre_id=v.id");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ //if ($row2['design'] == 0 && get('mobile') == 0)
+ for ($z = 1; $z <= $row2['grids']; $z++) { //preleti vse mozne odgovore in sestavi pogoj
+ $echo .= ' $("#half2_frame_dropping_' . $row2['id'] . '").children("div :nth-child(' . $z . ')").attr("value") == ' . $row3['vre_id'];
+ if ($z < $row2['grids']) { //ce ni zadnji mozni odgovor dodaj ali (||)
+ $echo .= '||';
+ }
+ }
+ }
+
+ $echo .= ' ) ';
+
+ //drag and drop @ tabela en odgovor
+ } elseif (($row2['tip'] == 6) && ($row2['enota'] == 9)) {
+ if ($row['operator'] == 0)
+ $echo .= ' ';
+ else
+ $echo .= ' ! ';
+
+ $echo .= ' ( ';
+
+ $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'");
+
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ //if ($row2['design'] == 0 && get('mobile') == 0)
+ $echo .= ' $("#half2_frame_dropping_' . $row3['grd_id'] . '_' . $row2['id'] . '").children("div").attr("value") == ' . $row['vre_id'];
+ }
+
+ $echo .= ' ) ';
+ //drag and drop @ tabela vec odgovorov
+ } elseif (($row2['tip'] == 16) && ($row2['enota'] == 9)) {
+ if ($row['operator'] == 0)
+ $echo .= ' ';
+ else
+ $echo .= ' ! ';
+
+ $echo .= ' ( ';
+
+ $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'");
+
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ //if ($row2['design'] == 0 && get('mobile') == 0)
+ for ($z = 1; $z <= $row2['grids']; $z++) { //preleti vse mozne odgovore in sestavi pogoj
+ $echo .= ' $("#half2_frame_dropping_' . $row3['grd_id'] . '_' . $row2['id'] . '").children("div :nth-child(' . $z . ')").attr("value") == ' . $row['vre_id'];
+ if ($z < $row2['grids']) { //ce ni zadnji mozni odgovor dodaj ali (||)
+ $echo .= '||';
+ }
+ }
+ }
+
+ $echo .= ' ) ';
+
+
+ // razvrscanje
+ } elseif ($row2['tip'] == 17) {
+
+ if ($row['operator'] == 0)
+ $echo .= ' ';
+ else
+ $echo .= ' ! ';
+
+ $echo .= ' ( ';
+
+ $sql3 = sisplet_query("SELECT grd_id FROM srv_condition_grid WHERE cond_id='$row[id]'");
+ if (!$sql3) echo mysqli_error($GLOBALS['connect_db']);
+
+ $j = 0;
+ while ($row3 = mysqli_fetch_array($sql3)) {
+ if ($j++ != 0) $echo .= ' || ';
+
+ if ($row2['design'] == 0 && get('mobile') == 0) // prestavljanje
+ $echo .= ' $(\'#half2_' . $row2['id'] . '\').sortable(\'toArray\')[' . ($row3['grd_id'] - 1) . '] == \'spremenljivka_'.$row['spr_id'].'_vrednost_' . $row['vre_id'] . '\' ';
+ elseif ($row2['design'] == 1 || get('mobile') > 0) // ostevilcevanje
+ $echo .= ' document.getElementsByName(\'spremenljivka_' . $row2['id'] . '_vrednost_' . $row['vre_id'] . '\')[0].value == \'' . ($row3['grd_id']) . '\' ';
+ elseif ($row2['design'] == 2 && get('mobile') == 0) // premikanje
+ $echo .= ' $(\'#sortzone_' . $row2['id'] . '\').sortable(\'toArray\')[' . ($row3['grd_id'] - 1) . '] == \'spremenljivka_'.$row['spr_id'].'_vrednost_' . $row['vre_id'] . '\' ';
+
+ }
+
+ $echo .= ' ) ';
+
+
+ // tabela text, tabela stevilo
+ } elseif ($row2['tip'] == 19 || $row2['tip'] == 20) {
+
+ $echo .= ' ( ';
+
+ $echo .= ' document.getElementById(\'vrednost_' . $row['vre_id'] . '_grid_' . $row['grd_id'] . '\').value';
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 2)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 3)
+ $echo .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $echo .= ' > ';
+ elseif ($row['operator'] == 5)
+ $echo .= ' >= ';
+
+
+ //if ($row['text'] == '')
+ $echo .= '"' . $row['text'] . '"';
+ /*else
+ $echo .= $row['text'];*/
+
+ $echo .= ' ) ';
+
+ // textbox
+ } elseif ($row2['tip'] == 21) {
+
+ $echo .= ' ( ';
+
+ if ($row['operator'] <= 5)
+ $echo .= 'document.getElementsByName(\'vrednost_' . $row['spr_id'] . '_kos_' . $row['vre_id'] . '\')[0].value';
+ else
+ $echo .= 'document.getElementsByName(\'vrednost_' . $row['spr_id'] . '_kos_' . $row['vre_id'] . '\')[0].value.length';
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 6)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 7)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 8)
+ $echo .= ' > ';
+
+ $echo .= '"' . $row['text'] . '"';
+
+ $echo .= ' ) ';
+
+ // number, compute in kvota majo drugacne pogoje in opcije
+ } elseif ($row2['tip'] == 4 || $row2['tip'] == 7 || $row2['tip'] == 22 || $row2['tip'] == 25) {
+
+ $echo .= ' ( ';
+
+ if ($row2['tip'] == 7) // number ma drugacen ID, ker ima lahko dva polja
+ $echo .= 'document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . ($row['grd_id'] + 1) . '\').value';
+ else
+ $echo .= 'document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value';
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 2)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 3)
+ $echo .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $echo .= ' > ';
+ elseif ($row['operator'] == 5)
+ $echo .= ' >= ';
+
+ if ($row2['tip'] == 4 || $row['operator'] == 0 || $row['operator'] == 1)
+ $echo .= '"' . $row['text'] . '"';
+ else {
+ if ($row['text'] == '')
+ $echo .= '"' . $row['text'] . '"';
+ else
+ $echo .= $row['text'];
+ }
+
+ $echo .= ' ) ';
+
+ // datum
+ } elseif ($row2['tip'] == 8) {
+
+ $echo .= ' ( ';
+
+ $echo .= 'Date.parse(convertDate(document.getElementById(\'vrednost_' . $row['spr_id'] . '\').value))';
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 2)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 3)
+ $echo .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $echo .= ' > ';
+ elseif ($row['operator'] == 5)
+ $echo .= ' >= ';
+
+ if ($row['text'] == '')
+ $echo .= '"' . $row['text'] . '"';
+ else
+ $echo .= 'Date.parse(convertDate("' . $row['text'] . '"))';
+
+ $echo .= ' ) ';
+
+ // vsota
+ } elseif ($row2['tip'] == 18) {
+
+ $echo .= ' ( ';
+
+ $echo .= 'document.getElementsByName(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['vre_id'] . '\')[0].value';
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 2)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 3)
+ $echo .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $echo .= ' > ';
+ elseif ($row['operator'] == 5)
+ $echo .= ' >= ';
+
+ if ($row['text'] == '')
+ $echo .= '"' . $row['text'] . '"';
+ else
+ $echo .= $row['text'];
+
+ $echo .= ' ) ';
+
+ }
+
+ // recnum
+ } elseif ($row['spr_id'] == -1) {
+
+ $echo .= ' ( _recnum % ' . $row['modul'] . ' == ' . $row['ostanek'] . ' ) ';
+
+ // calculations
+ } elseif ($row['spr_id'] == -2) {
+
+ $echo .= ' ( ';
+
+ $echo .= $this->generateCalculationJS($row['id']);
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 2)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 3)
+ $echo .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $echo .= ' > ';
+ elseif ($row['operator'] == 5)
+ $echo .= ' >= ';
+
+ if ($row['text'] == '')
+ $echo .= '"' . $row['text'] . '"';
+ else
+ $echo .= $row['text'];
+
+ $echo .= ' ) ';
+
+ // quotas
+ } elseif ($row['spr_id'] == -3) {
+
+ $quota = Check::getInstance()->checkQuota($row['id']);
+
+ $echo .= ' ( ';
+
+ $echo .= $quota;
+
+ if ($row['operator'] == 0)
+ $echo .= ' == ';
+ elseif ($row['operator'] == 1)
+ $echo .= ' !== ';
+ elseif ($row['operator'] == 2)
+ $echo .= ' < ';
+ elseif ($row['operator'] == 3)
+ $echo .= ' <= ';
+ elseif ($row['operator'] == 4)
+ $echo .= ' > ';
+ elseif ($row['operator'] == 5)
+ $echo .= ' >= ';
+
+ if ($row['text'] == '')
+ $echo .= '"' . $row['text'] . '"';
+ else
+ $echo .= $row['text'];
+
+ $echo .= ' ) ';
+
+ // naprava
+ } elseif ($row['spr_id'] == -4) {
+
+ if (in_array($row['text'], array('0','1','2','3'))){
+
+ // Star nacin detekcije - vedno vezan na prvi prihod, po novem detektiramo vsakic posebej
+ /*$sqlU = sisplet_query("SELECT device FROM srv_user WHERE ank_id='".get('anketa')."' AND id='".get('usr_id')."'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ $echo .= $row['text'] . ' == ' . $rowU['device'];*/
+
+ $device = 0;
+ $useragent = $_SERVER['HTTP_USER_AGENT'];
+
+ if ($useragent != '' && get_cfg_var('browscap')) {
+
+ $browser_detect = get_browser($useragent, true);
+
+ $detect = New Mobile_Detect();
+ $detect->setUserAgent($useragent);
+
+ // Detect naprave (pc, mobi, tablet, robot)
+ if ($detect->isMobile()) {
+ if ($detect->isTablet())
+ $device = 2;
+ else
+ $device = 1;
+ }
+ elseif ($browser_detect['crawler'] == 1){
+ $device = 3;
+ }
+ }
+
+ $echo .= ' ( ';
+ $echo .= $row['text'] . ' == ' . $device;
+ $echo .= ' ) ';
+ }
+ }
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $echo .= ' ) ';
+ }
+
+ // failsafe, ce se poklika if, pa se ne nastavi pogoja
+ if ($echo == '')
+ $echo .= ' true ';
+
+ echo $echo;
+ }
+
+ /**
+ * @desc zgenerira kalkulacijo za vstavitev v JS
+ */
+ public function generateCalculationJS($condition)
+ {
+ $calculationSpr = Cache::srv_spremenljivka(-$condition);
+
+ $sql = sisplet_query("SELECT * FROM srv_calculation WHERE cnd_id = '$condition' ORDER BY vrstni_red ASC");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+
+ $i = 0;
+ $expression = '';
+ while ($row = mysqli_fetch_array($sql)) {
+
+ if ($i++ != 0)
+ if ($row['operator'] == 0)
+ $expression .= ' + ';
+ elseif ($row['operator'] == 1)
+ $expression .= ' - ';
+ elseif ($row['operator'] == 2)
+ $expression .= ' * ';
+ elseif ($row['operator'] == 3)
+ $expression .= ' / ';
+
+ for ($i = 1; $i <= $row['left_bracket']; $i++)
+ $expression .= ' ( ';
+
+ // spremenljivke
+ if ($row['spr_id'] > 0) {
+
+ // obicne spremenljivke
+ if ($row['vre_id'] == 0) {
+ $row1 = Model::select_from_srv_spremenljivka($row['spr_id']);
+
+ $spr = $row1['id'];
+ $vre = 0;
+ $grd = $row['grd_id'];
+ $tip = $row1['tip'];
+ } // checkbox, multigrid
+ elseif ($row['vre_id'] > 0) {
+ $sql1 = sisplet_query("SELECT v.spr_id, v.id, s.tip AS tip FROM srv_vrednost v, srv_spremenljivka s WHERE v.id = '$row[vre_id]' AND v.spr_id=s.id");
+ if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
+
+ $row1 = mysqli_fetch_array($sql1);
+
+ $spr = $row1['spr_id'];
+ $vre = $row1['id'];
+ $tip = $row1['tip'];
+ $grd = $row['grd_id'];
+ } else {
+ $spr = 0;
+ $vre = 0;
+ $tip = 0;
+ $grd = 0;
+ }
+
+ // Preverimo kako obravnavamo missinge - posamezno kot 0 ali kot -88 za celo kalkulacijo
+ $newParams = new enkaParameters($calculationSpr['params']);
+ $calcMissing = $newParams->get('calcMissing', '0');
+
+ $expression .= " checkCalculation('{$spr}', '{$vre}', '{$grd}', '{$tip}', '{$calcMissing}') ";
+ }
+ // konstante
+ elseif ($row['spr_id'] == -1) {
+ $expression .= $row['number'];
+ }
+ // recnum
+ elseif ($row['spr_id'] == -2) {
+ $sqlu = sisplet_query("SELECT recnum FROM srv_user WHERE id='".get('usr_id')."'");
+ $rowu = mysqli_fetch_array($sqlu);
+
+ $expression .= $rowu['recnum'];
+ }
+
+ for ($i = 1; $i <= $row['right_bracket']; $i++)
+ $expression .= ' ) ';
+ }
+
+ // Zaokrozimo na doloceno stevilo decimalk
+ $decimals = $calculationSpr['decimalna'];
+ $expression = 'parseFloat((' . $expression . ').toFixed(' . $decimals . '))';
+
+ return '(' . $expression . ')';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/LanguageController.php b/main/survey/app/Controllers/LanguageController.php
new file mode 100644
index 0000000..ab47a41
--- /dev/null
+++ b/main/survey/app/Controllers/LanguageController.php
@@ -0,0 +1,196 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 18.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use SurveyInfo;
+
+class LanguageController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new LanguageController();
+ }
+
+ /************************************************
+ * Osnovne jezikovne datoteke
+ *
+ * @param $anketa
+ * @return
+ ************************************************/
+ public static function getLanguageFile()
+ {
+ global $lang;
+
+ if (get('anketa') > 0) {
+ SurveyInfo::getInstance()->SurveyInit(get('anketa'));
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+
+ $jezik = $row['lang_resp'];
+
+ } else {
+ $sql = sisplet_query("SELECT value FROM misc WHERE what = 'SurveyLang_resp'");
+ $row = mysqli_fetch_array($sql);
+
+ $jezik = $row['value'];
+ }
+
+ $file = lang_path($jezik);
+
+ if (@include($file)) {
+ $_SESSION['langX'] = lang_path($jezik, 1);
+ }
+ }
+
+
+ /**
+ * inicializacija multilang ankete. nastavljen mora biti usr_id ali $_GET[language]
+ *
+ */
+ public function multilang_init()
+ {
+ global $lang;
+
+ // mamo prebran cookie in user id, spremenimo language ce je treba -- multilanguage podpora je vezana na usr_id
+ $row = SurveyInfo::getInstance()->getSurveyRow();
+ if ($row['multilang'] == 1) {
+ if (isset($_GET['language'])) { // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu)
+
+ if (!empty(get('usr_id'))) { // (v bazo se shrani v displayintroduction - z ostalimi sistemskimi) (usr_id se ni postavljen)
+ $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$_GET[language]'");
+ $rowl = mysqli_fetch_array($sqll);
+ save('lang_id', $rowl['lang_id']);
+ } else { // v GETu, ko lahko v previewu spreminjamo jezik na strani (usr_id je ze postavljen)
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['id'] > 0)
+ $sql1 = sisplet_query("UPDATE srv_data_text" . get('db_table') . " dt SET text='$_GET[language]' WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ save('lang_id', $_GET['language']);
+ }
+
+ } elseif (isset($_POST['language'])) { // jezik podan v POSTu (ce si ga user spremeni na prvi strani)
+
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
+ $row1 = mysqli_fetch_array($sql1);
+ if ($row1['id'] > 0)
+ $sql1 = sisplet_query("UPDATE srv_data_text" . get('db_table') . " dt SET text='$_POST[language]' WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ save('lang_id', $_POST['language']);
+
+ } else { // jezik je ze shranjen v bazi, ga preberemo (naslednje strani)
+
+ $sqll = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " dt, srv_spremenljivka s WHERE dt.spr_id=s.id AND s.variable='language' AND dt.usr_id='" . get('usr_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+ $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$rowl[text]'");
+ $rowl = mysqli_fetch_array($sqll);
+ save('lang_id', $rowl['lang_id']);
+
+ }
+
+ if (get('lang_id') == null) { // ni bil podan preko GETa in ni shranjen v bazi -- priredimo default jezik
+ $_GET['language'] = self::$lang['id']; // to damo samo zato, da se shrani ID default jezika v bazo, namesto -1 (ker pri default jeziku ne podamo nič preko URLja)
+ // get('lang_id') mora se vedno ostati null !
+
+ } else { // zamenjamo jezik
+ $file = lang_path(get('lang_id'));
+ if (@include($file))
+ $_SESSION['langX'] = lang_path(get('lang_id'), 1);
+ }
+ }
+
+ }
+
+
+ /**
+ * prevod za srv_spremenljivka
+ */
+ public static function srv_language_spremenljivka($spremenljivka)
+ {
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT * FROM srv_language_spremenljivka WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ return $rowl;
+ }
+
+ return false;
+ }
+
+ /**
+ * vrne prevod za srv_vrednost
+ *
+ * @param mixed $vrednost
+ */
+ public function srv_language_vrednost($vrednost, $naslov2=false)
+ {
+
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT naslov, naslov2 FROM srv_language_vrednost WHERE ank_id='" . get('anketa') . "' AND vre_id='$vrednost' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ if($naslov2){
+ if ($rowl['naslov2'] != '')
+ return $rowl['naslov2'];
+ }
+ elseif ($rowl['naslov'] != ''){
+ return $rowl['naslov'];
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * vrne prevod za srv_grid
+ *
+ * @param mixed $vrednost
+ */
+ public static function srv_language_grid($spremenljivka, $grid)
+ {
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT naslov FROM srv_language_grid WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND grd_id='$grid' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ if ($rowl['naslov'] != '') return $rowl['naslov'];
+ }
+
+ return false;
+ }
+
+ /**
+ * vrne prevod podnaslova za dvojno tabelo
+ *
+ */
+ public static function srv_language_grid_podnaslov($spremenljivka, $grid)
+ {
+ if (get('lang_id') != null) {
+
+ $sqll = sisplet_query("SELECT podnaslov FROM srv_language_grid WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND grd_id='$grid' AND lang_id='" . get('lang_id') . "'");
+ $rowl = mysqli_fetch_array($sqll);
+
+ if ($rowl['podnaslov'] != '') return $rowl['podnaslov'];
+ }
+
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/StatisticController.php b/main/survey/app/Controllers/StatisticController.php
new file mode 100644
index 0000000..00b01c2
--- /dev/null
+++ b/main/survey/app/Controllers/StatisticController.php
@@ -0,0 +1,282 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 26.02.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Models\Model;
+use SurveyInfo;
+
+class StatisticController extends Controller
+{
+
+ /**
+ * @desc poisce vprasanja, ki imajo statistiko in jih poklice
+ */
+ public static function displayStatistika($konec = false)
+ {
+
+ $sql = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id = '" . get('grupa') . "'");
+ $row = mysqli_fetch_array($sql);
+ $vrstni_red = $row['vrstni_red'];
+
+ if ($konec) $vrstni_red = 99999999;
+
+ //preverimo ce gre za glasovanje ali navadno anketo
+ $rowA = SurveyInfo::getInstance()->getSurveyRow();
+
+ //statistika za glasovanje
+ if ($rowA['survey_type'] == 0) {
+
+ if (get('printPreview')) {
+ $sql2 = sisplet_query("SELECT ank_id, spr_id, show_title FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $spremenljivka = $row2['spr_id'];
+
+ $sqla = sisplet_query("SELECT starts, expire, statistics, db_table FROM srv_anketa WHERE id ='$row2[ank_id]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $text = $rowa['statistics'];
+
+ if ($text != '')
+ echo ' <h3>' . $text . "\n";
+ else
+ echo ' <h3>' . "\n";
+
+ if ($row2['show_title'] == 0)
+ echo ' ' . $row['naslov'] . '</h3>' . "\n";
+ else
+ echo ' </h3>' . "\n";
+ } else {
+ $sqlG = sisplet_query("SELECT spr_id FROM srv_glasovanje WHERE ank_id='" . get('anketa') . "'");
+ $rowG = mysqli_fetch_array($sqlG);
+
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $prev_grupa = $row['id'];
+
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$prev_grupa' AND stat>'0' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ echo ' <div class="spremenljivka" id="spremenljivka_statistika">' . "\n";
+ self::displayStatGlasovanje($rowG['spr_id']);
+ echo ' </div>' . "\n";
+ }
+ }
+ }
+ } //navadna statistika
+ else {
+ $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='" . get('anketa') . "' AND vrstni_red<'$vrstni_red' ORDER BY vrstni_red DESC LIMIT 1");
+ if (mysqli_num_rows($sql) > 0) {
+ $row = mysqli_fetch_array($sql);
+ $prev_grupa = $row['id'];
+
+ $sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='$prev_grupa' AND stat='1' ORDER BY vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ echo ' <div class="spremenljivka" id="spremenljivka_statistika">' . "\n";
+ self::displayStat($row['id']);
+ echo ' </div>' . "\n";
+ }
+ }
+ }
+
+ }
+
+ /**
+ * @desc prikaze statistike za odgovor
+ */
+ public static function displayStat($spremenljivka, $spol = 0)
+ {
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $text = $lang['results'];
+
+ echo ' <h3>' . $text . ': ' . $row['naslov'] . '</h3>' . "\n";
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_vrednost v, srv_data_vrednost" . get('db_table') . " d WHERE v.spr_id='$spremenljivka' AND v.id=d.vre_id");
+ $row = mysqli_fetch_array($sql);
+ $total = $row['count'];
+
+ $sql = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red");
+ while ($row = mysqli_fetch_array($sql)) {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " WHERE vre_id='$row[id]'");
+ $row1 = mysqli_fetch_array($sql1);
+
+
+ if ($total > 0)
+ $procent = round($row1['count'] / $total, 3) * 100;
+ else
+ $procent = 0;
+
+ echo ' <p><strong>' . $row['naslov'] . ':</strong> ' . $procent . '%</p>' . "\n";
+ }
+ }
+
+ /**
+ * @desc prikaze statistiko za glasovanje
+ */
+ public function displayStatGlasovanje($spremenljivka, $spol = 0)
+ {
+ global $lang;
+ global $site_url;
+ global $global_user_id;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ //preverimo ce gre za glasovanje
+ $sql2 = sisplet_query("SELECT * FROM srv_glasovanje WHERE spr_id='$spremenljivka'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $sqla = sisplet_query("SELECT starts, expire, statistics, db_table FROM srv_anketa WHERE id ='$row2[ank_id]'");
+ $rowa = mysqli_fetch_array($sqla);
+
+ if ($rowa['db_table'] == 1)
+ save('db_table', '_active');
+
+ $text = $rowa['statistics'];
+
+ if ($text != '')
+ echo ' <span class="glas_settings_title">' . $text . "\n";
+ else
+ echo ' <span class="glas_settings_title">' . "\n";
+
+ if ($row2['show_title'] == 0)
+ echo ' ' . $row['naslov'] . '</span>' . "\n";
+ else
+ echo ' </span>' . "\n";
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_vrednost v, srv_data_vrednost" . get('db_table') . " d WHERE v.spr_id='$spremenljivka' AND v.id=d.vre_id");
+ $row = mysqli_fetch_array($sql);
+ $total = $row['count'];
+
+ $sql = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red");
+ while ($row = mysqli_fetch_array($sql)) {
+
+ //prikaz statistike za moske(pri glasovanju)
+ if ($spol == 1) {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " v, srv_data_glasovanje g WHERE v.vre_id='$row[id]' AND v.usr_id=g.usr_id AND g.spr_id='$spremenljivka' AND g.spol='1' ");
+ $row1 = mysqli_fetch_array($sql1);
+ } //prikaz statistike za zenske(pri glasovanju)
+ elseif ($spol == 2) {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " v, srv_data_glasovanje g WHERE v.vre_id='$row[id]' AND v.usr_id=g.usr_id AND g.spr_id='$spremenljivka' AND g.spol='2' ");
+ $row1 = mysqli_fetch_array($sql1);
+ } else {
+ $sql1 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_vrednost" . get('db_table') . " WHERE vre_id='$row[id]'");
+ $row1 = mysqli_fetch_array($sql1);
+ }
+
+ if ($total > 0)
+ $procent = round($row1['count'] / $total, 3) * 100;
+ else
+ $procent = 0;
+
+ echo ' <p style="margin-top: 10px;"><strong>' . $row['naslov'] . ':</strong>' . "\n";
+
+
+ //ce gre za glasovanje in imamo nastavljen prikaz grafa ga izrisemo
+ if ($row2['show_graph'] == 1) {
+
+ echo '</p>';
+
+ echo ' <div "style=" margin: -20px 0 0 25%; text-align: right; width: 25%; font-size: 12px;">' . "\n";
+ if ($row2['show_results'] == 1) {
+ echo $row1['count'];
+ if ($row2['show_percent'] == 1)
+ echo ' (' . $procent . '%)';
+ } elseif ($row2['show_percent'] == 1)
+ echo $procent . '%';
+ echo ' </div>' . "\n";
+
+ echo '<div id="graph"><div class="graph_fill" style="width: ' . $procent . '%;"></div></div>';
+ } else {
+ if ($row2['show_results'] == 1) {
+ echo $row1['count'];
+ if ($row2['show_percent'] == 1)
+ echo ' (' . $procent . '%)';
+ } elseif ($row2['show_percent'] == 1)
+ echo $procent . '%';
+ echo '</p>';
+ }
+ }
+
+ //stevilo vseh glasov
+ if ($row2['stat_count'] == 1) {
+ if ($spol != 0) {
+ $sql5 = sisplet_query("SELECT COUNT(*) AS count FROM srv_data_glasovanje WHERE spr_id='$spremenljivka' AND spol='1' ");
+ $row5 = mysqli_fetch_array($sql5);
+ $moskih_glasov = $row5['count'];
+
+ if ($spol == 1) {
+ $percent = round($moskih_glasov / $total, 3) * 100;
+ $total = $moskih_glasov;
+ } else {
+ $percent = round(($total - $moskih_glasov) / $total, 3) * 100;
+ $total = $total - $moskih_glasov;
+ }
+ }
+
+ echo '<p style="margin-top: 10px;">' . $lang['glasovanja_count'] . ': ' . $total;
+ if ($spol != 0)
+ echo ' (' . $percent . '%)';
+ echo '</p>';
+ }
+
+ //cas aktivnosti ankete
+ if ($row2['stat_time'] == 1) {
+ $start = strtotime($rowa['starts']);
+ $end = strtotime($rowa['expire']);
+ echo '<p>' . $lang['glasovanja_time'] . ' ' . date("m.d.Y", $start) . ' ' . $lang['glasovanja_time_end'] . ' ' . date("m.d.Y", $end) . '</p>';
+ }
+
+ //prikaz statistike po spolu (samo kjer je nastavljena opcija izbira spola) - gumbi za preklop
+ if ($row2['spol'] == 1) {
+ echo '<div class="spol_buttons">' . "\n";
+
+ if ($spol == 0) echo '<input type="button" class="active" value="' . $lang['hour_all'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'0\');">';
+ else echo '<input type="button" value="' . $lang['hour_all'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'0\');">';
+
+ if ($spol == 1) echo '<input type="button" class="active" value="' . $lang['glasovanja_spol_moski'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'1\');">';
+ else echo '<input type="button" value="' . $lang['glasovanja_spol_moski'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'1\');">';
+
+ if ($spol == 2) echo '<input type="button" class="active" value="' . $lang['glasovanja_spol_zenske'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'2\');">';
+ else echo '<input type="button" value="' . $lang['glasovanja_spol_zenske'] . '" onClick="stat_spol(\'' . $spremenljivka . '\', \'2\');">';
+
+ echo '</div>' . "\n";
+ }
+
+ //prikaz arhiva statistik anket
+ if ($row2['stat_archive'] == 1) {
+
+ echo '<div id="arhiv">';
+ echo 'Ankete iz arhiva:';
+
+ $sqlArchive = sisplet_query("SELECT ank_id FROM srv_glasovanje WHERE stat_archive = '1' AND ank_id != '$row2[ank_id]'");
+
+ echo '<ul>';
+ while ($rowArchive = mysqli_fetch_array($sqlArchive)) {
+ $sql4 = sisplet_query("SELECT naslov, starts, insert_uid FROM srv_anketa WHERE id = '$rowArchive[ank_id]'");
+ $row4 = mysqli_fetch_array($sql4);
+
+ if($row4['insert_uid'] == $global_user_id){
+ echo '<li>';
+
+ echo '<a href="' . $site_url . 'a/' . $rowArchive['ank_id'] . '&glas_end=0' . get('cookie_url') . '">' . $row4['naslov'] . '</a>';
+ echo ' (' . $row4['starts'] . ')';
+
+ echo '</li>';
+ }
+ }
+ echo '</ul>';
+ echo '</div>';
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/SurveyController.php b/main/survey/app/Controllers/SurveyController.php
new file mode 100644
index 0000000..558f2ad
--- /dev/null
+++ b/main/survey/app/Controllers/SurveyController.php
@@ -0,0 +1,76 @@
+<?php
+/***************************************
+ * Description: Glavni razred pri main survey, ki skrbi za klice vseh ostalih razredov, ki nato sestavijo prikaz ankete
+ * Autor: Robert Šmalc
+ * Created date: 22.01.2016
+ *****************************************/
+
+namespace App\Controllers;
+
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\InitClass as Init;
+use App\Controllers\LanguageController as Language;
+use SurveyMissingValues;
+use SurveySetting;
+
+class SurveyController extends Controller
+{
+ private $printPreviewSet;
+
+ public function __construct($printPreviewSet = false)
+ {
+ // Pridobimo vse globalne spremenljivke
+ parent::getGlobalVariables();
+
+ // Pridobimo spremenljivke za Header
+ $this->getHeader();
+
+ // Shranimo pvrednost predogleda
+ save('printPreview', $printPreviewSet);
+
+ if (isset($this->get->pages) && $this->get->pages == 'all')
+ save('displayAllPages', true);
+
+ save('mobile', Helper::mobile());
+
+ // Pridobimo datoteko za jezike
+ Language::getLanguageFile();
+
+ // Ali imamo perdogled že rešene ankete
+ if (isset($this->get->quick_view) && $this->get->quick_view == 1)
+ save('quick_view', true);
+
+ // Če je arhivirano pošiljanje emailov
+ if (isset($this->get->ai) && (int)$this->get->ai > 0)
+ save('user_inv_archive', (int)$this->get->ai);
+
+ // Poiščemo missing vrednosti ankete smv
+ save('smv', new SurveyMissingValues(get('anketa')));
+
+ // Če imamo izklopljeno mobilno prilagajanje, potem ignoriramo mobitele in vedno prikazemo vse enako
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_friendly = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_friendly');
+ if ($mobile_friendly == 0)
+ save('mobile', 0);
+
+ // Inicializacija vsega
+ new Init();
+ }
+
+ /************************************************
+ * Poberemo spremenljivke iz get requestov in piškotkov
+ ************************************************/
+ public function getHeader()
+ {
+ $header = new Header();
+
+ // Pridobimo vse GET parametre
+ $this->get = $header->getAllUrlParameters();
+
+ //Pridobimo vse $_COOKIE paramletre
+ $this->cookie = $header->getAllCookieParameters();
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/VariableClass.php b/main/survey/app/Controllers/VariableClass.php
new file mode 100644
index 0000000..93c1c69
--- /dev/null
+++ b/main/survey/app/Controllers/VariableClass.php
@@ -0,0 +1,193 @@
+<?php
+/***************************************
+ * Description: Služi kot seznam vseh globalnih spremenljivk, ki se uporabljajo v Main Survey in jih potem tudi definiramo v Controllerju
+ * Autor: Robert Šmalc
+ * Created date: 29.01.2016
+ *****************************************/
+
+
+namespace App\Controllers;
+
+
+class VariableClass
+{
+ protected static $_configuration = array(
+ 'anketa' => null, // trenutna anketa
+ 'get' => null, // tukaj poberemo vse get parametre, ki se pošiljajo preko GET ali POST in jih dodamo v spremenljivko
+ 'grupa' => null, // trenutna grupa
+ 'spremenljivka' => null, // trenutna spremenljivka
+ 'usr_id' => null, // ID trenutnega uporabnika
+ 'cookie_expire' => null, // nastavitev kdaj expira cookie, da vemo za primer brez cookie-ja, da prenasamo preko urlja
+ 'cookie_url' => null, // kadar cookie prenasamo po URLju, se v to spremenljivko zapise koda, ki jo dodamo vsakemu linku ($_GET)
+ 'printPreview' => false, // ali kliče konstruktor
+ 'hierarhija' => null, // če gre za hierarhijo potem poberemo get parametre
+
+ /** prisilimo prikaz spremenljivke, za predogled vanalizah in mogoče še kje
+ *
+ * @public boolean
+ */
+ 'forceShowSpremenljivka' => false,
+ 'db_table' => '',
+ 'ime_AW' => null, // trenutno ime, ki se reseuje (socialna omrezja - alterwise)
+ 'loop_AW' => null,
+ 'loop_id' => null, // vrednost po kateri loopamo, ce smo v loopu
+ 'lang_id' => null,
+ 'language' => '1',
+ 'smv' => null, // misnig vrednosti od ankete
+ 'mobile' => 0, // 0 - klasicna, 1 - mobilna, 2 - dlancniki
+ 'ismobile' => 0, // detekcija, ce je mobilna naprava
+
+ 'quick_view' => false, // ali smo samo v predogledu ankete od uporabnika
+ 'user_inv_archive' => 0, // id_arhiva vabil (če smo preko vabil)
+ 'displayAllPages' => false, // ali smo v predogledu kjer izpisujemo vse strani
+ 'webSMSurvey' => '34862', // WebSM anketa, ki ne shranjuje nicesar in skoci na pravo stran (gru_id) glede na url
+ 'generateComputeJS' => '',
+
+ /**
+ * @desc vrne array vseh spremenljivk vgnezdenih v podanem ifu
+ */
+ 'getElements' => array(),
+ 'checkSpremenljivka' => array(),
+ 'checkIf' => array(),
+ 'getGrupa' => array(),
+ 'preskocena_first' => 1, // spremenljivka, da pri preskocenih straneh ne delamo vsakic vseh querijev (ampak samo prvic)
+ 'cache_srv_data_grid' => '', // ostale spremenljivke so cache, ki se v posted() polni in zapise v bazo v posted_commit()
+ 'cache_srv_data_vrednost' => '',
+ 'cache_srv_data_text' => '',
+ 'cache_srv_data_checkgrid' => '',
+ 'cache_srv_data_textgrid' => '',
+ 'cache_srv_data_rating' => '',
+ 'cache_srv_data_vrednost_cond' => '',
+ 'cache_srv_data_map' => '',
+ 'cache_srv_data_heatmap' => '',
+ 'cache_delete' => '',
+ 'lurker' => -1,
+ 'getOtherValue' => array(),
+ 'select_from_srv_spremenljivka' => array(),
+
+ // Naknadno dodane globalne spremenljivke
+ 'userAutor' => false
+ );
+
+ protected $key, $value, $return;
+
+ // Shrani novo vrednost na obstoječo spremenljivko ali doda novo spremenljivko
+ public static function save($key, $value)
+ {
+ // Ce shranjujemo anketa_id ('anketa') jo najprej dekodiramo ce je potrebno
+ if($key == 'anketa'){
+ $value = self::decryptAnketaID($value);
+ }
+
+ $polje = self::izStringaVpolje($key);
+ if ($polje){
+ self::$_configuration[ $polje['spremenljivka'][0] ][ $polje['key'][0] ] = $value;
+ } else {
+ self::$_configuration[$key] = $value;
+ };
+ }
+
+ // Popravimo id ankete ce gre za kodiranega (pri novih anketah je v url-ju kodiran id ankete da respondenti ne morejo dostopati do drugih anket)
+ private static function decryptAnketaID($anketa){
+
+ // Ce anketa ni numeric jo pretvorimo v originalen id
+ if(!is_numeric($anketa)){
+
+ $anketa_arr = str_split($anketa);
+ $anketa_id = '';
+
+ foreach($anketa_arr as $pos => $char){
+ // Na lihih mestih pretvorimo crko nazaj v stevilko
+ if($pos % 2 == 0)
+ $anketa_id .= ord($char) - 97;
+ else
+ $anketa_id .= $char;
+ }
+ }
+ else
+ $anketa_id = $anketa;
+
+ return $anketa_id;
+ }
+
+ /************************************************
+ * Funkcija iz stringa naredi polje z id vrednostjo
+ * primer (string) 'polje[id]' uredi v (arrey) polje[id]
+ * @return array()
+ ************************************************/
+ private static function izStringaVpolje($string)
+ {
+ // spremenljivka je mišljen tekst, ki je pred oklepaji
+ $spremenljivka = array();
+ // key je vrednost oz. id te spremenljivke, ki je med []
+ $key = array();
+
+ $t = "";
+ for ($i = 0; $i < strlen($string); $i++) {
+ if ($string[$i] == '[') {
+ $spremenljivka[] = $t;
+ $t = "";
+ $t1 = "";
+ $i++;
+ while ($string[$i] != ']') {
+ $t1 .= $string[$i];
+ $i++;
+ }
+ $key[] = $t1;
+
+ } else {
+ if ($string[$i] != ']')
+ $t .= $string[$i];
+ else {
+ continue;
+ }
+
+ }
+ }
+
+ // V kolikor je samo string
+ if ($t != "")
+ return false;
+
+ return [
+ 'spremenljivka' => $spremenljivka,
+ 'key' => $key
+ ];
+ }
+
+
+ // Dodamo vrednost k že obstoječi vrednosti
+ public static function add($key, $value, $return = null)
+ {
+ self::$_configuration[$key] .= $value;
+
+ if (!is_null($return))
+ return $value;
+ }
+
+ public static function get($key)
+ {
+ return self::$_configuration[$key];
+ }
+
+ public static function getAll()
+ {
+ return self::$_configuration;
+ }
+
+ /************************************************
+ * Pridobimo vse variable, ki se uporabljajo za main/survey in jih dodamo na Controller -> $this variable
+ *
+ * @return $this
+ ************************************************/
+ public function refresh()
+ {
+ foreach (self::$_configuration as $key => $value) {
+ $this->$key = $value;
+ }
+
+ return $this;
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/ComputeController.php b/main/survey/app/Controllers/Vprasanja/ComputeController.php
new file mode 100644
index 0000000..d3c9353
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/ComputeController.php
@@ -0,0 +1,55 @@
+<?php
+/***************************************
+ * Description: Compute
+ *
+ * Vprašanje je prisotno:
+ * tip 25
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\JsController as Js;
+use App\Models\Model;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+
+class ComputeController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new ComputeController();
+ }
+
+ public function display($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+ echo ' <input type="text" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" value="' . $row1['text'] . '">';
+
+ Js::getInstance()->generateCompute($spremenljivka);
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DatumController.php b/main/survey/app/Controllers/Vprasanja/DatumController.php
new file mode 100644
index 0000000..21552b5
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DatumController.php
@@ -0,0 +1,187 @@
+<?php
+/***************************************
+ * Description: Datum
+ *
+ * Vprašanje je prisotno:
+ * tip 8
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+class DatumController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DatumController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ # pogledamo ali imamo kak zapis v srv_data_vrednost. potem je to najbrž missing
+ $is_missing = false;
+ $srv_data_vrednost = array();
+ # če je bilo vprašanje preskočeno se je vs srv_data_vrednost zapisalo -2, če se potem uporabnik vrne, in spremeni pogojno vprašanje
+ # se potem datum ni prikazoval. ke je bilo v bazi -2, zato sem dal da naj poišče samo če vrednost ni -2
+ $sql2_c = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id AND vre_id NOT IN ('-1','-2')");
+ while ($row2_c = mysqli_fetch_assoc($sql2_c)) {
+ $srv_data_vrednost[$row2_c['vre_id']] = true;
+ $is_missing = true;
+ }
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">' . "\n";
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+
+ echo '<input type="text" id="vrednost_' . $spremenljivka . '" name="vrednost_' . $spremenljivka . '" value="' . $row1['text'] . '"
+ onkeyup="checkBranching();" ' . ($is_missing ? ' disabled' : '') . ' readonly="true"> ';
+
+ echo '</div>' . "\n";
+
+ $array_others = array();
+ $sql_other = sisplet_query("SELECT id,naslov FROM srv_vrednost WHERE spr_id='$spremenljivka' AND vrstni_red > 0 AND other != '0' ORDER BY vrstni_red");
+ while ($other = mysqli_fetch_array($sql_other)) {
+ # imamo polje drugo - ne vem, zavrnil...
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $other['id'];
+
+ if ($srv_data_vrednost[$other['id']]) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu
+ $_checked = ($sel ? ' checked' : '');
+
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+
+ $already_set_mv = array();
+ $sql_grid_mv = sisplet_query("SELECT naslov, other FROM srv_vrednost WHERE spr_id='" . $spremenljivka . "' AND other != 0");
+ while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) {
+ $already_set_mv[$row_grid_mv['other']] = $row_grid_mv['naslov'];
+ }
+
+ if ((($row['alert_show_99'] > 0 && isset($already_set_mv['-99']) && $already_set_mv['-99'] == $other['naslov'])
+ || ($row['alert_show_98'] > 0 && isset($already_set_mv['-98']) && $already_set_mv['-98'] == $other['naslov'])
+ || ($row['alert_show_97'] > 0 && isset($already_set_mv['-97']) && $already_set_mv['-97'] == $other['naslov']))
+ && $_checked == ''
+ )
+ $hide_missing = true;
+
+ $naslov = Language::getInstance()->srv_language_vrednost($other['id']);
+ if ($naslov != '') $other['naslov'] = $naslov;
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' missing" id="vrednost_if_' . $other['id'] . '"' . ' ' . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '">';
+ echo '<input type="checkbox" name="vrednost_mv_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $other['id'] . '"' . $_checked . ' onclick="checkBranching(); checkMissing(this);"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $other['naslov'] . '</label>';
+ echo '</div>';
+ }
+
+
+ # če smo v quick_view mode ne omogočamo
+ if (get('quick_view') == false) {
+ $date_element = "#vrednost_" . $spremenljivka;
+
+ // Ce izbiramo tudi cas - V DELU
+ $timepicker = ($spremenljivkaParams->get('date_withTime') > 0) ? 'true' : 'false';
+
+ ?>
+ <script type="text/javascript">
+ $(document).ready(function () {
+ datepicker("<?=$date_element?>", <?=($_GET['a'] != 'preview_spremenljivka' ? 'true' : 'false')?>, <?=$timepicker?>);
+
+
+ <?php
+ # dodamo date range
+ echo Helper::getDatepickerRange($spremenljivka, $date_element);
+
+ echo '$( "' . $date_element . '" ).datepicker( "option", "closeText", \'' . self::$lang['srv_clear'] . '\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showOn", \'button\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showButtonPanel", true);';
+
+ // Gumb pocisti vrednost na dnu
+ echo '$("' . $date_element . '").datepicker( "option", {
+ beforeShow: function( input ) {
+ setTimeout(function() {
+ var clearButton = $(input )
+ .datepicker( "widget" )
+ .find( ".ui-datepicker-close" );
+ clearButton.unbind("click").bind("click",function(){$.datepicker._clearDate( input );});
+ }, 1 );
+ }
+ });';
+
+ // Moznost, da so disablani specificni datumi - V DELU
+ if(false){
+
+ $disabled_dates = array('01-01-2017', '03-01-2017');
+
+ // Ce imamo kaksen datum nastavljen
+ if(!empty($disabled_dates)){
+ $disabled_dates_string = implode('","', $disabled_dates);
+ $disabled_dates_string = '"'.$disabled_dates_string.'"';
+
+ echo '$("' . $date_element . '").datepicker("option", "beforeShowDay", DisableSpecificDates);';
+
+ echo 'function DisableSpecificDates(date) {
+ var disableddates = ['.$disabled_dates_string.'];
+
+ var string = jQuery.datepicker.formatDate(\'dd-mm-yy\', date);
+ return [disableddates.indexOf(string) == -1];
+ }';
+ }
+ }
+
+ // TODO zakaj je tole? - $condition manjka in itak ne dela
+ # mogoče za missinge pr datumu ??
+ /*echo
+ '$("input#text_' . $condition . '").bind("keyup", {}, function(e) {' .
+ ' checkBranchingDate(); $(\'#vrednost_' . $spremenljivka . '\').trigger(\'change\'); return false; ' .
+ '});';*/
+ ?>
+ });
+
+ </script>
+ <?php
+
+ }
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DoubleController.php b/main/survey/app/Controllers/Vprasanja/DoubleController.php
new file mode 100644
index 0000000..b357be3
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DoubleController.php
@@ -0,0 +1,841 @@
+<?php
+/***************************************
+ * Description: Dobule grid in double checkbox
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 3
+ * tip 16 - enota 3
+ *
+ * Izris dvojnega multigrida/multicheckboxa
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+
+class DoubleController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DoubleController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za doublegrid
+ */
+ public function grid($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loop spremenljivkah, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+ // izracuni za sirino celic
+ $size = 2 * $row['grids'];
+ $colspan = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='1' ORDER BY vrstni_red");
+
+ $space = false;
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ $colspan++;
+
+ if (!$space) {
+ $colspan++;
+ $space = true;
+ }
+ }
+
+ }
+
+ //se za desni del grida
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='2' ORDER BY vrstni_red");
+
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ //$naslov = Language::srv_language_grid($row['id'], $row_grid2['id']);
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+ }
+
+ $indexLanguage++;
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table doublegrid">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '<col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ //izpis podnaslovov posameznih delov grida
+ # priredimo podnaslovov če je prevod ankete
+ $podnaslov1 = Language::srv_language_grid_podnaslov($row['id'], 1);
+ $podnaslov2 = Language::srv_language_grid_podnaslov($row['id'], 2);
+ if ($podnaslov1 != '') {
+ $row['grid_subtitle1'] = $podnaslov1;
+ }
+ if ($podnaslov2 != '') {
+ $row['grid_subtitle2'] = $podnaslov2;
+ }
+ # priredimo podnaslovov če je prevod ankete - konec
+
+ echo ' <tr>' . "\n\r";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle1'] . '</td>' . "\n";
+ echo ' <td></td>';
+ echo ' <td></td>';
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle2'] . '</td>' . "\n";
+ echo ' </tr>' . "\n\r";
+
+ echo ' <tr>' . "\n\r";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+
+ #double grid space
+ echo '<td></td>';
+ echo '<td class="double"></td>';
+
+ //se za desni del grida
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja) - za part 1
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='1' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+ # cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja) - za part 2
+ $srv_data_grid2 = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='2' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid2[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ $grid_id2 = $srv_data_grid2[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</td>' . "\n";
+ echo '<td></td>' . "\n";
+ }
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+ # izpišemo radio grida
+
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<td class="missing">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ # ni missing vrednost
+ echo '<td class="category">';
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ }
+ }
+
+ #double grid space
+ echo '<td></td>';
+ echo '<td class="double"></td>';
+
+
+ //DESNI DEL GRIDA
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids2) > 0) {
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids2[$i]['id'] == $grid_id2) {
+ $is_missing = true;
+ }
+ }
+ }
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids2[$i]['id'];
+ # izpišemo radio grida
+
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<td class="missing">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . (($grid_id2 == $value && $grid_id2 != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ # ni missing vrednost
+ echo '<td class="category">';
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . (($grid_id2 == $value && $grid_id2 != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids2[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+ /**
+ * @desc prikaze vnosno polje za doublecheckgrid - TODO!!
+ */
+ public function checkGrid($spremenljivka)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // izracuni za sirino celic
+ $size = 2 * $row['grids'];
+ $colspan = $row['grids'];
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hideLabels == false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+
+ $css = ' style = "width: ' . $gridWidth . '%;" ';
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids1 = array();
+ $srv_grids2 = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ //$sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY part, vrstni_red");
+ $sql_grid1 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part = '1' ORDER BY vrstni_red");
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part = '2' ORDER BY vrstni_red");
+
+ $space = false;
+
+ //levi del
+ while ($row_grid1 = mysqli_fetch_assoc($sql_grid1)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid1['id']);
+ if ($naslov != '') {
+ $row_grid1['naslov'] = $naslov;
+ }
+ $srv_grids1[$row_grid1['id']] = $row_grid1;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid1['other'] != 0) {
+ $mv_count++;
+
+ if ($row_grid1['part'] == 1)
+ $colspan++;
+
+ if (!$space) {
+ $colspan++;
+ $space = true;
+ }
+ }
+ }
+
+ //desni del
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+
+ if ($row_grid2['part'] == 1)
+ $colspan++;
+
+ if (!$space) {
+ $colspan++;
+ $space = true;
+ }
+ }
+ $indexLanguage++;
+ }
+
+ echo ' <table class="grid_table doublecheckgrid">' . "\n";
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '<col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count / 2; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ //ipis podnaslovom posameznih delv grida
+ echo ' <tr>' . "\n\r";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle1'] . '</td>' . "\n";
+ echo ' <td></td>';
+ echo ' <td></td>';
+ echo ' <td colspan="' . $colspan . '">' . $row['grid_subtitle2'] . '</td>' . "\n";
+ echo ' </tr>' . "\n\r";
+
+ echo ' <tr>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ # če imamo enoto povečamo št. stoplcev
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ //ce imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30)
+ $cellsize = round(80 / $size);
+ else
+ $cellsize = 'auto';
+
+ $spacesize = round(80 / $size / 4);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $taHeight = ($spremenljivkaParams->get('taHeight') ? $spremenljivkaParams->get('taHeight') : 1);
+ //default sirina
+ if ($taWidth == -1)
+ //$taWidth = 10;
+ $taWidth = round(50 / $size);
+
+ $bg = 1;
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids1) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids1 AS $g_id => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+
+ //vmesno polje z mejo
+ if ($count == $colspan) {
+ echo '<td></td><td class="double"></td>';
+ $first_missing_value = true;
+ }
+ $count++;
+ }
+ }
+
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids2 AS $g_id => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ $count++;
+ }
+ }
+
+
+
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $srv_data_cache = array();
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids1) > 0) {
+ foreach ($srv_grids1 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids1[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ if (count($srv_grids2) > 0) {
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids2[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' : '').'>';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ if (count($srv_grids1) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids1 AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+ # izpišemo labelo grida
+ if ($srv_grid['other'] != 0) {
+ # imamo missing polje
+ echo '<td class="missing">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+
+ //vmesno polje z mejo
+ if ($count == $colspan) {
+ echo '<td></td><td class="double"></td>';
+ $first_missing_value = true;
+ }
+ $count++;
+ }
+ }
+
+ if (count($srv_grids2) > 0) {
+ $first_missing_value = true;
+ $count = 1;
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+
+ $count++;
+ }
+ # izpišemo labelo grida
+ if ($srv_grid['other'] != 0) {
+ # imamo missing polje
+ echo '<td class="missing">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ $count++;
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo ' </table>' . "\n";
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DragDropController.php b/main/survey/app/Controllers/Vprasanja/DragDropController.php
new file mode 100644
index 0000000..4b4f4bc
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DragDropController.php
@@ -0,0 +1,914 @@
+<?php
+/***************************************
+ * Description: Prikaže vprašanje Drag and drop (multigrid, multicheckbox, radio, checkbox, select
+ *
+ * Vprašanje je prisotno:
+ * tip 16 - enota 9 in enota 3
+ * tip 6 - enota 9
+ * tip 1, 2, 3 - orientation 8
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+
+// Iz admin/survey
+use enkaParameters;
+use SurveySetting;
+use Common;
+
+
+// Vprašanja
+
+class DragDropController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DragDropController();
+ }
+
+ /**
+ * @desc prikaze vnos za drag-drop
+ */
+ public function display($spremenljivka)
+ {
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ // Pri WebSM anketi nimamo userja, zato ne izvajamo ajaxa
+ $ajax = 'true';
+ $usr_id = get('usr_id');
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+ $ajax = 'false';
+ $usr_id = 0;
+ }
+
+ // Pri vpogledu moramo deaktivirati canvas in tipke (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+ //n>k // prestavljanje
+ //if ($row['design'] == 0 && get('mobile') == 0){
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+
+ //izracun visine
+ $num = mysqli_num_rows($sql1); //stevilo trenutnih kategorij odgovorov v levem bloku
+ $size = $num * 37;
+
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ //echo '<div id="vrednost_if_'.$row1['id'].'">';
+ echo '<table class="ranking_table">';
+ echo '<tr>';
+ //zaslon razdelimo na dva dela - izris leve strani
+ echo '<td>';
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_ranking_avaliable_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_avaliable_categories' . $_lang);
+ if ($srv_ranking_avaliable_categories == '') $srv_ranking_avaliable_categories = self::$lang['srv_ranking_avaliable_categories'];
+
+ echo '<b>' . $srv_ranking_avaliable_categories . ':</b>';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone" style="height:' . $size . 'px">';
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ echo '<ul>';
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>';
+ }
+
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ //$this->display_DropBox($row1['naslov'], $row1['id']);
+ $value = $row1['naslov'];
+
+ // Datapiping
+ $value = Helper::dataPiping($value);
+
+ $vre_id = $row1['id'];
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row1['other']; //drugo, po navadi missing
+
+ //********* potrebno za pravilno prikazovanje predogleda
+
+ if(isset($_GET['a'])){
+ if($_GET['a'] == 'preview_spremenljivka'){
+ $preview_spremenljivka = 1;
+ echo '
+ <script>
+ var usr_id = 0;
+ </script>
+ ';
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ //********* potrebno za pravilno prikazovanje predogleda - konec
+
+ ?>
+ <script>
+ draggableOnDroppable[<?=$vre_id?>] = false; //inicializacija spremenljivke, ki belezi, ali je odgovor prisoten v ustreznem kontejnerju
+ draggableOver[<?=$spremenljivka?>] = false;
+
+ $(document).ready(function () {
+ Draggable(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$other?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ //echo '<div id="vrednost_if_'.$id.'" class="variabla">';
+ //echo '</div>'; //vrednost_if_ID
+ //div ki vsebuje vrednost
+ //if($length > 30)
+ // if($length > 90){
+ // $niz = substr($value, 0, 90);
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // }
+ // else
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ //else{
+ //echo '<div id="'.$class.'_'.$id.'" class="'.$class.' '.$c.'">'.$value.'</div>'."\n";
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ //}
+ }
+
+ echo '</li>' . "\n";
+ echo '</ul>';
+ echo '</div>'; //half_$spremenljivka
+ echo '</td>';
+
+ //srednja celica (stevilo prenesenih in spodaj puscica)
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<td class="middle">';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<td class="middle_mobile">';
+ }
+ echo '<b></b>';
+ echo '<img src="' . self::$site_url . 'main/survey/skins/Modern/arrow.png" alt="arrow">';
+ echo '</td>';
+
+ //izris desne strani
+ echo '<td>';
+
+ echo '<b>' . self::$lang['srv_drag_drop_answers'] . ':</b>';
+
+ echo '<div class="dropholder">'; // ker na td ne primer position relative za nastavit position absolute na dropzone
+
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $this->display_DropBox($row1['naslov'], $row1['id']);
+ }
+
+ //echo '<div id="vrednost_if_'.$id.'" class="variabla">';
+ //echo '<div id="vrednost_if_" class="variabla">';
+ //echo '</div>'; //vrednost_if_ID
+
+// echo '</div>'; //half2_$spremenljivka
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<ul>';
+ echo '<li>
+ <div id="half2_frame_dropping_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>
+ </li>' . "\n";
+ echo '</ul>';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<ul>';
+ echo '<li>
+ <div id="half2_frame_dropping_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>
+ </li>' . "\n";
+ echo '</ul>';
+ }
+
+ echo '</div>'; //half2_$spremenljivka
+ echo '</div>'; //dropholder
+
+ echo '</td>';
+
+
+ echo '</tr>';
+ echo '</table>';
+
+ //Gumb za resetiranje
+ echo '<div class="buttonsHeatmap">';
+ //echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="Ponastavi">';
+ echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="'.$lang['srv_drag_and_drop_reset_button'].'">'; //srv_drag_and_drop_reset_button
+ echo '</div>';
+
+ echo '</div>';
+ //}
+
+
+ ?>
+ <script>
+ $(document).ready(function () {
+ DragDropDelovanje(<?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, usr_id, <?=$num?>, <?=get('mobile')?>, <?=$checkbox_limit?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+
+ //preveri, ce je ze kaj v bazi. Pomembno, za prikazovanje ze odgovorjenih zadev, ko uporabnik gre na prejsnjo stran ali kaj podobnega
+ $sql2_PP = sisplet_query("SELECT spr_id, vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+
+ while ($row2_PP = mysqli_fetch_array($sql2_PP)) {
+
+ $spr_id_b = $row2_PP["spr_id"];
+ $vre_id_b = $row2_PP["vre_id"];
+
+ if (!empty($row2_PP)) { //ce je ze nekaj v bazi
+
+ ?>
+ <script>
+ $(document).ready(function () {
+ var other = $('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').attr('missing');
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ //console.log(other);
+ //draggableOnDroppable[<?=$spr_id_b?>] = true; //odgovor je prisoten
+ if (<?=$row['tip']?> == 1
+ )
+ { //ce je samo en mozen odgovor
+ //if( (<?=$row['tip']?> == 1) || (<?=$row['tip']?> == 2 && <?=$other?> != 0) ){ //ce je samo en mozen odgovor
+ $('#half2_frame_dropping_<?=$spr_id_b?>')
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ //.droppable( 'disable' ); //onemogoci prenos drugega odgovora
+ }
+ //else if (<?=$row['tip']?> == 2 && other != 0) {
+ else
+ if (other != 0) {
+ $('#half2_frame_dropping_<?=$spr_id_b?>')
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ //.droppable( 'disable' ); //onemogoci prenos drugega odgovora
+ //console.log('Je missing');
+ }
+ else {
+ $('#half2_frame_dropping_<?=$spr_id_b?>')
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ //console.log('Ni missing');
+ }
+ });
+ </script>
+ <?
+ }
+ }
+ }
+
+ /**
+ * @desc prikaze vnos za drag-drop v grid
+ */
+ public function grid($spremenljivka)
+ {
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ //***********za skatlasto obliko
+ $display_drag_and_drop_new_look = ($spremenljivkaParams->get('display_drag_and_drop_new_look') ? $spremenljivkaParams->get('display_drag_and_drop_new_look') : 0); //za checkbox
+ //***********za skatlasto obliko - konec
+
+ $quick_view = json_encode(get('quick_view'));
+
+ // Pri WebSM anketi nimamo userja, zato ne izvajamo ajaxa
+ $ajax = 'true';
+ $usr_id = get('usr_id');
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+ $ajax = 'false';
+ $usr_id = 0;
+ }
+
+ //n>k // prestavljanje
+ //if ($row['design'] == 0 && get('mobile') == 0){
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+
+ //izracun visine
+ $num = mysqli_num_rows($sql1); //stevilo trenutnih kategorij odgovorov v levem bloku
+ $size = $num * 37;
+
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ //echo '<div id="vrednost_if_'.$row1['id'].'">';
+ echo '<table class="ranking_table">';
+ echo '<tr>';
+ //zaslon razdelimo na dva dela - izris leve strani
+ echo '<td id="left_frame_'.$spremenljivka.'">';
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_ranking_avaliable_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_avaliable_categories' . $_lang);
+ if ($srv_ranking_avaliable_categories == '') $srv_ranking_avaliable_categories = self::$lang['srv_ranking_avaliable_categories'];
+
+ echo '<b>' . $srv_ranking_avaliable_categories . ':</b>';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone" style="height:' . $size . 'px">';
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<ul>';
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<ul>';
+ echo '<li>
+ <div id="half_frame_dropping_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>';
+
+ }
+
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ //$this->display_DropBox($row1['naslov'], $row1['id']);
+ $value = $row1['naslov'];
+
+ // Datapiping
+ $value = Helper::dataPiping($value);
+
+ $vre_id = $row1['id'];
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ //if($display_drag_and_drop_new_look != 1){
+ $class = 'ranking';
+/* }else if($display_drag_and_drop_new_look == 1){
+ $class = 'drag_and_drop_box';
+ } */
+
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+ $c = '';
+ $other = $row1['other']; //drugo, po navadi missing
+
+ //********* potrebno za pravilno prikazovanje predogleda
+ if(isset($_GET['a'])){
+ if($_GET['a'] == 'preview_spremenljivka'){
+ $preview_spremenljivka = 1;
+ echo '
+ <script>
+ var usr_id = 0;
+ </script>
+ ';
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ }else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ //********* potrebno za pravilno prikazovanje predogleda - konec
+
+
+ ?>
+ <script>
+ //spremenljvke, ce se ne uporablja polj
+ //draggableOnDroppable[<?=$vre_id?>] = false; //inicializacija spremenljivke, ki belezi, ali je trenutna kategorija odgovora prisotna kontejnerju/okvirju
+
+ skatlastOkvir[<?=$spremenljivka?>] = <?=$display_drag_and_drop_new_look?>; //belezi, ali je okvir skatlaste oblike
+ //draggableOverDroppable[<?=$vre_id?>] = false;
+ data_after_refresh[<?=$spremenljivka?>] = false;
+ frame_total_height_right[<?=$spremenljivka?>] = 0;
+ last_vre_id[<?=$spremenljivka?>] = 0;
+ vre_id_global[<?=$spremenljivka?>] = 0;
+ last_indeks[<?=$spremenljivka?>] = 0;
+ last_drop[<?=$vre_id?>] = 0;
+ //num_grids_global[<?=$spremenljivka?>] = 0;
+ indeks_global[<?=$spremenljivka?>] = 0;
+ num_grids_global[<?=$spremenljivka?>] = <?=$row['grids']?>;//stevilo okvirjev, pomembno za revert kategorije odgovora
+ cat_pushed[<?=$spremenljivka?>] = false;
+ draggable_global[<?=$vre_id?>] = 0;
+ var from_left = [];
+ from_left[<?=$vre_id?>] = true;
+ //console.log("from_left[<?=$vre_id?>]: "+from_left[<?=$vre_id?>]);
+ //spremenljvke, ce se ne uporablja polj - konec
+
+ //spremenljivke kot polja polj
+ draggableOnDroppable[<?=$vre_id?>] = new Array(2); //inicializacija spremenljivke, ki belezi, ali je trenutna kategorija odgovora prisotna kontejnerju/okvirju
+ draggableOverDroppable[<?=$vre_id?>] = new Array(2);
+ for (i = 1; i <= num_grids_global[<?=$spremenljivka?>]; i++) {
+ draggableOnDroppable[<?=$vre_id?>][i] = false;
+ draggableOverDroppable[<?=$vre_id?>][i] = false;
+ }
+ //spremenljivke kot polja polj - konec
+
+
+ $(document).ready(function () {
+ //if(<?=$display_drag_and_drop_new_look?> == 0){
+ GridDraggable(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$other?>, <?=get('mobile')?>, <?=$display_drag_and_drop_new_look?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+/* }
+ else if(<?=$display_drag_and_drop_new_look?> == 1){
+ //GridDraggableBox(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', <?=$usr_id?>, <?=$other?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ GridDraggableBox(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$other?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ } */
+ });
+ </script>
+ <?
+ //echo '<div id="vrednost_if_'.$id.'" class="variabla">';
+ //echo '</div>'; //vrednost_if_ID
+ //div ki vsebuje vrednost
+ //if($length > 30)
+ // if($length > 90){
+ // $niz = substr($value, 0, 90);
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$niz.'...</div>'."\n";
+ // }
+ // else
+ //echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ // echo '<div title="'.strip_tags($value).'" id="'.$class.'_'.$vre_id.'" class="'.$class.'_long '.$c.'">'.$value.'</div>'."\n";
+ //else{
+ //echo '<div id="'.$class.'_'.$id.'" class="'.$class.' '.$c.'">'.$value.'</div>'."\n";
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ //}
+ }
+
+ echo '</li>' . "\n";
+ echo '</ul>';
+ echo '</div>'; //half_$spremenljivka
+ echo '</td>';
+
+ //srednja celica (stevilo prenesenih in spodaj puscica)
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ echo '<td class="middle">';
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+ echo '<td class="middle_mobile">';
+ }
+ echo '<b></b>';
+ echo '<img src="' . self::$site_url . 'main/survey/skins/Modern/arrow.png" alt="arrow">';
+ echo '</td>';
+
+ //izris desne strani***********************************************************************************
+
+ echo '<td id="right_frame_'.$spremenljivka.'">';
+
+ echo '<b>' . self::$lang['srv_drag_drop_answers'] . ':</b>';
+
+ echo '<div class="dropholder">'; // ker na td ne primer position relative za nastavit position absolute na dropzone
+
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $this->display_DropBox($row1['naslov'], $row1['id']);
+ }
+
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$spremenljivka' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($spremenljivka, $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # Izpišemo TOP vrstico z labelami
+ //if (count($srv_grids) > 0) {
+ /* $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>'."\n";
+ $first_missing_value = false;
+ }
+ # izpišemo labelo grida
+ //echo ' <td class="'.($srv_grid['other']==0?'category':'missing').' '.$cssAlign.'">'.$srv_grid['naslov'].'</td>'."\n";
+ echo $srv_grid['naslov'];
+ } */
+ //}
+
+
+ //glede na število gridov, dodati ustrezno stevilo <li> oz. okvirjev
+ echo '<ul>';
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ /* if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>'."\n";
+ $first_missing_value = false;
+ } */
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ if($display_drag_and_drop_new_look == 0){
+ echo '<li>
+ <div class="frame_dropping_titles">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ }else if($display_drag_and_drop_new_look == 1){
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping_box" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ echo '<li>
+ <div class="frame_dropping_titles_box">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ }
+ } else if (get('mobile') == 1) {// ce respondent uporablja mobilnik
+
+ if($display_drag_and_drop_new_look == 0){
+ echo '<li>
+ <div class="frame_dropping_titles_mobile">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping_mobile" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ }else if($display_drag_and_drop_new_look == 1){
+ echo '<li>
+ <div id="half2_frame_dropping_' . $i . '_' . $spremenljivka . '" class="frame_dropping_box_mobile" onHover=""></div>
+ </li>' . "\n"; //izpis okvirja
+ echo '<li>
+ <div class="frame_dropping_titles_box_mobile">' . $srv_grid['naslov'] . '</div>
+ </li>' . "\n"; //izpis "naslova" okvirja
+ }
+ }
+ ?>
+ <script>
+ $(document).ready(function () {
+ //ce imamo missing, je potrebno povecati stevilo grid-ov oz. okvirjev
+ if (<?=$srv_grid['other']?> !=
+ '0'
+ )
+ {
+ //console.log("Imamo missing!");
+ num_grids_global[<?=$spremenljivka?>] = num_grids_global[<?=$spremenljivka?>] + 1;
+
+ }
+ //if(<?=$display_drag_and_drop_new_look?> == 0){
+ GridDragDropDelovanje(num_grids_global[<?=$spremenljivka?>],<?=$i?>, <?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, usr_id, <?=$num?>, <?=get('mobile')?>, <?=$display_drag_and_drop_new_look?>); //poklici funkcijo za ureditev draggable in droppable
+/* }
+ else if(<?=$display_drag_and_drop_new_look?> == 1){
+ //GridDragDropDelovanjeBox(num_grids_global[<?=$spremenljivka?>],<?=$i?>, <?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, <?=$usr_id?>, <?=$num?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ GridDragDropDelovanjeBox(num_grids_global[<?=$spremenljivka?>],<?=$i?>, <?=$row['tip']?>, <?=$spremenljivka?>, '<?=self::$site_url?>', <?=$ajax?>, srv_meta_anketa_id, usr_id, <?=$num?>, <?=get('mobile')?>); //poklici funkcijo za ureditev draggable in droppable
+ } */
+ });
+ </script>
+ <?
+ }
+ ?>
+ <script>
+ $(document).ready(function () {
+ //console.log($('#spremenljivka_'+<?=$spremenljivka?>).css('height'));
+ var spremenljivka = <?=$spremenljivka?>;
+ var ajax = <?=$ajax?>;
+ var site_url = '<?=self::$site_url?>';
+ var num_grids = num_grids_global[<?=$spremenljivka?>];
+
+ //Ureditev povrnitve odgovorov (iz desne strani) v levo
+ $('#resetDragDrop_'+spremenljivka).click(function(){
+
+ var rightFrameHasChildren = ($('#half2_'+spremenljivka).find('.ranking').length ? 'Da' : 'Ne');
+ //console.log("Imamo kaj v desnem okvirju? "+rightFrameHasChildren);
+
+ if (rightFrameHasChildren == 'Da'){
+
+ //pobrisi vse iz baze
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data_reset', {spremenljivka: spremenljivka, usr_id: usr_id, anketa: srv_meta_anketa_id, tip: <?=$row['tip']?>}); //post-aj potrebne podatke
+ }
+
+ $('#half2_'+spremenljivka).find('.ranking').each(function(indeks) { //preleti vse prisotne kategorije odgovorov v desnem okvirju
+ var id = $(this).attr('id');
+ //console.log(index+1 + ": " + id);
+ var indeks = indeks+1;
+ var defaultHeight = 30; //default, povrnjena visina posameznega okvirja
+ var parent = $(this).parent().attr('id');
+ //console.log("parent:"+parent);
+ var index = parent.substring(21,22); //indeks okvirja v katerem se nahaja trenutna kategorija odgovora
+ //console.log("index:"+index);
+ //console.log("id:"+id);
+
+ $('#'+parent).outerHeight(defaultHeight); //povrni visino posameznega okvirja
+ //var parentHeight = $('#'+parent).outerHeight(true);
+ //console.log("parent:"+parent+" with height:"+parentHeight);
+
+ dynamic_question_height(spremenljivka, num_grids, <?=get('mobile')?>, <?=$display_drag_and_drop_new_look?>); //povrni visino celotnega vprasanja
+
+ ResetButtonHeight(spremenljivka);//povrni gumb na zacetno visino
+ if(<?=$display_drag_and_drop_new_look?>){
+ $(this).removeClass('drag_and_drop_box_right');
+ $(this).removeClass('drag_and_drop_box_right_after_refresh');
+ $(this).addClass('drag_and_drop_right');
+ }
+
+
+ //var vre_id = $(this).val();
+ var vre_id = $(this).attr('value');
+ //console.log("vre_id:"+vre_id);
+
+ if(<?=$row['tip']?> == 6){
+ $('#half_frame_dropping_'+spremenljivka).prepend(this); //pripopaj preneseno kategorijo na zacetek seznama kategorij na levi strani
+ //uredi parametre za nadalnje delovanje odgovarjanja
+ draggableOnDroppable[vre_id] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ draggableOverDroppable[vre_id] = false;
+ last_indeks[spremenljivka] = 0;
+ last_drop[vre_id] = 0;
+ last_vre_id[spremenljivka] = 0;
+ //uredi parametre za nadalnje delovanje odgovarjanja - konec
+ }else if(<?=$row['tip']?> == 16){
+ $(this).remove(); //odstrani kategorijo odgovora iz okvirja
+
+ //uredi parametre za nadalnje delovanje odgovarjanja
+ draggableOnDroppable[vre_id][index] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ draggableOverDroppable[vre_id][index] = false;
+ //uredi parametre za nadalnje delovanje odgovarjanja - konec
+ }
+ from_left[vre_id] = true;
+ });
+ }
+ });
+ });
+ </script>
+ <?
+
+
+ echo '</ul>';
+
+
+ echo '</div>'; //half2_$spremenljivka
+ echo '</div>'; //dropholder
+
+ echo '</td>';
+ //************************************************ konec izrisa desne strani
+
+ echo '</tr>';
+ echo '</table>';
+
+ //Gumb za resetiranje
+ echo '<div class="buttonsHeatmap">';
+ //echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="Ponastavi">';
+ echo '<input id="resetDragDrop_'.$row['id'].'" type="button" value="'.$lang['srv_drag_and_drop_reset_button'].'">'; //srv_drag_and_drop_reset_button
+ echo '</div>';
+
+
+ echo '</div>';
+ //}
+
+ //********* urejanje prikaza ob morebitnem refresh-u strani ali prehod na naslednjo oz. prejsnjo stran
+ //preveri, ce je ze kaj v bazi. Pomembno, za prikazovanje ze odgovorjenih zadev, ko uporabnik gre na prejsnjo stran ali kaj podobnega
+ if ($row['tip'] == 6) {
+ $sql2_PP = sisplet_query("SELECT spr_id, vre_id, grd_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ } elseif ($row['tip'] == 16) {
+ //$sql2_PP = sisplet_query("SELECT spr_id, vre_id, grd_id FROM srv_data_checkgrid WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql2_PP = sisplet_query("SELECT spr_id, vre_id, grd_id FROM srv_data_checkgrid_active WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ }
+
+
+ ?>
+ <script>
+
+ var cat_margin_left = 10 + 5 * 2 + 1 * 2; //hrani rob za ureditev visine levega okvirja = margin_spodnji + padding(spredi pa zadi) + border(spredi pa zadi) + neznanka
+ //var title_heigth = 26; //visina okvricka z naslovom
+ //var title_heigth = $('#spremenljivka_<?=$spremenljivka?> .naslov').height();
+ //console.log("Title height from survey: "+title_heigth);
+ var height_beside = 40; //visina od zacetka vprasanja do prvega okvirja (in malo po zadnjem okvirju)
+ var final_height_right_block_PP = 0; //hrani koncno visino desnega bloka, torej vseh prisotnih okvirjev
+ var top_cat_right = 30;
+ var left_cat = -6;
+
+ </script>
+ <?
+ $i = 0;
+ while ($row2_PP = mysqli_fetch_array($sql2_PP)) {
+
+ $spr_id_b = $row2_PP["spr_id"];
+ $vre_id_b = $row2_PP["vre_id"];
+ $grd_id_b = $row2_PP["grd_id"];
+
+ if (!empty($row2_PP)) { //ce je ze nekaj v bazi
+ ?>
+ <script>
+ $(document).ready(function () {
+
+ data_after_refresh[<?=$spremenljivka?>] = true; //oznacimo, da so prisotni podatki po refresh-u
+ draggableOnDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true; //oznacimo, da je trenutna kategorija odgovora v okvirju z dolocenim indeksom
+ draggableOverDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true;
+ last_drop[<?=$vre_id_b?>] = <?=$grd_id_b?>; //pomembno za revert kategorije odgovora in belezenje podatkov v bazo ob refreshu
+ vre_id_global[<?=$spr_id_b?>] = <?=$vre_id_b?>; //pomembno za revert kategorije odgovora ob refreshu
+ //uredi visino trenuntega okvirja glede na visino trenutne kategorije odgovora
+ frame_height(<?=$spr_id_b?>, <?=$vre_id_b?>, <?=$grd_id_b?>, false);
+
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ var desniOkvirRefresh = $('#half2_frame_dropping_<?=$grd_id_b?>_<?=$spr_id_b?>');
+ var trenutnaKategorija = $('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>');
+ if (<?=$row['tip']?> == 6)
+ { //ce je tabela - en odgovor
+ if(<?=$display_drag_and_drop_new_look?> == 0){
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>')) //prenesi ustrezni odgovor
+ }else if(<?=$display_drag_and_drop_new_look?> == 1){ //ce so skatle
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').css({left: left_cat})); //prenesi ustrezni odgovor
+ trenutnaKategorija.removeClass('drag_and_drop');
+ trenutnaKategorija.addClass('drag_and_drop_box_right_after_refresh');
+ //var pravaVisina = calcPravaVisina(desniOkvirRefresh, 0); //visina/pozicija prenesene kategorije v desnem okvirju
+ /* desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').css({top: pravaVisina})); //prenesi ustrezni odgovor */
+ }
+ }
+ else
+ if (<?=$row['tip']?> == 16)
+ {
+ if(<?=$display_drag_and_drop_new_look?> == 0){
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone()) //kloniraj ustrezni odgovor
+ }else if(<?=$display_drag_and_drop_new_look?> == 1){
+ desniOkvirRefresh //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone().css({left:left_cat})) //kloniraj ustrezni odgovor
+
+ desniOkvirRefresh.children(trenutnaKategorija).removeClass('drag_and_drop');
+ desniOkvirRefresh.children(trenutnaKategorija).addClass('drag_and_drop_box_right_after_refresh');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+
+ }
+/* if(<?=$display_drag_and_drop_new_look?> == 0){
+ $('#half2_frame_dropping_<?=$grd_id_b?>_<?=$spr_id_b?>') //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone()) //kloniraj ustrezni odgovor
+ }else if(<?=$display_drag_and_drop_new_look?> == 1){
+ $('#half2_frame_dropping_<?=$grd_id_b?>_<?=$spr_id_b?>') //v ustrezen okvir z indeksom grd_id
+ .prepend($('#spremenljivka_<?=$spr_id_b?>_vrednost_<?=$vre_id_b?>').clone().css({top: (top_cat_right), left:-6})) //kloniraj ustrezni odgovor
+ } */
+ }
+
+/* //console.log('Nekaj je v bazi!');
+ data_after_refresh[<?=$spremenljivka?>] = true; //oznacimo, da so prisotni podatki po refresh-u
+ draggableOnDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true; //oznacimo, da je trenutna kategorija odgovora v okvirju z dolocenim indeksom
+ draggableOverDroppable[<?=$vre_id_b?>][<?=$grd_id_b?>] = true;
+ last_drop[<?=$vre_id_b?>] = <?=$grd_id_b?>; //pomembno za revert kategorije odgovora in belezenje podatkov v bazo ob refreshu
+ vre_id_global[<?=$spr_id_b?>] = <?=$vre_id_b?>; //pomembno za revert kategorije odgovora ob refreshu
+ //uredi visino trenuntega okvirja glede na visino trenutne kategorije odgovora
+ frame_height(<?=$spr_id_b?>, <?=$vre_id_b?>, <?=$grd_id_b?>, false);
+
+ checkBranching(); */
+ });
+ </script>
+ <?
+ }
+ }
+
+ //if(!empty($row2_PP)){
+ if (mysqli_num_rows($sql2_PP) != 0) {
+ ?>
+ <script>
+ $(document).ready(function () {
+ data_after_refresh[<?=mysqli_num_rows($sql2_PP)?>] = <?=mysqli_num_rows($sql2_PP)?>;
+ refresh[<?=$spremenljivka?>] = 1;
+ //console.log(<?=$vre_id?>);
+ //console.log(last_drop[<?=$vre_id?>]);
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ //question_height(<?=$spr_id_b?>, <?=$row['grids']?>);
+ //question_height(<?=$spr_id_b?>, num_grids_global[<?=$spremenljivka?>]);
+ //dynamic_question_height(<?=$spr_id_b?>, num_grids_global[<?=$spremenljivka?>]);
+ num_grids_global[<?=$spremenljivka?>] = <?=$row['grids']?>;//stevilo okvirjev, pomembno za revert kategorije odgovora ob refreshu
+ });
+ </script>
+ <?
+ //}
+ }
+ //********* konec - urejanje prikaza ob morebitnem refresh-u strani ali prehod na naslednjo oz. prejsnjo stran
+ }
+
+ /**
+ * @desc izrisemo drop okno
+ */
+ public function display_DropBox($value, $id)
+ {
+
+ $length = strlen($value);
+ $style = '';
+ $class = 'ranking';
+ $c = '';
+
+ //div ki vsebuje vrednost
+ if ($length > 30)
+ if ($length > 90) {
+ $niz = substr($value, 0, 90);
+ echo '<div title="' . strip_tags($value) . '" id="' . $class . '_' . $id . '" class="' . $class . '_long ' . $c . '">' . $niz . '...</div>' . "\n";
+ } else
+ echo '<div title="' . strip_tags($value) . '" id="' . $class . '_' . $id . '" class="' . $class . '_long ' . $c . '">' . $value . '</div>' . "\n";
+ else
+ echo '<div id="' . $class . '_' . $id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n";
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/DynamicController.php b/main/survey/app/Controllers/Vprasanja/DynamicController.php
new file mode 100644
index 0000000..57e0127
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/DynamicController.php
@@ -0,0 +1,725 @@
+<?php
+/***************************************
+ * Description: Prikaže vsa polja iz dinamičnega multigrida/multicheckbox horizontalni/vertikalni
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 3 - dynamic_mg 1, 3, 5
+ * tip 16 - enota 3 - dynamic_mg 1, 3, 5
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+class DynamicController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new DynamicController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za dinamicen multigrid
+ */
+ public function multigrid($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+
+ //************************ za izris traku
+ $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0); //za checkbox trak
+ $trak_num_of_titles = ($spremenljivkaParams->get('trak_num_of_titles') ? $spremenljivkaParams->get('trak_num_of_titles') : 0); //belezi stevilo nadnaslovov
+
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen @ diferencial ali klasicna tabela
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ $trak_class = 'trak_class';
+ $trak_class_input = 'trak_class_input';
+ $question = 'question_trak';
+ if ($row['enota'] == 1){ //ce je diferencial
+ $gridWidth = 15; //za sirino celic skrajno levo pa desno od traku
+ }
+ if($trak_num_of_titles != 0){
+ $display_trak_num_of_titles = 'style="display:none;"';
+ $trak_nadnaslov_table_td_width = 100 / $trak_num_of_titles; //spremenljivka za razporeditev sirine nadnaslovov @ traku
+ }
+ $display_trak_num_of_titles = '';
+
+/* ?>
+ <script>
+ $(document).ready(function(){
+ trak_edit_num_titles(<?=$row['grids']?>, <?=$spremenljivka?>, <?=$trak_num_of_titles?>, <?=json_encode($trak_nadnaslov)?>);
+ });
+ </script>
+ <? */
+ }else{
+ $trak_class = '';
+ $trak_class_input = '';
+ $question = 'question';
+ $display_trak_num_of_titles = 'style="display:none;"';
+ }
+
+ for($i = 1; $i <= $trak_num_of_titles; $i++){
+ $trak_nadnaslov[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.$i.'') ? $spremenljivkaParams->get('trak_nadnaslov_'.$i.'') : $lang['srv_new_text']);
+ }
+ //********************** za izris traku - konec
+
+
+
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ $size += 1;
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table dynamicmultigrid">' . "\n";
+
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+ if ($row['enota'] > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="differential">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ }
+ if (!$row['dynamic_mg'] == 3) {
+ echo '<colgroup>';
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ //vrstica z nadnaslovi
+ echo '<tr '.$display_trak_num_of_titles.' class="display_trak_num_of_titles_respondent_'.$row['id'].'">';
+ echo ' <td></td>';
+ echo ' <td></td>';
+ //for($j = 1; $j <= $trak_num_of_titles; $j++){
+ for ($j = 1; $j <= $row['grids']; $j++) {
+ //echo '<td>'.$j.'</td>';
+ if($j == 1){
+ $nadnaslov_floating = 'left';
+ }else if($j == $row['grids']){
+ $nadnaslov_floating = 'right';
+ }else{
+ $nadnaslov_floating = 'none';
+ }
+ echo '<td class="trak_inline_nadnaslov" grd="gr_'.$j.'"><div id="trak_nadnaslov_'.$j.'_'.$spremenljivka.'" name="trak_nadnaslov_'.$j.'" class="trak_inline_nadnaslov" style="float:'.$nadnaslov_floating.'; display:inline" '.(strpos($trak_nadnaslov[$j], $lang['srv_new_text'])!==false || $this->lang_id!=null ?' default="1"':'').'>' . $trak_nadnaslov[$j] . '</div></td>';
+
+ }
+ echo '</tr>';
+ //vrstica z nadnaslovi - konec
+
+ echo ' <tr>' . "\n";
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+
+ if($diferencial_trak != 1){ //ce ni traku
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }elseif($diferencial_trak == 1){ //ce je trak
+ # izpišemo ustrezno labelo grida
+ if($srv_grid['other'] == 0){ //ce je labela za kategorijo odgovora, naj bo prazno
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '"></td>' . "\n";
+ }else { //drugace, ce je labela za missing, izpisi labelo
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ }
+ }
+
+ if (!$row['dynamic_mg'] == 3) {
+ echo ' <td></td>' . "\n";
+ }
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $gridRow = 1;
+ $hide = false;
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $countVar = mysqli_num_rows($sql1);
+
+ // Stevilo vseh vrednosti
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '" value="' . $countVar . '" />';
+ // Indikator da v js vemo ali smo ravnokar naloudali stran ali pa smo samo premaknili vrstico (potrebno zaradi prikazovanja glede na ife v dolocenih primerih)
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '_load" value="1" />';
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $ifDisplay = ($row1['if_id'] > 0 ? ' if_hide' : '');
+ // Ce lahko prikazemo vrstico (se ni nobena izrisana in ni skrita z ifom) -> naslednjih ne izrisujemo vec
+ if ($hide == false && $row1['hidden'] == 0 && $row1['if_id'] == 0) {
+ $gridRowDisplay = '';
+ $hide = true;
+ } else
+ $gridRowDisplay = ' style="display:none;"';
+
+ $colspan = 0;
+
+ echo ' <tr id="vrednost_if_'. $row1['id'].'" seq="'.$gridRow.'" class="'.$spremenljivka.'_gridRow '.$spremenljivka.'_gridRow_'.$gridRow.' '.$ifDisplay.'" '.$gridRowDisplay.'>' . "\n";
+ echo ' <td class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</td>' . "\n";
+ echo '<td></td>' . "\n";
+
+ $colspan += 2;
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+
+ $colspan++;
+ }
+
+ $value = $srv_grids[$i]['id'];
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<td class="missing">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\'); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0) ){ //ce je trak
+ if ($gridRow < $countVar){
+ echo '<td onClick="checkBranching(); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 0); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');" id="trak_tbl_' . $row1['id'] . '_'.$srv_grid['vrstni_red'].'" class="category' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' '.$trak_class.' '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? 'trak_container_bg' : '').'">';
+ }else{
+ echo '<td onClick="checkBranching(); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 0); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '" id="trak_tbl_' . $row1['id'] . '_'.$srv_grid['vrstni_red'].'" class="category' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' '.$trak_class.' '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? 'trak_container_bg' : '').'">';
+ }
+ # ni missing vrednost
+ echo '<input vre_id = '.$row1['id'].' class="'.$trak_class_input.'" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '">';
+ echo '<label class="radio-button-label">'.$srv_grid['variable'];
+ //echo '<span ' . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '></span>'; //custom radio button
+ echo '</label>';
+ echo '</td>' . "\n";
+ }else{
+ # ni missing vrednost
+ echo '<td class="category">';
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\'); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ }
+
+ $colspan++;
+ }
+ }
+
+ # dodamo še enoto
+ if ($row['enota'] == 1) {
+ echo ' <td></td>' . "\n";
+ echo ' <td>' . $row1['naslov2'] . '</td>' . "\n";
+ $colspan += 2;
+ }
+
+ // puscice levo/desno
+ if ($row['dynamic_mg'] == 3) {
+
+ //echo ' <td style="height: 80px;">'."\n";
+ echo '</tr><tr class="gridRowArrows ' . $spremenljivka . '_gridRowArrows_' . $gridRow . ' ' . $ifDisplay . '" ' . $gridRowDisplay . '><td colspan="' . $colspan . '">';
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ if ($gridRow > 1)
+ echo ' <td><div title="' . self::$lang['back'] . '" id="arrow_left" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' <td><div id="dynamic_count" style="text-align: center;">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div></td>';
+ if ($gridRow < $countVar)
+ echo ' <td><div title="' . self::$lang['forward'] . '" id="arrow_right" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' </tr></table>' . "\n";
+ echo '</td>';
+ //echo ' </td>'."\n";
+
+ // paginacija
+ } elseif ($row['dynamic_mg'] == 5 || (get('mobile') == 1 && $mobile_tables > 0)) {
+
+ echo '</tr><tr class="gridRowArrows ' . $spremenljivka . '_gridRowArrows_' . $gridRow . ' ' . $ifDisplay . '" ' . $gridRowDisplay . '><td colspan="' . $colspan . '">';
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ for ($i = 1; $i <= $countVar; $i++) {
+ echo ' <td><div title="' . $i . '" id="sequence_number_' . $i . '" class="sequence_number sequence_number_'.$i.' ' . ($i == $gridRow ? ' active' : '') . '" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . $i . '\');">' . $i . '</div></td>';
+ }
+ echo ' </tr></table>' . "\n";
+ echo '</td>';
+
+ // puscice za naprej/nazaj
+ } else {
+
+ echo ' <td style="height: 80px;">' . "\n";
+ if ($gridRow > 1)
+ echo ' <div title="' . self::$lang['back'] . '" id="arrow_up" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' <div id="dynamic_count">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div>';
+ if ($gridRow < $countVar)
+ echo ' <div title="' . self::$lang['forward'] . '" id="arrow_down" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' </td>' . "\n";
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ $gridRow++;
+ }
+
+ echo '</table>' . "\n";
+
+ //************* za ureditev prilagajanja label stolpcev @TRAK
+ //prilagajanje trem opisnim nadnaslovom
+ $custom_column_label_option = ($spremenljivkaParams->get('custom_column_label_option') ? $spremenljivkaParams->get('custom_column_label_option') : 1);
+ echo '
+ <script>
+ change_custom_column_label_respondent(\'' . $row['grids'] . '\', \'' . $row['id'] . '\', \'' . $custom_column_label_option . '\');
+ </script>
+ ';
+ if($trak_num_of_titles != 0){
+ //prilagajanje stevilu izbranih nadnaslovov
+ ?>
+ <script>
+ $(document).ready(function(){
+ trak_edit_num_titles_respondent(<?=$row['grids']?>, <?=$spremenljivka?>, <?=$trak_num_of_titles?>, <?=json_encode($trak_nadnaslov)?>);
+ });
+ </script>
+ <?
+ }
+ //************* za ureditev prilagajanja label stolpcev @TRAK - konec
+ }
+
+ /**
+ * @desc prikaze vnosno polje za vertikalen dinamicen multigrid
+ */
+ public function verticalMultigrid($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+
+ $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0); //za checkbox trak
+ //echo '<script>console.log("diferencial_trak: "+'.$diferencial_trak.'); </script>';
+ //echo '<script>console.log("dynamic_mg vertikal: "+'.$row['dynamic_mg'].'); </script>';
+
+ //CE JE TRAK - POJDI NA IZRIS VODORAVNE RAZLICICE
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen @ diferencial ali klasicna tabela
+ $this->multigrid($spremenljivka); //pojdi na zgornjo funkcijo za izris vodoravne različice
+ }else{ //CE NI TRAK, NADALJUJ Z IZRISOM NAVPICNE RAZLICICE
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ $size += 1;
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $gridRow = 1;
+ $hide = false;
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $countVar = mysqli_num_rows($sql1);
+
+ // Stevilo vseh vrednosti
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '" value="' . $countVar . '" />';
+ // Indikator da v js vemo ali smo ravnokar naloudali stran ali pa smo samo premaknili vrstico (potrebno zaradi prikazovanja glede na ife v dolocenih primerih)
+ echo '<input type="hidden" id="dynamic_multigrid_' . $spremenljivka . '_load" value="1" />';
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $ifDisplay = ($row1['if_id'] > 0 ? ' if_hide' : '');
+ // Ce lahko prikazemo vrstico (se ni nobena izrisana in ni skrita z ifom) -> naslednjih ne izrisujemo vec
+ if ($hide == false && $row1['hidden'] == 0 && $row1['if_id'] == 0) {
+ $gridRowDisplay = '';
+ $hide = true;
+ } else
+ $gridRowDisplay = ' style="display:none;"';
+
+ echo ' <div id="vrednost_if_'.$row1['id'].'" seq="'.$gridRow.'" class="'.$spremenljivka.'_gridRow '.$spremenljivka.'_gridRow_'.$gridRow.' '.$ifDisplay.'" '.$gridRowDisplay.'>' . "\n";
+
+ echo '<div ' . ($row['dynamic_mg'] == 4 ? ' style="float: left; width: 70%;"' : '') . '>';
+
+ echo '<div class="dynamic_mg_vrednost">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</div>';
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ $first_missing_value = false;
+ }
+ $value = $srv_grids[$i]['id'];
+ $grid_title = $srv_grids[$i]['naslov'];
+
+ // Datapiping
+ $grid_title = Helper::dataPiping($grid_title);
+
+ $smeski ='';
+ if(in_array($row['enota'], [11,12])){
+ $smeski = 'visual-radio-scale visual-radio-block';
+ }
+
+ # izpišemo radio grida
+ echo '<div class="variabla '.$smeski.'">';
+ if ($srv_grid['other'] != 0) {
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . '); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . ');' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo ' ' . $grid_title . '</label>';
+ } else {
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ if ($gridRow < $countVar)
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . '); rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');">';
+ else
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mm\', ' . $row1['id'] . '); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . '">';
+
+ // Font awesome
+ if($row['enota'] == 11){
+ echo '<span class="enka-vizualna-skala siv-'.$row['grids'].$value.'"></span>';
+ }elseif($row['enota'] == 12){
+ echo '<span class="enka-custom-radio '.$spremenljivkaParams->get('customRadio').'"></span>';
+ }else {
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ }
+
+ echo ' ' . $grid_title . '</label>';
+ }
+ echo '</div>';
+ }
+ }
+
+ // Dodamo se drug naslov ce imamo semanticni diferencial
+ if ($row['enota'] == 1) {
+
+ // Datapiping
+ $row1['naslov2'] = Helper::dataPiping($row1['naslov2']);
+
+ echo '<div class="dynamic_mg_vrednost">';
+ echo $row1['naslov2'];
+ echo '</div>';
+ }
+
+ echo '</div>';
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // puscice za naprej/nazaj
+ if ($row['dynamic_mg'] == 4) {
+ $position = ($size - 2) * 10;
+ echo ' <div style="margin-top:' . $position . 'px; float: right; text-align: center;">' . "\n";
+ if ($gridRow > 1)
+ echo ' <div title="' . self::$lang['back'] . '" id="arrow_up" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' <div id="dynamic_count">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div>';
+ if ($gridRow < $countVar)
+ echo ' <div title="' . self::$lang['forward'] . '" id="arrow_down" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div>';
+ else
+ echo ' <div style="height: 24px;"></div>';
+ echo ' </div>' . "\n";
+
+ // Paginacija
+ } elseif ($row['dynamic_mg'] == 6 || (get('mobile') == 1 && $mobile_tables > 0)) {
+
+ echo '</tr><tr class="gridRowArrows ' . $spremenljivka . '_gridRowArrows_' . $gridRow . ' ' . $ifDisplay . '" ' . $gridRowDisplay . '><td colspan="' . $colspan . '">';
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ for ($i = 1; $i <= $countVar; $i++) {
+ echo ' <td><div title="' . $i . '" id="sequence_number_' . $i . '" class="sequence_number sequence_number_'.$i.' ' . ($i == $gridRow ? ' active' : '') . '" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . $i . '\');">' . $i . '</div></td>';
+ }
+ echo ' </tr></table>' . "\n";
+ echo '</td>';
+
+ // puscice levo/desno
+ } else {
+ echo ' <table class="dynamic_mg_orientation"><tr>' . "\n";
+ if ($gridRow > 1)
+ echo ' <td><div title="' . self::$lang['back'] . '" id="arrow_left" class="arrow arrow_back" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow - 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' <td><div id="dynamic_count" style="text-align: center;">'.($countVar == 1 ? '' : $gridRow.' / '.$countVar).'</div></td>';
+ if ($gridRow < $countVar)
+ echo ' <td><div title="' . self::$lang['forward'] . '" id="arrow_right" class="arrow arrow_forward" onClick="rowSlide(\'' . $spremenljivka . '\', \'' . $gridRow . '\', \'' . ($gridRow + 1) . '\');"></div></td>';
+ else
+ echo ' <td><div style="height: 24px;"></div></td>';
+ echo ' </tr></table>' . "\n";
+ }
+
+ echo ' </div>' . "\n";
+
+ $bg++;
+ $gridRow++;
+ }
+ } //KONEC IZRISA NAVPICNE / VERTICAL RAZLICICE
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/HeatMapController.php b/main/survey/app/Controllers/Vprasanja/HeatMapController.php
new file mode 100644
index 0000000..4a255dd
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/HeatMapController.php
@@ -0,0 +1,242 @@
+<?php
+/***************************************
+ * Description: Prikaže vprašanje Heatmap
+ *
+ * Vprašanje je prisotno:
+ * tip 27
+ *
+ * Autor: Patrik Pucer
+ * Created date: 06.10.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
+use App\Controllers\Vprasanja\MultigridController as Multigrid;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+class HeatMapController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new HeatMapController();
+ }
+
+ /**
+ * @desc prikaze vnos za image hotspot za radio
+ */
+ public function display($spremenljivka){
+
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0);
+
+ //$hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 1); //po default-u skrij namig
+ $hotspot_tooltips_option = 1; //naj bo 1 tako, da je skrito, saj trenutno tega v heatmap ne rabimo
+
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+
+ $heatmap_num_clicks = ($spremenljivkaParams->get('heatmap_num_clicks') ? $spremenljivkaParams->get('heatmap_num_clicks') : 1);
+ $heatmap_show_clicks = ($spremenljivkaParams->get('heatmap_show_clicks') ? $spremenljivkaParams->get('heatmap_show_clicks') : 0); //za checkbox
+ $disable_heatmap_show_clicks_hidden = ($heatmap_show_clicks == 1) ? 'disabled' : '';
+
+ $heatmap_click_color = ($spremenljivkaParams->get('heatmap_click_color') ? $spremenljivkaParams->get('heatmap_click_color') : "");
+ $heatmap_click_size = ($spremenljivkaParams->get('heatmap_click_size') ? $spremenljivkaParams->get('heatmap_click_size') : 5);
+ $heatmap_click_shape = ($spremenljivkaParams->get('heatmap_click_shape') ? $spremenljivkaParams->get('heatmap_click_shape') : 1);
+
+ $heatmap_show_counter_clicks = ($spremenljivkaParams->get('heatmap_show_counter_clicks') ? $spremenljivkaParams->get('heatmap_show_counter_clicks') : 0); //za prikazovanje/skrivanje stevca klikov
+
+ // Pri vpogledu moramo deaktivirati canvas in tipke (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+
+
+
+ echo '<div id="heatmap_'.$spremenljivka.'" class="hotspot" style="width: 40%; float: left;">';
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ //ce so podatki ze v bazi (rec. uporabnik klikne 'Prejsnja stran')
+ //$sql1a = sisplet_query("SELECT lat, lng, address, text FROM srv_data_map WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql1a = sisplet_query("SELECT lat, lng, address, text FROM srv_data_heatmap WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $heatmap_data = array();
+ while ($row1a = mysqli_fetch_array($sql1a)) {
+ $heatmap_data[] = $row1a;
+ }
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'" style="display:none; ">';
+ //echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'">';
+ //echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //canvas
+ echo '<canvas id="heatmapCanvas_'.$row['id'].'">';
+
+ echo '</canvas>';
+
+ //Za obmocja
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ }
+ echo '</map>';
+
+ //************************************************************************************************
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki
+ echo '<div id="heatmapCheckbox_'.$row['id'].'">';
+ RadioCheckboxSelect::getInstance()->display($spremenljivka); //prikaze radio button in checkbox z odgovori
+ echo '</div>';
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+ //Za obmocja - konec
+
+ //GUMBA
+ echo '<div class="buttonsHeatmap">';
+
+ //gumb za resetiranje vseh tock
+ echo '<input id="resetHeatMapCanvas_'.$row['id'].'" type="button" value="'.$lang['srv_vprasanje_heatmap_reset_canvas'].'">';
+
+ echo '&emsp;';
+
+ //gumb za resetiranje zadnje tocke
+ echo '<input id="resetHeatMapLastPoint_'.$row['id'].'" type="button" value="'.$lang['srv_vprasanje_heatmap_reset_last_point'].'">';
+
+ echo '</div>';
+ //GUMBA - konec
+
+ //canvas - konec
+
+ //div za stevec klikov
+ if($heatmap_show_counter_clicks){
+ echo '</br><div id="heatmapClickCounter_'.$spremenljivka.'">';
+ echo '<div>'.$lang['srv_vprasanje_heatmap_num_clicks'].':</div>';
+ echo '<div id="heatmapClickNumber_'.$spremenljivka.'" style="float:left">0</div>/'.$heatmap_num_clicks;
+ echo '</div>';
+ }
+ //div za stevec klikov - konec
+
+ //div za inpute tock
+ echo '<div id="heatmapInputs_'.$spremenljivka.'" style="display:none">';
+ echo '</div>';
+ //div za inpute tock - konec
+
+ ?>
+ <script>
+
+ mousePos[<?=$spremenljivka?>] = new Array(2);
+ indeksMousePos[<?=$spremenljivka?>] = 0;
+ heatmap_num_clicksGlobal[<?=$spremenljivka?>] = <?=$heatmap_num_clicks?>;
+ var heatmapDataLength = [];
+ var refreshed = [];
+ for(i = 1; i <= <?=$heatmap_num_clicks?>; i++){
+ mousePos[<?=$spremenljivka?>][i] = 0;
+ //console.log("mousePos[<?=$spremenljivka?>]["+i+"]: "+mousePos[<?=$spremenljivka?>][i]);
+ }
+
+ $(document).ready(function () {
+
+ InitHeatMapCanvas(<?=$spremenljivka?>, <?=$quick_view?>);
+ //Ta spremenljivka ze vsebuje podatke? primer, ce gre uporabnik na prejsnjo stran ali refresh-a stran
+ var heatmap_data = JSON.parse('<?php echo json_encode($heatmap_data); ?>');
+ heatmapDataLength[<?=$spremenljivka?>] = heatmap_data.length; //belezi zacetno dolzino polja
+ //ce ze obstajajo tocke, jih dodaj na canvas
+ if (heatmap_data.length > 0){
+ heatmap_data_add(<?=$spremenljivka?>, heatmap_data, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, <?=$heatmap_show_clicks?>, <?=$heatmap_num_clicks?>);
+ refreshed[<?=$spremenljivka?>] = 1;
+ }
+ });
+ $('#heatmapCanvas_<?=$spremenljivka?>').click(function (e) {
+ HeatMapCanvasDelovanje(e, <?=$spremenljivka?>, <?=$heatmap_show_clicks?>, <?=$heatmap_num_clicks?>, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, <?=$quick_view?>);
+ });
+ $('#heatmapCanvas_<?=$spremenljivka?>').mouseover(function (e) {
+ if (heatmap_num_clicksGlobal[<?=$spremenljivka?>] != 0){ //ce je se mozno klikati
+ $(this).css( 'cursor', 'pointer' ); //ko je se miška nahaja na canvas-u, naj se spremeni v rokico
+ }
+ });
+ //klicanje funkcije za brisanje vseh tock na canvasu
+ $('#resetHeatMapCanvas_<?=$spremenljivka?>').click(function (e) {
+ resetHeatMapCanvas(<?=$spremenljivka?>, <?=$heatmap_num_clicks?>, <?=$quick_view?>);
+ });
+
+ //klicanje funkcije za brisanje zadnje izbrane tocke na canvasu
+ $('#resetHeatMapLastPoint_<?=$spremenljivka?>').click(function (e) {
+ var heatmap_data = JSON.parse('<?php echo json_encode($heatmap_data); ?>');
+ resetHeatMapLastPoint(<?=$spremenljivka?>, <?=$heatmap_num_clicks?>, <?=$heatmap_show_clicks?>, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, heatmap_data, <?=$quick_view?>);
+ });
+
+ $('#heatmapCheckbox_<?=$spremenljivka?> .variabla').css("display", "none"); //skrij radio/checkbox button odgovore, kjer se bodo beležili odgovori
+
+ </script>
+ <?
+
+ echo '</div>';
+
+ echo ' </div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php b/main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php
new file mode 100644
index 0000000..3e0b953
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/ImageHotSpotController.php
@@ -0,0 +1,856 @@
+<?php
+/***************************************
+ * Description: Prikaže vprašanje Image HotSpot
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 10
+ *
+ * Autor: Patrik Pucer
+ * Created date: 26.04.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
+use App\Controllers\Vprasanja\MultigridController as Multigrid;
+use App\Controllers\Vprasanja\RankingController as Ranking;
+
+// Iz admin/survey
+use SurveyInfo;
+
+
+class ImageHotSpotController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new ImageHotSpotController();
+ }
+
+ /**
+ * @desc prikaze vnos za image hotspot za radio
+ */
+ public function display($spremenljivka){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0);
+ $hotspot_region_visibility = ($spremenljivkaParams->get('hotspot_region_visibility') ? $spremenljivkaParams->get('hotspot_region_visibility') : 1); //za radio "vedno" in "ob mouseover"
+ $hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 0);
+
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+ $hotspot_visibility_color = ($spremenljivkaParams->get('hotspot_visibility_color') ? $spremenljivkaParams->get('hotspot_visibility_color') : "");
+
+ // Pri vpogledu moramo deaktivirati canvas in tipke (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+ if($hotspot_region_visibility_option){
+ $hotspot_region_visibility_option = $hotspot_region_visibility;
+ }
+
+ //zaslon razdelimo na dva dela - izris leve strani***************************************
+ echo '<div id="half_hot_spot_1" class="hotspot" style="width: 40%; float: left;">';
+
+
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ //$sqlR = sisplet_query("SELECT * FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'" style="display:none; ">';
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }
+ else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //prikaz obmocij na sliki*********************************************************************************
+ $options[$row['id']] = '{areas: ['; //belezi kodo za settings-e za prikazovanje tooltip v imagemapster
+
+ //HTML ZA TOOLTIP
+ //$htmltootip[$row['id']] = '';
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ //$sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sql_grid = sisplet_query("SELECT id, naslov, other FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ }
+ }
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ //$sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql_grid = sisplet_query("SELECT vre_id, grd_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $sql1 = sisplet_query("SELECT id, naslov, hidden FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $htmltootip[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = $htmltootip1[$row1['id']].''.$row1['id'].'<br />';
+ //echo $htmltootip1[$row1['id']];
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<div class=\"grid_table multigrid\">';
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ //echo ' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div id=\"im_vrednost_if_' . $row1['id'] . '\"' . (($row1['hidden'] == 1) ? 'style=\"display:none\"' : '') . (($row1['hidden'] == 2) ? 'class=\"answer-disabled\"' : '') . '\">';
+
+
+ //echo ' <td class="question">';
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td class="question">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div class=\"question\">';
+
+ //echo $row1['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$row1['naslov'];
+
+ //echo '</td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'</td>' . "\n";
+ $htmltootip[$row['id']] = $htmltootip[$row['id']].'</div>';
+
+ //echo ' <td></td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td></td>' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div></div>';
+
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' </div>';
+
+ //uredi options za imagemapster in prikazovanja obmocij
+ //$options[$row['id']] = $options[$row['id']] .'{key: "'.$row1['naslov'].'", toolTip: "'.$htmltootip[$row['id']].' "} ,';
+
+ //$bg++;
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</table>' . "\n";
+ }
+ //echo '</table>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'</table>' . "\n";
+
+ //echo $htmltootip[$row1['id']];
+ //HTML ZA TOOLTIP - KONEC
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ //uredi options za imagemapster in prikazovanja obmocij
+ $options[$row['id']] = $options[$row['id']] .'{key: "'.$rowR['vre_id'].'", toolTip: "'.$htmltootip[$rowR['vre_id']].' "} ,';
+ }
+ echo '</map>';
+
+ $options[$row['id']] = rtrim($options[$row['id']], ","); //odstrani zadnjo vejico pri options
+ $options[$row['id']] = $options[$row['id']].']}'; //zapri areas z ]}
+ //echo $options[$row['id']];
+
+ //************************************************************************************************
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki
+ RadioCheckboxSelect::getInstance()->display($spremenljivka); //prikaze radio button in checkbox z odgovori
+ //izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+
+
+ ?>
+
+ <script>
+ $(document).ready(function () {
+ mapinitRadio(<?=$row['id']?>, <?=$options[$row['id']]?>, <?=$row['tip']?>, <?=$hotspot_region_visibility_option?>, <?=$hotspot_tooltips_option?>, '<?=$hotspot_region_color?>', '<?=$hotspot_visibility_color?>', <?=$quick_view?>); //uredi delovanje imagemapster in prikazovanja/skrivanje obmocij ter tooltip-ov
+ });
+ </script>
+ <?
+ echo '</div>';
+ //prikaz obmocij na sliki - konec**************************************************************************
+
+
+ echo ' </div>';
+ //************************* Izris leve strani - konec
+ }
+
+ /**
+ * @desc prikaze vnos za image hotspot za radio grid
+ */
+ public function grid($spremenljivka){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0); //za checkbox
+ $hotspot_region_visibility = ($spremenljivkaParams->get('hotspot_region_visibility') ? $spremenljivkaParams->get('hotspot_region_visibility') : 1); //za radio "vedno" in "ob mouseover"
+ $hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 0);
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+ $hotspot_visibility_color = ($spremenljivkaParams->get('hotspot_visibility_color') ? $spremenljivkaParams->get('hotspot_visibility_color') : "");
+
+ if($hotspot_region_visibility_option){
+ $hotspot_region_visibility_option = $hotspot_region_visibility;
+ }
+
+ // Pri vpogledu moramo deaktivirati radio button-e (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+
+
+ //zaslon razdelimo na dva dela - izris leve strani***************************************
+ echo '<div id="half_hot_spot_1" class="hotspot" style="width: 40%; float: left;">';
+
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row['id'].'" style="display:none; ">';
+
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }
+ else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //prikaz obmocij na sliki*********************************************************************************
+ $options[$row['id']] = '{areas: ['; //belezi kodo za settings-e za prikazovanje tooltip v imagemapster
+
+ //HTML ZA TOOLTIP
+ //$htmltootip[$row['id']] = '';
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ //$sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sql_grid = sisplet_query("SELECT id, naslov, other FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ }
+ }
+
+ //echo '<table class="grid_table multigrid">' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'<table class=\"grid_table multigrid\">';
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ //$sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $sql_grid = sisplet_query("SELECT vre_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ //$sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ $sql1 = sisplet_query("SELECT id, naslov, hidden FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $htmltootip[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = $htmltootip1[$row1['id']].''.$row1['id'].'<br />';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ // preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ // ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ //echo ' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <tr id="vrednost_if_' . $row1['id'] . '"' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div id=\"im_vrednost_if_' . $row1['id'] . '\"' . (($row1['hidden'] == 1) ? 'style=\"display:none\"' : '') . (($row1['hidden'] == 2) ? 'class=\"answer-disabled\"' : '') . '\">';
+
+
+ //echo ' <td class="question">';
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td class="question">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div class=\"question\">';
+
+ //echo $row1['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$row1['naslov'];
+
+
+ //echo '</td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].'</td>' . "\n";
+ $htmltootip[$row['id']] = $htmltootip[$row['id']].'</div>';
+
+ //echo ' <td></td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td></td>' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div></div>';
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+
+ //echo ' <td></td>' . "\n";
+ //$htmltootip[$row['id']] = $htmltootip[$row['id']].' <td></td>' . "\n";
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' <div></div>';
+
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<div class=\"missing ' . $cssAlign . '\">';
+ # imamo missing vrednost
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<label for=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation=\"0\" onclick=\"checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation=\"0\" onclick=\"checkChecked(this); checkTableMissing(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$srv_grid['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</label>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ } else {
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<div class=\"category ' . $cssAlign . '\">';
+ # ni missing vrednost
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<label for=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\">';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation=\"' . $srv_grids[$i]['variable'] . '\" onclick=\"checkChecked(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].$srv_grid['naslov'];
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</label>';
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ }
+ }
+ }
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' </div>';
+
+
+ //uredi options za imagemapster in prikazovanja obmocij
+ //$options[$row['id']] = $options[$row['id']] .'{key: "'.$row1['naslov'].'", toolTip: "'.$htmltootip[$row['id']].' "} ,';
+
+ //$bg++;
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>';
+ //$htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</table>' . "\n";
+ }
+ //HTML ZA TOOLTIP - KONEC
+
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ //uredi options za imagemapster in prikazovanja obmocij
+ $options[$row['id']] = $options[$row['id']] .'{key: "'.$rowR['vre_id'].'", toolTip: "'.$htmltootip[$rowR['vre_id']].' "} ,';
+ }
+ echo '</map>';
+
+ $options[$row['id']] = rtrim($options[$row['id']], ","); //odstrani zadnjo vejico pri options
+ $options[$row['id']] = $options[$row['id']].']}'; //zapri areas z ]}
+ //echo $options[$row['id']];
+
+ //************************************************************************************************
+ //izris tabele z radio button, ki bo skrita in beležila odgovore na sliki
+ Multigrid::getInstance()->display($spremenljivka); //prikaze tabelo z radio button odgovori
+
+ //izris tabele z radio button, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+
+ ?>
+
+ <script>
+ $(document).ready(function () {
+ mapinitRadioGrid(<?=$row['id']?>, <?=$options[$row['id']]?>, <?=$hotspot_region_visibility_option?>, <?=$hotspot_tooltips_option?>, '<?=$hotspot_region_color?>', '<?=$hotspot_visibility_color?>', <?=$quick_view?>); //uredi delovanje imagemapster in prikazovanja obmocij ter tooltip-ov
+ });
+ </script>
+ <?
+ echo '</div>';
+ //prikaz obmocij na sliki - konec**************************************************************************
+
+
+ echo ' </div>';
+
+ //************************* Izris leve strani - konec
+ }
+
+ public function ranking($spremenljivka, $oblika){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
+ $hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0); //za checkbox
+ $hotspot_region_visibility = ($spremenljivkaParams->get('hotspot_region_visibility') ? $spremenljivkaParams->get('hotspot_region_visibility') : 1); //za radio "vedno" in "ob mouseover"
+ $hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 0);
+ $hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
+ $hotspot_visibility_color = ($spremenljivkaParams->get('hotspot_visibility_color') ? $spremenljivkaParams->get('hotspot_visibility_color') : "");
+
+ if($hotspot_region_visibility_option){
+ $hotspot_region_visibility_option = $hotspot_region_visibility;
+ }
+
+ // Pri vpogledu moramo deaktivirati radio button-e (quick_edit & quick_view = 0)
+ $quick_view = json_encode(get('quick_view'));
+
+
+ //zaslon razdelimo na dva dela - izris leve strani***************************************
+ echo '<div id="half_hot_spot_1" class="hotspot" style="width: 40%; float: left;">';
+
+ //imena obmocij iz srv_vrednost
+ $sql1 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ $sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
+
+ echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'" style="display:none; ">';
+
+ // Ali gre za sazu anketo
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu'))
+ echo '<input type="hidden" id="hotspot_image_'.$row[id].'_sazu" value="1">';
+
+ if (mysqli_num_rows($sql1) == 0){
+ echo ' <div class="variabla">';
+ echo '</div>';
+ }
+ else{
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
+ echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
+ echo '</div>';
+ }
+ }
+
+ echo '</div>';
+
+ //prikaz slike
+ $findme = 'img';
+ $pos = strpos($hotspot_image, $findme);
+ if($pos === false) { //string NOT present
+
+ }
+ else { //string present
+ $usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
+ //v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
+ $hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
+ }
+
+ echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
+ //prikaz slike - konec
+
+ //prikaz obmocij na sliki*********************************************************************************
+ $options[$row['id']] = '{areas: ['; //belezi kodo za settings-e za prikazovanje tooltip v imagemapster
+
+ //HTML ZA TOOLTIP
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_hotspot_regions WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ //$row_grid['naslov'] = $naslov;
+ $row_grid['vrstni_red'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ }
+ }
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT vre_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, vrstni_red FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $htmltootip[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = '';
+ $htmltootip1[$row1['id']] = $htmltootip1[$row1['id']].''.$row1['id'].'<br />';
+
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $htmltootip[$row1['id']] .= '<div id=\"im_vrednost_if_' . $row1['id'] . '\"' . (($row1['hidden'] == 1) ? 'style=\"display:none\"' : '') . (($row1['hidden'] == 2) ? 'class=\"answer-disabled\"' : '') . '\">';
+
+ $htmltootip[$row1['id']] .= '<div class=\"question\">';
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu'))
+ $htmltootip[$row1['id']] .= '<div class=\"title\">Razvrsti območje od 1 do 6 glede na privlačnost:</div>';
+ else
+ $htmltootip[$row1['id']] .= '<div class=\"title\">'.$row1['naslov'].'</div>';
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ $htmltootip[$row1['id']] .= '<div class=\"missing ' . $cssAlign . '\">';
+ # imamo missing vrednost
+ $htmltootip[$row1['id']] .= '<label for=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ $htmltootip[$row1['id']] .= '<input type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_grid_missing_value_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation=\"0\" onclick=\"checkChecked(this); checkTableMissing(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRadioGrid(this, ' . $row1['id'] . ');\">';
+
+ $htmltootip[$row1['id']] .= '<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ $htmltootip[$row1['id']] .= $srv_grid['naslov'];
+ $htmltootip[$row1['id']] .= '</label>';
+ $htmltootip[$row1['id']] .= '</div>';
+ }
+ else {
+ $htmltootip[$row1['id']] .= '<div class=\"category ' . $cssAlign . '\">';
+
+
+ // Za SAZU moramo posebej obarvati
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+ # ni missing vrednost
+ $htmltootip[$row1['id']] .= '<label for=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ $htmltootip[$row1['id']] .= '<input vrstni_red='.$srv_grid['vrstni_red'].' type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation=\"' . $srv_grids[$i]['variable'] . '\" onclick=\"checkChecked(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRankingSazu(this, ' . $row1['id'] . ');\">';
+ $htmltootip[$row1['id']] .= '<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ //besedilo ob radio buttonu
+ $htmltootip[$row1['id']] .= $srv_grid['vrstni_red'];
+
+ //besedilo ob radio buttonu - konec
+ $htmltootip[$row1['id']] .= '</label>';
+ }
+ else{
+ # ni missing vrednost
+ $htmltootip[$row1['id']] .= '<label for=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\">';
+
+ $htmltootip[$row1['id']] .= '<input vrstni_red='.$srv_grid['vrstni_red'].' type=\"radio\" ' . (!$hideName ? ' name=\"vrednost_' . $row1['id'] . '\"' : '') . ' id=\"im_vrednost_' . $row1['id'] . '_grid_' . $value . '\" value=\"' . $value . '\"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation=\"' . $srv_grids[$i]['variable'] . '\" onclick=\"checkChecked(this); if (typeof checkBranching == \'function\'){checkBranching();} setCheckedClass(this, null, ' . $row1['id'] . '); mapdelovanjeRanking(this, ' . $row1['id'] . ');\">';
+ $htmltootip[$row1['id']] .= '<span class=\"enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'\"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+ //besedilo ob radio buttonu
+ $htmltootip[$row1['id']] .= $srv_grid['vrstni_red'];
+ //besedilo ob radio buttonu - konec
+ $htmltootip[$row1['id']] .= '</label>';
+ }
+ $htmltootip[$row1['id']] .= '</div>';
+ }
+ }
+ }
+
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].' </div>'; //konec elementa question
+
+
+ //KOMENTAR v popupu******************************************************************************************************
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+
+ $sqlComment = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ // Najdemo naslednje textgrid vprasanje na isti strani, kamor zapisemo komentarje
+ $sqlComment = sisplet_query("SELECT v1.id, v1.naslov, v1.vrstni_red, s1.id as spr_id
+ FROM srv_vrednost v1, srv_spremenljivka s1
+ WHERE s1.gru_id='".$row[gru_id]."' AND s1.variable='regcom'
+ AND v1.spr_id=s1.id AND v1.vrstni_red='".$row1[vrstni_red]."'
+ ");
+ $rowComment = mysqli_fetch_array($sqlComment);
+
+ // Pridobimo ze mogoce vnesen text
+ $sqlCommentData = sisplet_query("SELECT text FROM srv_data_textgrid".get('db_table')."
+ WHERE spr_id='".$rowComment['spr_id']."' AND usr_id='".get('usr_id')."' AND vre_id='".$rowComment['id']."'
+ ");
+ $rowCommentData = mysqli_fetch_array($sqlCommentData);
+
+ // Izrisemo input box, ki je sinhroniziran z inputi naslednjega skritega textgrid vprasanja
+ $textarea_id = 'vrednost_'.$rowComment['id'].'_grid_1';
+
+ $komentar = '<textarea onkeyup=\"mapdelovanjeRankingKomentar(\''.$textarea_id.'\', this.value);\" id=\"im_vrednost_komentar_' . $row1['id'] . '\" name=\"vrednost_komentar_' . $row1['id'] . '\" >';
+ $komentar .= $rowCommentData['text'];
+ $komentar .= '</textarea>';
+
+ $htmltootip[$row1['id']] .= ' <div class=\"komentar\">Opišite s ključno besedo:'.$komentar.'</div>';
+ }
+ //KOMENTAR - KONEC **********************************************************************************************
+
+
+ $htmltootip[$row1['id']] .= '<span class=\"close_button\" onClick=\"removeMapsterTooltip();\" style=\"margin:\">Zapri</span>';
+
+ //uredi options za imagemapster in prikazovanja obmocij
+ $htmltootip[$row1['id']] = $htmltootip[$row1['id']].'</div>'; //konec elementa z radio buttoni
+ }
+
+ //echo $htmltootip[$row1['id']];
+ //HTML ZA TOOLTIP - KONEC
+
+ echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
+ while ($rowR = mysqli_fetch_array($sqlR)) {
+ echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
+ //uredi options za imagemapster in prikazovanja obmocij
+ $options[$row['id']] = $options[$row['id']] .'{key: "'.$rowR['vre_id'].'", toolTip: "'.$htmltootip[$rowR['vre_id']].' "} ,';
+ }
+ echo '</map>';
+
+ $options[$row['id']] = rtrim($options[$row['id']], ","); //odstrani zadnjo vejico pri options
+ $options[$row['id']] = $options[$row['id']].']}'; //zapri areas z ]}
+ //echo $options[$row['id']];
+
+ //************************************************************************************************
+ //izris ranking z oštevilčevanjem, ki bo skrita in beležila odgovore na sliki
+ Ranking::getInstance()->display($spremenljivka, $oblika); //prikaze tabelo z radio button odgovori
+ //izris ranking z oštevilčevanjem, ki bo skrita in beležila odgovore na sliki - konec
+ //***********************************************************************************
+
+
+ ?>
+ <script>
+ $(document).ready(function () {
+
+ //uredi delovanje imagemapster in prikazovanja obmocij ter tooltip-ov
+ mapinitRanking(<?=$row['id']?>, <?=$options[$row['id']]?>, <?=$hotspot_region_visibility_option?>, <?=$hotspot_tooltips_option?>, '<?=$hotspot_region_color?>', '<?=$hotspot_visibility_color?>', <?=$quick_view?>);
+
+ // Remove tooltip if clicked outside
+ $(window).click(function(e) {
+ if(e.target.class != "hotspot"
+ && e.target.class != "mapster_tooltip"
+ && !$(".hotspot").has(e.target).length
+ && !$(".mapster_tooltip").has(e.target).length){
+ removeMapsterTooltip();
+ }
+ });
+ });
+ </script>
+ <?
+ echo '</div>';
+ //prikaz obmocij na sliki - konec**************************************************************************
+
+
+ echo ' </div>';
+
+ //************************* Izris leve strani - konec
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/ImenaController.php b/main/survey/app/Controllers/Vprasanja/ImenaController.php
new file mode 100644
index 0000000..a2ae73b
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/ImenaController.php
@@ -0,0 +1,160 @@
+<?php
+/***************************************
+ * Description: SN imena
+ *
+ * Vprašanje je prisotno:
+ * tip 9
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Models\Model;
+
+// Iz admin/survey
+use enkaParameters;
+use Common;
+
+// Vprašanja
+
+class ImenaController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new ImenaController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ if ($spremenljivkaParams->get('NG_cancelButton') == '1') {
+ $cancelText = $spremenljivkaParams->get('NG_cancelText');
+ $cancelButton = 1;
+ } else {
+ $cancelText = self::$lang['srv_NG_cancelText'];
+ $cancelButton = 0;
+ }
+
+ // Dodajanje polj za vnos ime z gumbom (+)
+ if ($row['design'] == 0 || $_GET['m'] == 'quick_edit') {
+ $addText = ($spremenljivkaParams->get('NG_addText') ? $spremenljivkaParams->get('NG_addText') : self::$lang['srv_NG_addText']);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ $first = true;
+ $id = 1;
+
+ // WebSM anketa ima fiksno napolnjena polja ker gre samo za primer in se nic ne shranjuje
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" readonly name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="John">';
+ echo ' </div>';
+
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" readonly name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="Sarah">';
+ echo ' <img src="' . self::$site_url . 'main/survey/skins/Modern/blue_delete.png" style="cursor:pointer;" border="0">';
+ echo ' </div>';
+
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" readonly name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="Kevin">';
+ echo ' <img src="' . self::$site_url . 'main/survey/skins/Modern/blue_delete.png" style="cursor:pointer;" border="0">';
+ echo ' </div>';
+
+ //gumb za dodajanje polj
+ echo ' <div id="divTxt' . $spremenljivka . '">';
+ echo ' </div>';
+ echo ' <p style="cursor:pointer;"><img src="' . self::$site_url . 'main/survey/skins/Modern/add.png" border="0"> ' . $addText . '</p>';
+ } else {
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="' . $row2['text'] . '">';
+ if ($first || $_GET['m'] == 'quick_edit')
+ $first = false;
+ else
+ echo ' <a href="#" onClick="removeFormField(\'#row' . $id . '\'); return false;"><span class="faicon delete"></span></a>';
+
+ echo ' </div>';
+
+ $id++;
+ }
+
+ if ($_GET['m'] != 'quick_edit') {
+
+ //vedno imamo eno prazno vnosno polje
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" value="" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" onblur="checkName(\'' . $spremenljivka . '\', this); checkBranching();">';
+ if ($first)
+ $first = false;
+ else
+ echo ' <a href="#" onClick="removeFormField(\'#row' . $id . '\'); return false;"><span class="faicon delete"></span></a>';
+ echo ' </div>';
+ $id++;
+
+ // gumb za dodajanje polj
+ echo ' <input type="hidden" id="counter" value="' . $id . '">';
+
+ echo ' <div id="divTxt' . $spremenljivka . '">';
+ echo ' </div>';
+
+ echo ' <div class="sn_add_field"><a href="#" onClick="addFormField(' . $spremenljivka . '); return false;"><span class="faicon add"></span> ' . $addText . '</a></div>';
+ }
+ }
+ } // Fiksno stevilo polj za imena
+ elseif ($row['design'] == 1) {
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ $first = true;
+ $id = 1;
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ echo ' <div id="row' . $id . '" class="sn_name"><input type="text" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $id . '" size="40" value="' . $row2['text'] . '"></div>';
+ $id++;
+ }
+
+ // dodamo prazna vnosna polja
+ for ($i = $id; $i <= $row['size']; $i++)
+ echo ' <div id="row' . $i . '" class="sn_name"><input type="text" name="spremenljivka_' . $spremenljivka . '[]" id="txt' . $i . '" size="40" onblur="checkName(\'' . $spremenljivka . '\', this); checkBranching();"></div>';
+ } // 1 textbox - loceni z entri
+ elseif ($row['design'] == 2) {
+ $values = '';
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $values .= $row2['text'] . "\n";
+ }
+
+ echo '<textarea name="spremenljivka_' . $spremenljivka . '" style="width: 250px; height: 150px;">' . $values . '</textarea>';
+ } // Vnos stevila polj
+ elseif ($row['design'] == 3) {
+ $countText = ($spremenljivkaParams->get('NG_countText') ? $spremenljivkaParams->get('NG_countText') : self::$lang['srv_design_count']);
+ echo $countText . ': <input type="text" size="5" name="stImen_' . $spremenljivka . '" id="stImen_' . $spremenljivka . '" value="" onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); edit_size(' . $spremenljivka . ', stImen_' . $spremenljivka . '.value)">' . "\n";
+
+ echo '<div id="imena_' . $spremenljivka . '">';
+ echo '</div>';
+ }
+
+
+ //gumb za preskok (ce je vklopljen)
+ if ($cancelButton == 1)
+ echo ' <br><p><input class="prev" type="button" value="' . $cancelText . '" onclick="submitForm()"></p>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/MapsController.php b/main/survey/app/Controllers/Vprasanja/MapsController.php
new file mode 100644
index 0000000..a188a7b
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MapsController.php
@@ -0,0 +1,364 @@
+<?php
+/* * *************************************
+ * Description: Maps (google maps lokacija)
+ *
+ * Vprašanje je prisotno:
+ * tip 26 - lokacija
+ * podtip 2 - multi lokacija
+ * podtip 1 - moja lokacija
+ *
+ * Autor: Uros Podkriznik
+ * Created date: 22.04.2016
+ * *************************************** */
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+/**
+ * Description of MapsController
+ *
+ * @author uros p.
+ */
+class MapsController extends Controller {
+
+ public function __construct() {
+ parent::getGlobalVariables();
+ }
+
+ /* * **********************************************
+ * Get instance
+ * ********************************************** */
+
+ private static $_instance;
+
+ public static function getInstance() {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MapsController();
+ }
+
+ public function display($spremenljivka, $oblika) {
+ global $lang;
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $podtip = $row['enota'];
+ //$selected = Model::getOtherValue($spremenljivka);
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_variabla" class="variabla ' . $oblika['cssFloat'] . '">' . "\n";
+
+ //get input type - marker, polyline, polygon
+ $multi_input_type = $spremenljivkaParams->get('multi_input_type');
+
+ $map_data = array();
+ $map_data_info_shapes = array();
+
+ //ce je choose location
+ if($podtip == 3){
+
+ $loop_id_3 = "";
+ //force text to be null from sql
+ $force_text_null = 'false';
+
+ //do we have loop
+ if(get('loop_id') != null){
+ //does data for this loop already exist?
+ $sql1 = sisplet_query("SELECT id FROM srv_data_map WHERE usr_id='" . get('usr_id') .
+ "' AND spr_id='$spremenljivka' AND loop_id $loop_id", 'array');
+
+ //data does not exist, force null on text
+ if(count($sql1) == 0)
+ $force_text_null = 'true';
+ else
+ $loop_id_3 = " AND dm.loop_id = '" . get('loop_id') . "'";
+ }
+
+
+ $sql1 = sisplet_query("SELECT vm.vre_id, vm.lat, vm.lng, vm.address, v.naslov, IF($force_text_null, NULL, dm.text) as text FROM srv_vrednost AS v
+ LEFT JOIN srv_vrednost_map AS vm ON v.id = vm.vre_id
+ LEFT JOIN srv_data_map AS dm ON v.id = dm.vre_id AND dm.usr_id='" . get('usr_id') . "'
+ WHERE v.spr_id='$spremenljivka' $loop_id_3", 'array');
+
+ //je vec vrednosti
+ if(!isset($sql1['lat']))
+ $map_data = $sql1;
+ //je ena vrednost
+ else
+ $map_data[] = $sql1;
+
+
+ //get info shapes
+ $sql2 = sisplet_query("SELECT lat, lng, address, overlay_id FROM srv_vrednost_map
+ WHERE spr_id='$spremenljivka' AND overlay_type='polyline' ORDER BY overlay_id, vrstni_red", 'array');
+
+ //create json data for info shapes
+ $st_linij=0;
+ $last_id=0;
+ foreach ($sql2 as $line_row) {
+ if($line_row['overlay_id'] != $last_id){
+ $st_linij++;
+ $last_id = $line_row['overlay_id'];
+ $map_data_info_shapes[$st_linij-1]['overlay_id']=$line_row['overlay_id'];
+ $map_data_info_shapes[$st_linij-1]['address']=$line_row['address'];
+ $map_data_info_shapes[$st_linij-1]['path']= array();
+ }
+
+ $path = array();
+ $path['lat']=floatval($line_row['lat']);
+ $path['lng']=floatval($line_row['lng']);
+
+ array_push($map_data_info_shapes[$st_linij-1]['path'], $path);
+ }
+ }
+ //ce je polygon ali polyline
+ else if($podtip == 2 && $multi_input_type != '' && $multi_input_type != 'marker'){
+ //ce so podatki ze v bazi (rec. uporabnik klikne 'Prejsnja stran')
+ $sql1 = sisplet_query("SELECT lat, lng FROM srv_data_map WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id "
+ . "ORDER BY vrstni_red", 'array');
+
+ //if not empty
+ if(count($sql1)>0){
+ $map_data = $sql1;
+
+ //iterate and convert all coordinates to float - needed for JS
+ for($i=0; $i<count($map_data); $i++){
+ $map_data[$i]['lat'] = floatval($map_data[$i]['lat']);
+ $map_data[$i]['lng'] = floatval($map_data[$i]['lng']);
+ }
+ }
+ }
+ //ce so markerji
+ else{
+ //ce so podatki ze v bazi (rec. uporabnik klikne 'Prejsnja stran')
+ $sql1 = sisplet_query("SELECT lat, lng, address, text FROM srv_data_map WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id "
+ . "ORDER BY vrstni_red", 'array');
+
+ //je vec vrednosti
+ if(!isset($sql1['lat']))
+ $map_data = $sql1;
+ //je ena vrednost
+ else
+ $map_data[] = $sql1;
+ }
+
+ //dobi fokus mape
+ $fokus = $spremenljivkaParams->get('fokus_mape');
+
+ //pridobi parametre za centriranje mape in jo nastavi za kasnejso uporabo v js
+ $fokus_koordinate = $spremenljivkaParams->get('fokus_koordinate'); //dobi fokus koordinat mape
+ if(!isset(json_decode($fokus_koordinate)->center->lat))
+ $fokus_koordinate = false;
+
+ //dobi max odgovore
+ $maxmark = $spremenljivkaParams->get('max_markers');
+ //staro, kasneje sem dodal max_markers - to je zaradi vasjinega workshopa
+ if($maxmark == '')
+ $maxmark = $spremenljivkaParams->get('date_range_max');
+
+ //dobi user location
+ $spremenljivkaParams->get('user_location') == 1 ? $userLocation = json_encode(true) :
+ $userLocation = json_encode(false);
+
+ //dobi podvprasanje za marker
+ $spremenljivkaParams->get('marker_podvprasanje') == 1 ? $podvprasanje = json_encode(true) :
+ $podvprasanje = json_encode(false);
+
+ //dobi naslov podvprasanje za marker
+ $podvprasanje_naslov = $spremenljivkaParams->get('naslov_podvprasanja_map');
+ if(!$spremenljivkaParams->get('naslov_podvprasanja_map'))
+ $podvprasanje_naslov = '';
+
+ //ali se prikaze searchbox
+ $spremenljivkaParams->get('dodaj_searchbox') == 1 ? $dodaj_searchbox = json_encode(true) :
+ $dodaj_searchbox = json_encode(false);
+
+ //ce je tip moja lokacija
+ if($podtip == 1){
+ //vkljucijo se funkcije za klik na mapi
+ $klikNaMapo = json_encode(true);
+ //vkljuci se iskanje lokacije uporabnika
+ //$userLocation = json_encode(True);
+ $mojaLokacija = json_encode(True);
+ if(!$fokus)
+ $fokus = "Slovenia";
+ }
+ //ce je tip multi lokacija
+ elseif($podtip == 2){
+ //vkljuci se iskanje lokacije uporabnika
+ //$userLocation = json_encode(false);
+ $mojaLokacija = json_encode(false);
+ if(!$fokus)
+ $fokus = "Slovenia";
+
+ if($multi_input_type != 'marker'){
+ $klikNaMapo = json_encode(false);
+ //izrisi opozorilo o max odgovorov
+ echo '<div id="end_shape_info_'.$spremenljivka.'" style="display: inline-block; color:red; font-size:0.8em;">'.$lang['srv_resevanje_info_end_shpe_map'].'</div>';
+ }
+ else{
+ //izrisi opozorilo o max odgovorov
+ echo '<div id="max_marker_'.$spremenljivka.'" style="display: none; color:red; font-size:0.8em;">'.$lang['srv_resevanje_max_marker_opozorilo_map'].'</div>';
+ //vkljucijo se funkcije za klik na mapi
+ $klikNaMapo = json_encode(true);
+ }
+ }
+ //ce je podtip izberi lokacijo
+ elseif($podtip == 3){
+ //izkljucijo se funkcije za klik na mapi
+ $klikNaMapo = json_encode(false);
+ $mojaLokacija = json_encode(false);
+ }
+
+ //ali smo v pregledu izpolnjene ankete? ce da, se v JS nastavi na viewMode=true
+ $quick_view = json_encode(get('quick_view'));
+ //disablaj klik na mapo, ce je v quick_view
+ if(get('quick_view'))
+ $klikNaMapo = json_encode(false);
+
+ //warningi za geolokacijo
+ echo '<div id="warning_geo_'.$spremenljivka.'" style="display: none; color:orange; font-size:0.8em;"></div>';
+
+ //izrisi search box za v mapo
+ echo '<input id="pac-input_'.$spremenljivka.'" class="pac-input" type="text" onkeypress="return event.keyCode != 13;" style="display: none;">';
+ //izrisi mapo
+ echo '<div id="map_'.$spremenljivka.'" style="width:100%;height:300px;border-style: solid;border-width: 1px;border-color: #b4b3b3;"></div>';
+
+ ?>
+ <script type="text/javascript">
+ //zaradi resevanja preko mobilnikov, dodaj ta class, da se iznici top padding (mobile.css)
+ document.getElementById("spremenljivka_<?php echo $spremenljivka; ?>")
+ .getElementsByClassName("variable_holder")[0].className += " map_spremenljivka";
+
+ //preveri, ce je google API ze loadan (ce se je vedno na novo naloadal, je prislo do errorjev)
+ if((typeof google === 'object' && typeof google.maps === 'object'))
+ MapDeclaration();
+ else{
+ mapsAPIseNi(MapDeclaration);
+ }
+
+ function MapDeclaration(){
+ //spremenljivke
+ var spremenljivka = "<?php echo $spremenljivka; ?>";
+ //podtip
+ var podtip = "<?php echo $podtip; ?>";
+ max_mark[spremenljivka] = "<?php echo $maxmark; ?>";
+ //je ta spremenljivka tipa moja lokacija?
+ var mojaLokacija = <?php echo $mojaLokacija; ?>;
+ //ze ta spremenljivka vsebuje podatke? primer, ce gre uporabnik na prejsnjo stran
+ var map_data = JSON.parse('<?php echo addslashes(json_encode($map_data)); ?>');
+ //vsebuje ta spremenljivka F user location (trenutna lokacija)
+ var doUserLocation = <?php echo $userLocation; ?>;
+ //ali se izrise podvprasanje v infowindow
+ podvprasanje[spremenljivka] = <?php echo $podvprasanje; ?>;
+ //naslov podvprasanja v infowindow
+ podvprasanje_naslov[spremenljivka] = '<?php echo $podvprasanje_naslov; ?>';
+ //se naj izvede F klik na mapo (najbrz bo to vedno true)
+ var doKlikNaMapo = <?php echo $klikNaMapo; ?>;
+ //smo v pregledu izpolnjene ankete?
+ viewMode = <?php echo $quick_view; ?>;
+ //centerInMap = string naslova, kaj bo zajel zemljevid. Rec. Slovenija / ali Ljubljana
+ var centerInMap = "<?php echo $fokus; ?>";
+ //get input type - marker, polyline, polygon
+ var multi_input_type = "<?php echo $multi_input_type; ?>";
+ //steje markerje (int id spremenljivke: int st markerjev)
+ st_markerjev[spremenljivka] = 0;
+ //array of all marksers
+ allMarkers['<?php echo $spremenljivka; ?>'] = [];
+
+ //pridobi parametre za centriranje mape in jo nastavi za kasnejso uporabo
+ var centerInMapKoordinate = <?php echo json_encode($fokus_koordinate)?>;
+ if(centerInMapKoordinate)
+ centerInMapKoordinate = JSON.parse(centerInMapKoordinate);
+
+ //ce je spremenljivka tipa moj lokacija, jo shrani v array
+ if(mojaLokacija)
+ ml_sprem.push(spremenljivka);
+
+ //mapType = tip zemljevida, ki bo prikazan. Recimo za satelitsko sliko google.maps.MapTypeId.SATELLITE (možno še .ROADMAP)
+ var mapType = google.maps.MapTypeId.ROADMAP;
+
+ //Deklaracija potrebnih stvari za delovanje in upravljanje google maps JS API
+ var mapOptions = {
+ streetViewControl: false,
+ navigationControl: false,
+ mapTypeId: mapType
+ };
+
+ //ce je v bazi naslov enak vpisanemu v nastavitvah, nastavi po parametrih
+ if(centerInMapKoordinate){
+ mapOptions.center = {lat: parseFloat(centerInMapKoordinate.center.lat),
+ lng: parseFloat(centerInMapKoordinate.center.lng)};
+ mapOptions.zoom = parseInt(centerInMapKoordinate.zoom);
+ }
+
+ //deklaracija geocoderja (API)
+ if(!geocoder)
+ geocoder = new google.maps.Geocoder();
+ //infowindow iz API-ja, za prikaz markerja in informacije o markerju
+ if(!infowindow)
+ infowindow = new google.maps.InfoWindow();
+ //deklaracija zemljevida
+ var mapdiv = document.getElementById("map_"+spremenljivka);
+ var map = new google.maps.Map(mapdiv, mapOptions);
+ //shrani podatke za center v mapo v primeru, ce je spremenljivka hidden
+ //zaradi loopa, da se lahko ob prikayu ponovno nastavi
+ map.centerInMap = centerInMap;
+ map.centerInMapKoordinate = centerInMapKoordinate;
+ //to se kasneje uporabi za pridobitev mape z id-em spremenljivke
+ mapdiv.gMap = map;
+ //deklaracija mej/okvira prikaza na zemljevidu
+ bounds[spremenljivka] = new google.maps.LatLngBounds();
+
+ //ce ze obstajajo markerji ali podatki za mapo, jo nafilaj
+ if (multi_input_type && multi_input_type != 'marker'){
+ if(map_data.length > 0)
+ map_data_fill_shape(spremenljivka, map_data, multi_input_type);
+ else
+ drawShape(spremenljivka, null, multi_input_type);
+ }
+ else if (map_data.length > 0)
+ map_data_fill(spremenljivka, map_data, podtip);
+ //ce ne obstajajo podatki, centriraj mapo na nastavljeno obmocje
+ else if(!centerInMapKoordinate)
+ centrirajMap(centerInMap, map);
+
+ if(podtip == 3){
+ //fill info shapes in map if exists
+ var map_data_info_shapes = JSON.parse('<?php echo addslashes(json_encode($map_data_info_shapes)); ?>');
+ if (map_data_info_shapes.length > 0)
+ map_data_fill_info_shapes('<?php echo $spremenljivka; ?>', map_data_info_shapes);
+ }
+
+ //izvedi, ce je nastavljena trenutna lokacija respodenta
+ if (doUserLocation && map_data.length === 0){
+ usrLoc_sprem.push(spremenljivka);
+ userLocation(spremenljivka);
+ }
+
+ //izvedi, ce je nastavljen klik na mapo
+ if (doKlikNaMapo)
+ klikNaMapo(spremenljivka);
+
+ //izrisi in nastavi search box na zemljevidu
+ if(<?php echo $dodaj_searchbox; ?>)
+ searchBox(spremenljivka, function doAfterPlaceFromSearchBox(pos, address){
+ if(max_mark[spremenljivka]-st_markerjev[spremenljivka] > 0)
+ createMarker(spremenljivka, address, pos, true);
+ });
+ }
+
+ </script>
+ <?php
+ echo '</div>';
+ }
+
+}
diff --git a/main/survey/app/Controllers/Vprasanja/MaxDiffController.php b/main/survey/app/Controllers/Vprasanja/MaxDiffController.php
new file mode 100644
index 0000000..e1807b9
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MaxDiffController.php
@@ -0,0 +1,295 @@
+<?php
+/***************************************
+ * Description: Multigrid maxdiff
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 5
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+class MaxDiffController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MaxDiffController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za maxdiff
+ */
+ public function display($spremenljivka)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ // diferencial
+ $size += 2;
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ //$cellsize = round(80/$size);
+ $cellsize = round(160 / $size);
+ } else {
+ //$cellsize = 'auto';
+ $cellsize = round(160 / $size);
+ }
+
+ //$spacesize = round(80/$size/4);
+ $spacesize = round(240 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table maxdiff">' . "\n";
+
+
+ echo '<thead>';
+ echo ' <tr>' . "\n";
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ //echo ' <td></td>'."\n";
+
+ if ($i == 1) {
+ echo ' <td></td>' . "\n";
+ }
+
+
+ }
+ }
+
+ echo ' </tr>' . "\n";
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '">' . "\n";
+
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing ' . $cssAlign . '">';
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input data-col="' . $i . $row[0] . '" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ if ($i == 1) {
+ echo ' <td style="text-align: center;" class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+ echo '</td>' . "\n";
+ }
+
+
+ } else {
+ echo '<td class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input data-col="' . $i . $row[0] . '" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') .'"'.
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox().'px;"') : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ //urejanje navpicnega dela grupiranja radio button - vodoravni je urejen po defaultu s pomočjo atributa name
+ echo '
+ <script>
+
+ $(document).ready(
+ function(){
+ var col, elem, ime;
+ ime = "vrednost_' . $row1['id'] . '";
+
+ $("input[name=" + ime + "]").click(function() {
+ elem = $(this);
+ col = elem.data("col");
+ $("input[data-col=" + col + "]").prop("checked", false);
+ elem.prop("checked", true);
+ });
+ }
+ );
+ </script>
+ ';
+
+ if ($i == 1) {
+ echo ' <td style="text-align: center;" class="question">';
+ echo $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo '</td>';
+ }
+ }
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/MultigridController.php b/main/survey/app/Controllers/Vprasanja/MultigridController.php
new file mode 100644
index 0000000..85fd49d
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MultigridController.php
@@ -0,0 +1,1686 @@
+<?php
+/***************************************
+ * Description: Multigrid: dropdown, select box, checkbox, multiple
+ *
+ * Vprašanje je prisotno:
+ * tip 6 - enota 2, enota 6
+ * tip 16 - enota 3, enota 6, enota 0
+ * tip 19
+ * tip 20
+ * tip 24
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+
+class MultigridController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MultigridController();
+ }
+
+ protected $spremenljivka;
+
+ /**
+ * @desc prikaze vnosno polje za navadno tabelo in tabelo diferencial
+ * Stara funkcija $this->displayMultigrid($spremenljivka);
+ */
+ public function display($spremenljivka)
+ {
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // prej:
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+
+ // Za izris traku
+ $diferencial_trak = ($spremenljivkaParams->get('diferencial_trak') ? $spremenljivkaParams->get('diferencial_trak') : 0); //za checkbox trak
+ $trak_num_of_titles = ($spremenljivkaParams->get('trak_num_of_titles') ? $spremenljivkaParams->get('trak_num_of_titles') : 0); //belezi stevilo nadnaslovov
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0)){ //ce je trak vklopljen @ diferencial ali klasicna tabela
+ $trak_class = 'trak_class';
+ $trak_class_input = 'trak_class_input';
+ $question = 'question_trak';
+
+ if ($row['enota'] == 1){ //ce je diferencial
+ $gridWidth = 15; //za sirino celic skrajno levo pa desno od traku
+ }
+
+ if($trak_num_of_titles != 0){
+ $display_trak_num_of_titles = 'style="display:none;"';
+ $trak_nadnaslov_table_td_width = 100 / $trak_num_of_titles; //spremenljivka za razporeditev sirine nadnaslovov @ traku
+ }
+
+ $display_trak_num_of_titles = '';
+ }
+ else{
+ $trak_class = '';
+ $trak_class_input = '';
+ $question = 'question';
+ $display_trak_num_of_titles = 'style="display:none;"';
+ }
+
+ for($i = 1; $i <= $trak_num_of_titles; $i++){
+ $trak_nadnaslov[$i] = ($spremenljivkaParams->get('trak_nadnaslov_'.$i.'') ? $spremenljivkaParams->get('trak_nadnaslov_'.$i.'') : $lang['srv_new_text']);
+ }
+ // Za izris traku - konec
+
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ // diferencial
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+
+ // IZRIS TABELE
+ echo '<table class="grid_table multigrid">' . "\n";
+
+
+ // Colgroup
+ // ce je gridWidth enak nula, imamo skrito labelo.
+ // hideLabels bom posredoval naprej v funkcije
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo ' <col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+ }
+
+
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++) {
+ echo '<col>';
+ }
+ echo '</colgroup>';
+
+
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+ if ($row['enota'] > 0 && !in_array($row['enota'], [11,12])) {
+ // desnih label ne bom skrival, ker je neumno dati dvojne labele + skrite labele!
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="differential">';
+ echo ' <col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ }
+ // Colgroup - konec
+
+
+ // Header vrstica
+ echo '<thead>';
+ $this->displayMultigridHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $diferencial_trak, $trak_nadnaslov, $display_trak_num_of_titles, $middle_row=false, $hideLabels);
+ echo '</thead>';
+
+
+ // Body tabele
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+
+ # po potrebi prevedemo naslov2 za semanticni diferencial
+ if($row['enota'] == 1){
+ $naslov2 = Language::getInstance()->srv_language_vrednost($row1['id'], true);
+ if ($naslov2 != '') {
+ $row1['naslov2'] = $naslov2;
+ }
+ }
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">' . "\n";
+
+ if ($hideLabels == false) {
+
+ echo ' <td class="'.$question.'">';
+
+ echo $row1['naslov'];
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo '</td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ if (count($srv_grids) > 0) {
+
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 1);">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo '</label>';
+
+ echo '</td>' . "\n";
+ }
+ else {
+ if($diferencial_trak == 1 && ($row['enota'] == 1 || $row['enota'] == 0) ){
+ echo '<td onClick="checkBranching(); trak_change_bg(this, '.$diferencial_trak.', '.$srv_grid['spr_id'].', 0);" id="trak_tbl_' . $row1['id'] . '_'.$srv_grid['vrstni_red'].'" class="category' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' '.$trak_class.' '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? 'trak_container_bg' : '').'">';
+
+ # ni missing vrednost
+ echo '<input vre_id = '.$row1['id'].' class="'.$trak_class_input.'" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '">';
+ echo '<label class="radio-button-label">'.$srv_grid['variable'].'</label>';
+
+ echo '</td>' . "\n";
+ }
+ else{
+ // Pri VAS in slikovnem tiput mora biti 'checked' označen tudi pri TD elementu
+ $_checked = (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '');
+
+ // V kolikor imamo vizalno skalo in smeške
+ if($row['enota'] == 11){
+ $tabelaSmeski = 'visual-radio-scale visual-radio-table';
+ }
+ elseif($row['enota'] == 12){
+ $tabelaSmeski = 'custom_radio_picture custom-radio-table';
+ }
+ else{
+ $tabelaSmeski ='';
+ }
+
+ echo '<td class="category '.$tabelaSmeski. $_checked.' ' . $cssAlign . '">';
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . $_checked . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . '); customRadioTableSelect(' . $row1['id'] . ', ' . $value. ');">';
+
+ if($row['enota'] == 11){
+ echo '<span class="enka-vizualna-skala siv-'.$row['grids'].$value.'"></span>';
+ }elseif($row['enota'] == 12){
+ echo '<span class="enka-custom-radio '.$spremenljivkaParams->get('customRadio').'"></span>';
+ }else {
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ }
+ echo '</label>';
+
+ //Pri smeških moramo pognati JS, da doda ustrezen razred 'obarvan'
+ if($row['enota'] == 12 && ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing)){
+ echo '<script>
+ $(document).ready( function(){ customRadioTableSelect(\''.$row1['id'].'\', \''.$value.'\'); } );
+ </script>';
+ }
+
+ echo '</td>' . "\n";
+ }
+ }
+ }
+ }
+ # dodamo še enoto
+ if ($row['enota'] == 1) {
+ // Datapiping
+ $row1['naslov2'] = Helper::dataPiping($row1['naslov2']);
+
+ echo ' <td></td>' . "\n";
+ echo ' <td class="differential question_trak">' . $row1['naslov2'] . '</td>' . "\n";
+ }
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+
+
+ // za ureditev prilagajanja label stolpcev - prilagajanje trem opisnim nadnaslovom
+ $custom_column_label_option = ($spremenljivkaParams->get('custom_column_label_option') ? $spremenljivkaParams->get('custom_column_label_option') : 1);
+ echo '<script>
+ change_custom_column_label_respondent(\'' . $row['grids'] . '\', \'' . $row['id'] . '\', \'' . $custom_column_label_option . '\');
+ </script>';
+
+ // prilagajanje stevilu izbranih nadnaslovov
+ if($trak_num_of_titles != 0){
+ ?>
+ <script>
+ $(document).ready(function(){
+ trak_edit_num_titles_respondent(<?=$row['grids']?>, <?=$spremenljivka?>, <?=$trak_num_of_titles?>, <?=json_encode($trak_nadnaslov)?>);
+ });
+ </script>
+ <?
+ }
+ // za ureditev prilagajanja label stolpcev - konec
+
+
+ // JS za ponvaljanje naslovne vrstice
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+ if($grid_repeat_header > 0){
+ echo '<script> gridRepeatHeader(\''.$grid_repeat_header.'\', \''.$row['id'].'\'); </script>';
+ }
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayMultigridDropdown($spremenljivka);
+ ************************************************/
+ public function dropdown($spremenljivka)
+ {
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $_otherStatusFields = array(99 => 'undecided', 98 => 'rejected', 97 => 'inappropriate');
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ if ($gridAlign == 0)
+ $cssAlign = ' class="alignCenter"';
+ elseif ($gridAlign == 1)
+ $cssAlign = ' class="alignLeft"';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' class="alignRight"';
+
+ echo ' <table class="grid_table multigriddropdown">' . "\n";
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ echo '<col>';
+ echo '</colgroup>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // cache tabele srv_grid, da se ne bere vsakic znova
+ $srv_grids = array();
+
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') $row_grid['naslov'] = $naslov;
+
+ $srv_grids[$row_grid['vrstni_red']] = $row_grid;
+ }
+
+ // cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo '<tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.$row3['text'].'">';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ echo '<td ' . $cssAlign . '>';
+
+
+ if ($row['enota'] == 2) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $prvaVrstica_roleta = ($spremenljivkaParams->get('prvaVrstica_roleta') ? $spremenljivkaParams->get('prvaVrstica_roleta') : 1);
+
+ //echo '<select multiple name="vrednost_'.$row1['id'].'" id="vrednost_'.$spremenljivka.'_'.$row1['id'].'" size="'.$sbSize.'" onchange="checkBranching(); omejiSelectBoxMulti('.$spremenljivka.','.$row1['id'].'); clickSelectBox('.$spremenljivka.');" multiple = " ">'."\n";
+ echo '<select name="vrednost_' . $row1['id'] . '" id="vrednost_' . $spremenljivka . '_' . $row1['id'] . '" size="1" onclick="checkBranching(); omejiSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . '); clickSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . ');" >' . "\n";
+ switch ($prvaVrstica_roleta) {
+ case "1":
+ echo ' <option value=""></option>';
+ break;
+ case "2":
+
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+ }
+
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $row5 = $srv_grid;
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ echo '<option name="vrednost_' . $row1['id'] . '_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ }
+ }
+
+
+ echo '</select>' . "\n";
+ echo '</td>' . "\n";
+
+ echo '</tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayMultigridSelectBox($spremenljivka);d
+ ************************************************/
+ public function selectBox($spremenljivka)
+ {
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $_otherStatusFields = array(99 => 'undecided', 98 => 'rejected', 97 => 'inappropriate');
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ if ($gridAlign == 0)
+ $cssAlign = ' class="alignCenter"';
+ elseif ($gridAlign == 1)
+ $cssAlign = ' class="alignLeft"';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' class="alignRight"';
+
+ echo ' <table class="grid_table multigriddropdown">' . "\n";
+
+ if ($hideLabels ==false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ echo '<col>';
+ echo '</colgroup>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $missingi = array();
+
+ // cache tabele srv_grid, da se ne bere vsakic znova
+ $srv_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') $row_grid['naslov'] = $naslov;
+
+ $srv_grid[$row_grid['vrstni_red']] = $row_grid;
+
+ //belezenje missingov
+ if($row_grid['other']!=0){
+ array_push($missingi, $row_grid['naslov']);
+ }
+ }
+
+ // cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo '<tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.$row3['text'].'">';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ echo '<td ' . $cssAlign . '>';
+
+ // todo id se podvaja - popravljeno
+ //echo '<select name="vrednost_'.$row1['id'].'" id="vrednost_'.$spremenljivka.'_'.$row1['id'].'" size="1" onchange="checkBranching();" >'."\n";
+
+ if ($row['tip'] == 6) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+ //echo '<select multiple name="vrednost_'.$row1['id'].'" id="vrednost_'.$spremenljivka.'_'.$row1['id'].'" size="'.$sbSize.'" onchange="checkBranching(); omejiSelectBoxMulti('.$spremenljivka.','.$row1['id'].'); clickSelectBox('.$spremenljivka.');" multiple = " ">'."\n";
+ echo '<select multiple name="vrednost_' . $row1['id'] . '" id="vrednost_' . $spremenljivka . '_' . $row1['id'] . '" size="' . $sbSize . '" onclick="checkBranching(); omejiSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . '); clickSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . ');" multiple = " ">' . "\n";
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo ' <option value=""></option>';
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+
+ } elseif ($row['tip'] == 16) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+
+ echo '<select name="vrednost_' . $row1['id'] . '[]" id="vrednost_' . $spremenljivka . '_' . $row1['id'] . '" size="' . $sbSize . '" onclick="checkBranching(); clickSelectBoxMulti(' . $spremenljivka . ',' . $row1['id'] . ');" multiple = " ">' . "\n";
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo ' <option value=""></option>';
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+ }
+
+ //echo '<option value=""></option>'."\n";
+
+ //for ($i = 1; $i <= $row['grids']; $i++) {
+ for ($i = 1; $i <= count($srv_grid); $i++) {
+
+ $row5 = $srv_grid[$i];
+ $value1 = $value2 = $row5['id'];
+
+ if($row5['other']!=0){ //ce so missingi
+ $value2 = $row5['other'];
+ }
+
+ // todo name je obsolete - popravljeno
+ if ($row['tip'] == 16) {
+ //echo '<option name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ echo '<option name="vrednost_' . $row1['id'] . '_grid_' . $value1 . '" id="vrednost_' . $row1['id'] . '_grid_' . $valu1e . '" value="' . $value2 . '"' . (($grid_id == $value1 && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ //echo '<option name="vrednost_' . $row1['id'] . '_grid_' . $value1 . '" id="vrednost_' . $row1['id'] . '_grid_' . $valu1e . '" value="' . $value2 . '"' . (($grid_id == $value1 && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="0" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ } else {
+ //echo '<option name="vrednost_' . $row1['id'] . '_' . $i . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ echo '<option name="vrednost_' . $row1['id'] . '_' . $i . '" id="vrednost_' . $row1['id'] . '_grid_' . $value1 . '" value="' . $value2 . '"' . (($grid_id == $value1 && $grid_id != '') ? ' selected="true"' : '') . ' data-calculation="' . $row5['variable'] . '" onclick="checkBranching();">' . $row5['naslov'] . '</option>';
+ }
+ }
+
+ echo '</select>' . "\n";
+ echo '</td>' . "\n";
+
+ echo '</tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayMultigridSelectBox($spremenljivka);
+ ************************************************/
+ public function checkbox($spremenljivka)
+ {
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // za združljivost za nazaj dodam tudi v "staro funkcijo" opcijo prikaza brez labele :)
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ // polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ // če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ echo ' <table class="grid_table multigridcheckbox">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo ' <col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo ' <col class="space">';
+ echo '</colgroup>';
+
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ # če imamo enoto povečamo št. stoplcev
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ //ce imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30)
+ $cellsize = round(80 / $size);
+ else
+ $cellsize = 'auto';
+
+ $spacesize = round(80 / $size / 4);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $taHeight = ($spremenljivkaParams->get('taHeight') ? $spremenljivkaParams->get('taHeight') : 1);
+ //default sirina
+ if ($taWidth == -1)
+ //$taWidth = 10;
+ $taWidth = round(50 / $size);
+
+ $bg = 1;
+
+
+ // Header tabele
+ echo '<thead>';
+ $this->displayMulticheckboxHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $middle_row=false, $hideLabels);
+ echo '</thead>';
+
+
+ // Body tabele
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $srv_data_cache = array();
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+
+ # izpišemo labelo grida
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing ' . $cssAlign . '">';
+ # imamo missing polje
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, 16, ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {# ni missing vrednost
+ echo '<td class="category ' . $cssAlign . '">';
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="1" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, 16, ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+ echo '</tbody>';
+
+ echo ' </table>' . "\n";
+
+ // JS za ponvaljanje naslovne vrstice
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+ if($grid_repeat_header > 0){
+ echo '<script> gridRepeatHeader(\''.$grid_repeat_header.'\', \''.$row['id'].'\'); </script>';
+ }
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za multiple (kombinirano) tabelo, ki je sestavljena iz večih tabel
+ * Stara funkcija $this->displayMultigridMultiple($spremenljivka);
+ */
+ public function multiple($spremenljivka)
+ {
+ global $admin_type;
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+
+ $sql1 = sisplet_query("SELECT spr_id FROM srv_grid_multiple WHERE parent='$spremenljivka' ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $multiple[] = $row1['spr_id'];
+ }
+ if (count($multiple) == 0)
+ return;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ // $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+
+ // tole prej je klicalo funkcijo 2x. Ker imam še opcijo -2, bom naredil z enim klicem in več kode tu.
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT g.*, s.tip, s.enota, s.dostop, s.params FROM srv_grid g, srv_grid_multiple m, srv_spremenljivka s WHERE s.id=g.spr_id AND g.spr_id=m.spr_id AND m.spr_id IN (" . implode(',', $multiple) . ") ORDER BY m.vrstni_red, g.vrstni_red");
+ if (!$sql_grid) echo mysqli_error($GLOBALS['connect_db']);
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row_grid['spr_id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+
+ // Sirina posamezne podtabele v % (lahko jo posebej nastavimo)
+ $subtabelaParams = new enkaParameters($row_grid['params']);
+ $gridmultiple_width = (($subtabelaParams->get('gridmultiple_width') > 0) ? $subtabelaParams->get('gridmultiple_width') : 0);
+ if($gridmultiple_width > 0){
+
+ $sql_grid_size = sisplet_query("SELECT COUNT(*) as cnt_grids FROM srv_grid WHERE spr_id='".$row_grid['spr_id']."'");
+ $row_grid_size = mysqli_fetch_assoc($sql_grid_size);
+
+ if((int)$row_grid_size['cnt_grids'] > 1){
+ $row_grid['gridmultiple_width'] = floor($gridmultiple_width / $row_grid_size['cnt_grids']);
+ }
+ else{
+ $row_grid['gridmultiple_width'] = $gridmultiple_width;
+ }
+ }
+
+ if ($row_grid['tip'] == 6 && ($row_grid['enota'] == 2 || $row_grid['enota'] == 6)) {
+ $srv_grids[$row_grid['spr_id'] . '-0'] = $row_grid;
+ }
+ elseif ($row_grid['tip'] == 16 && $row_grid['enota'] == 6) {
+ $srv_grids[$row_grid['spr_id'] . '-0'] = $row_grid;
+ }
+ else {
+ $srv_grids[$row_grid['spr_id'] . '-' . $row_grid['id']] = $row_grid;
+
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+ }
+
+ $size = count($srv_grids);
+
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ }
+ else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table multigrid">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+
+ echo '<colgroup class="category">';
+ /*for ($i = 1; $i <= $size; $i++)
+ echo '<col>';*/
+ foreach ($srv_grids as $grid){
+ if($grid['gridmultiple_width'] > 0)
+ echo '<col style="width:'.$grid['gridmultiple_width'].'%;">';
+ else
+ echo '<col>';
+ }
+ echo '</colgroup>';
+
+ echo '<thead>';
+
+ // podnaslovi gridov
+ if ($row['grid_subtitle1'] == '1') {
+ echo ' <tr>';
+ if ($hideLabels == false) {
+ echo ' <td></td>';
+ //echo ' <td style="width:' . $spacesize . '%"></td>';
+ echo ' <td></td>';
+ }
+ $sql2 = sisplet_query("SELECT s.id, s.naslov, s.tip, s.dostop, s.enota, s.grids FROM srv_spremenljivka s, srv_grid_multiple m WHERE s.id = m.spr_id AND parent = '" . $row['id'] . "' ORDER BY m.vrstni_red");
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ // Datapiping
+ $row2['naslov'] = Helper::dataPiping($row2['naslov']);
+
+ if (($admin_type <= $row2['dostop'] && $admin_type >= 0) || ($admin_type == -1 && $row2['dostop'] == 4) || get('forceShowSpremenljivka')){
+ if (get('lang_id') != null) {
+ $rowl = \App\Controllers\LanguageController::srv_language_spremenljivka($row2['id']);
+ if (strip_tags($rowl['naslov']) != '') $row2['naslov'] = $rowl['naslov'];
+ }
+
+ echo ' <td colspan="' . ($row2['tip'] == 6 && ($row2['enota'] == 2 || $row2['enota'] == 6) ? '1' : $row2['grids']) . '" class="grid_header" grd="g_' . $row2['id'] . '">' . $row2['naslov'] . '</td>';
+ }
+ }
+
+ echo ' </tr>';
+ }
+
+ echo ' <tr>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ $jj = 0;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ $jj++;
+ if (($admin_type <= $srv_grid['dostop'] && $admin_type >= 0) || ($admin_type == -1 && $srv_grid['dostop'] == 4) || get('forceShowSpremenljivka')) {
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ # izpišemo labelo grida
+ if ($srv_grid['tip'] == 6 && ($srv_grid['enota'] == 2 || $srv_grid['enota'] == 6)) {
+ echo '<td></td>';
+ }
+ elseif ($srv_grid['tip'] == 16 && $srv_grid['enota'] == 6) {
+ echo '<td></td>';
+ }
+ else {
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ }
+ }
+ if ($row['enota'] > 0) echo '<td></td><td></td>'; // differencial
+ echo ' </tr>' . "\n";
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($multiple[0], get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id IN (" . implode(',', $multiple) . ") AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['spr_id']][$row_grid['vre_id']] = $row_grid;
+ }
+
+ $srv_data_checkgrid = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id IN (" . implode(',', $multiple) . ") AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_checkgrid[$row2['spr_id']][$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id IN (" . implode(',', $multiple) . ") AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['spr_id']][$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, vrstni_red, hidden, other FROM srv_vrednost WHERE spr_id='" . $multiple[0] . "' ORDER BY FIELD(vrstni_red, $orderby)");
+ $sql_if_variabla = sisplet_query("SELECT id, other FROM srv_vrednost WHERE spr_id='" . $row['id'] . "' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $row_if_variabla = mysqli_fetch_array($sql_if_variabla);
+
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row_if_variabla['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $is_missing = false;
+
+ echo ' <tr id="vrednost_if_' . $row_if_variabla['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ //echo ' <tr id="vrednost_if_'.$row1['id'].'">'."\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">';
+ echo $row1['naslov'];
+ if ($row_if_variabla['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='" . $multiple[0] . "' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' :'').'>';
+ }
+ echo '</td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+
+ $jj = 0;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+ $jj++;
+
+ if (($admin_type <= $srv_grid['dostop'] && $admin_type >= 0) || ($admin_type == -1 && $srv_grid['dostop'] == 4) || get('forceShowSpremenljivka')) {
+
+ $sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='" . $srv_grid['spr_id'] . "' AND vrstni_red = '" . $row1['vrstni_red'] . "'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $row_spr = Model::select_from_srv_spremenljivka($srv_grid['spr_id']);
+ $spr_Params = new enkaParameters($row_spr['params']);
+
+ $value = $srv_grids[$i]['id'];
+
+ // multigrid
+ if ($row_spr['tip'] == 6) {
+
+ // dropdown in selectbox
+ if (($row_spr['enota'] == 2) || ($row_spr['enota'] == 6)) {
+ $sbSize = ($spr_Params->get('sbSize') ? $spr_Params->get('sbSize') : 3);
+ $prvaVrstica = ($spr_Params->get('prvaVrstica') ? $spr_Params->get('prvaVrstica') : 1);
+ $prvaVrstica_roleta = ($spr_Params->get('prvaVrstica_roleta') ? $spr_Params->get('prvaVrstica_roleta') : 1);
+ $grid_id = $srv_data_grid[$row_spr['id']][$row2['id']]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ if ($row_spr['enota'] == 2) {//roleta
+ echo '<select id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" onchange="checkBranching();" size="1" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '">';
+ //echo '<option value=""></option>';
+ switch ($prvaVrstica_roleta) {
+ case "1":
+ echo ' <option value=""></option>' . "\n";
+ break;
+ case "2":
+
+ break;
+ case "3":
+ echo ' <option value="">' . $lang['srv_dropdown_select'] . '...</option>' . "\n";
+ break;
+ }
+ } elseif ($row_spr['enota'] == 6) {//selectbox
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+ echo '<select id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" onclick="checkBranching(); clickSelectBoxMultiCombo(' . $row_spr['id'] . ',' . $row2['id'] . ', ' . $value . ');" size="' . $sbSize . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '">';
+
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo '<option value=""></option>';
+ break;
+ case "3":
+ echo '<option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+
+ //echo '<option value=""></option>';
+ }
+
+
+ $sql_grid = sisplet_query("SELECT id, naslov, variable FROM srv_grid WHERE spr_id='$row_spr[id]' ORDER BY vrstni_red");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ echo '<option id="vrednost_' . $row_spr['id'] . '_grid_' . $row_grid['id'] . '" value="' . $row_grid['id'] . '" onclick="checkBranching();" data-calculation="' . $row_grid['variable'] . '" name="vrednost_' . $row_spr['id'] . '" ' . ($row_grid['id'] == $grid_id ? ' selected' : '') . '>' . $row_grid['naslov'] . '</option>';
+ }
+ echo '</select>';
+ echo '</td>';
+ } else {
+
+ $grid_id = $srv_data_grid[$row_spr['id']][$row2['id']]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ # ni missing vrednost
+ echo '<label for="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '"' : '') . ' id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio "' .((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ }
+
+ // multi
+ } elseif ($row_spr['tip'] == 16) {
+
+ //multi selectbox
+ if ($row_spr['enota'] == 6) {
+ $spremenljivkaParams = new enkaParameters($row_spr['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 3);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+ $grid_id = $srv_data_grid[$row_spr['id']][$row2['id']]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+
+ //echo '<select multiple="" id="multi_'.$row_spr['id'].'_'.$row2['id'].'_grid_'.$value.'" onchange="checkBranching();" size="'.$sbSize.'" name="multi_'.$row_spr['id'].'_'.$row2['id'].'">';
+ echo '<select multiple="" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" onclick="checkBranching(); clickSelectBoxMultiCombo(' . $row_spr['id'] . ',' . $row2['id'] . ', ' . $value . ');" size="' . $sbSize . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '[]">';
+
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo '<option value=""></option>';
+ break;
+ case "3":
+ echo '<option value="">' . $lang['srv_dropdown_select'] . '...</option>';
+ break;
+ }
+
+
+ //echo '<option value=""></option>';
+
+ $sql_grid = sisplet_query("SELECT id, naslov, variable FROM srv_grid WHERE spr_id='$row_spr[id]' ORDER BY vrstni_red");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ echo '<option id="vrednost_' . $row_spr['id'] . '_grid_' . $row_grid['id'] . '" value="' . $row_grid['id'] . '" onclick="checkBranching();" data-calculation="' . $row_grid['variable'] . '" name="vrednost_' . $row_spr['id'] . '" ' . ($row_grid['id'] == $grid_id ? ' selected' : '') . '>' . $row_grid['naslov'] . '</option>';
+ //echo '<option id="vrednost_'.$row_spr['id'].'_grid_'.$row_grid['id'].'" value="'.$row_grid['id'].'" onclick="checkBranching();" data-calculation="'.$row_grid['variable'].'" name="vrednost_'.$row_spr['id'].'[]" '.($row_grid['id']==$grid_id?' selected':'').'>'.$row_grid['naslov'].'</option>';
+ }
+ echo '</select>';
+ echo '</td>';
+ }//multi checkbox
+ elseif ($row_spr['enota'] != 6) {
+ $grid_id = $srv_data_checkgrid[$row_spr['id']][$row2['id']][$value]['grd_id'];
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ echo '<label for="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '">';
+ echo '<input type="checkbox" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="1" onclick="checkChecked(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio "' .((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+ }
+ // multitext
+ } elseif ($row_spr['tip'] == 19) {
+
+ $taWidth = ($spr_Params->get('taWidth') ? $spr_Params->get('taWidth') : -1);
+ $taHeight = ($spr_Params->get('taHeight') ? $spr_Params->get('taHeight') : 1);
+
+ //default sirina
+ if ($taWidth == -1) {
+ $taWidth = 80;
+ }
+ else {
+ $taWidth = $taWidth * 10; // da dobimo % (opcije se od 1 - 9)
+ }
+
+ $vsebina = $srv_data_cache[$row_spr['id']][$row2['id']][$srv_grid['id']]['text'];
+
+ // datum
+ if ($spr_Params->get('multigrid-datum') == '1') {
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' datepicker ' . $cssAlign . '">';
+ echo '<input type="text" class="width_' . $taWidth . ' height_' . $taHeight . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();" value="' . ($is_missing ? '' : $vsebina) . '" readonly="true">' . '';
+
+ $date_element = "#multi_" . $row_spr['id'] . "_" . $row2['id'] . "_grid_" . $value;
+ ?>
+ <script>
+ datepicker("<?=$date_element?>", <?=($_GET['a'] != 'preview_spremenljivka' ? 'true' : 'false')?>);
+ <?php
+ # dodamo date range
+ echo Helper::getDatepickerRange($row_spr['id'], $date_element);
+
+ echo '$( "' . $date_element . '" ).datepicker( "option", "closeText", \'' . $lang['srv_clear'] . '\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showOn", \'button\');';
+ echo '$( "' . $date_element . '" ).datepicker( "option", "showButtonPanel", true);';
+
+ // Gumb pocisti vrednost na dnu
+ echo '$("' . $date_element . '").datepicker( "option", {
+ beforeShow: function( input ) {
+ setTimeout(function() {
+ var clearButton = $(input )
+ .datepicker( "widget" )
+ .find( ".ui-datepicker-close" );
+ clearButton.unbind("click").bind("click",function(){$.datepicker._clearDate( input );});
+ }, 1 );
+ }
+ });';
+
+ ?>
+ </script>
+ <?
+
+ echo '</td>' . "\n";
+ }
+ // navaden text
+ else {
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ echo '<textarea class="width_' . $taWidth . ' height_' . $taHeight . '" rows="' . $taHeight . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();">' . ($is_missing ? '' : $vsebina) . '</textarea>';
+ echo '</td>' . "\n";
+ }
+
+ // multinumber
+ } elseif ($row_spr['tip'] == 20) {
+
+ $taWidth = ($spr_Params->get('taWidth') ? $spr_Params->get('taWidth') : -1);
+ $taHeight = ($spr_Params->get('taHeight') ? $spr_Params->get('taHeight') : 1);
+
+ //default sirina
+ if ($taWidth == -1) {
+ $taWidth = 80;
+ }
+ else {
+ $taWidth = $taWidth * 10; // da dobimo % (opcije se od 1 - 9)
+ }
+
+ $vsebina = $srv_data_cache[$row_spr['id']][$row2['id']][$srv_grid['id']]['text'];
+
+
+ echo '<td class="category ' . ($srv_grid['vrstni_red'] == 1 && $jj > 1 ? 'double' : '') . ' ' . $cssAlign . '">';
+ //echo '<textarea class="width_'.$taWidth.' height_'.$taHeight.'" rows="'.$taHeight.'" name="multi_'.$row_spr['id'].'_'.$row2['id'].'_grid_'.$value.'" id="multi_'.$row_spr['id'].'_'.$row2['id'].'_grid_'.$value.'" data-calculation="'.$srv_grid['variable'].'" '.($is_missing ? ' disabled' : '').' onkeyup="checkBranching();">'.($is_missing ? '' : $vsebina).'</textarea>';
+ echo '<input type="text" class="width_' . $taWidth . '" name="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" id="multi_' . $row_spr['id'] . '_' . $row2['id'] . '_grid_' . $value . '" value="' . ($is_missing ? '' : $vsebina) . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeypress="checkNumber(this, ' . $row_spr['cela'] . ', ' . $row_spr['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row_spr['cela'] . ', ' . $row_spr['decimalna'] . '); checkBranching();">';
+
+ echo '</td>' . "\n";
+
+ }
+ }
+ }
+ }
+ # dodamo še enoto
+ if ($row['enota'] == 1) {
+ echo ' <td></td>' . "\n";
+ echo ' <td class="differential">' . $row1['naslov2'] . '</td>' . "\n";
+ }
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+
+
+ // Izris naslovne vrstice tabele za radio tabelo
+ private function displayMultigridHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $diferencial_trak, $trak_nadnaslov, $display_trak_num_of_titles, $middle_row=false, $hideLabels=false){
+ global $lang;
+
+ // Vrstica z nadnaslovi
+ echo '<tr '.$display_trak_num_of_titles.' class="display_trak_num_of_titles_respondent_'.$row['id'].'">';
+
+ if ($hideLabels == false) {
+ echo ' <td></td>';
+ echo ' <td></td>';
+ }
+
+ for ($j = 1; $j <= $row['grids']; $j++) {
+
+ if($j == 1){
+ $nadnaslov_floating = 'left';
+ }
+ else if($j == $row['grids']){
+ $nadnaslov_floating = 'right';
+ }
+ else{
+ $nadnaslov_floating = 'none';
+ }
+
+ echo '<td class="trak_inline_nadnaslov" grd="gr_'.$j.'"><div id="trak_nadnaslov_'.$j.'_'.$spremenljivka.'" name="trak_nadnaslov_'.$j.'" class="trak_inline_nadnaslov" style="float:'.$nadnaslov_floating.'; display:inline" '.(strpos($trak_nadnaslov[$j], $lang['srv_new_text'])!==false || $this->lang_id!=null ?' default="1"':'').'>' . $trak_nadnaslov[$j] . '</div></td>';
+ }
+
+ // Ce je diferencial
+ if ($row['enota'] == 1) {
+
+ echo '<td></td><td></td>';
+
+ if($mv_count > 0 && $diferencial_trak == 1){
+ for($z=0; $z<=$mv_count; $z++){
+ echo '<td></td>';
+ }
+ }
+ }
+ echo '</tr>';
+ // Vrstica z nadnaslovi - konec
+
+
+ // Preverimo, ce ponavljamo glavo - potem ji dodamo class in jo z JS ponovimo
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+
+ // Zacetek TR
+ if (($mv_count > 0 && $diferencial_trak == 1) || $diferencial_trak != 1) {
+ echo ' <tr class="table-header '.($middle_row ? 'middle_row"' : ''). ' ' .($grid_repeat_header > 0 ? 'repeat_header' : '').'">' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>';
+ echo ' <td></td>';
+ }
+ }
+
+ if (count($srv_grids) > 0) {
+
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ # dodamo spejs pred manjkajočimi vrednostmi
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Ce ni traku izpišemo labelo grida
+ if($diferencial_trak != 1){
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ // Ce je trak
+ elseif($diferencial_trak == 1 && $mv_count > 0){
+
+ // Izpišemo ustrezno labelo grida
+ if($srv_grid['other'] == 0){ //ce je labela za kategorijo odgovora, naj bo prazno
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '"></td>' . "\n";
+ }
+ // Drugace, ce je labela za missing, izpisi labelo
+ else {
+ echo ' <td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ }
+ }
+
+ // Differencial in ni traku
+ if ($row['enota'] > 0 && $diferencial_trak != 1 && !in_array($row['enota'], [11,12]))
+ echo '<td></td><td></td>';
+
+
+ // Konec TR
+ if (($mv_count > 0 && $diferencial_trak == 1) || $diferencial_trak != 1)
+ echo ' </tr>' . "\n";
+ }
+
+ // Izris naslovne vrstice tabele za checkbox tabelo
+ private function displayMulticheckboxHeader($spremenljivka, $row, $srv_grids, $mv_count, $cssAlign, $middle_row=false, $hideLabels){
+ global $lang;
+
+ // Preverimo, ce ponavljamo glavo - potem ji dodamo class in jo z JS ponovimo
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $grid_repeat_header = ($spremenljivkaParams->get('grid_repeat_header') ? $spremenljivkaParams->get('grid_repeat_header') : 0);
+
+ // Zacetek TR
+ echo ' <tr class="table-header '.($middle_row ? 'middle_row"' : ''). ' ' .($grid_repeat_header > 0 ? 'repeat_header' : '').'">' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+
+ if (count($srv_grids) > 0) {
+
+ $first_missing_value = true;
+
+ foreach ($srv_grids AS $g_id => $srv_grid) {
+
+ # dodamo spejs pred manjkajočimi vrednostmi
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+
+
+ // Konec TR
+ echo ' </tr>' . "\n";
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/MultigridMobileController.php b/main/survey/app/Controllers/Vprasanja/MultigridMobileController.php
new file mode 100644
index 0000000..eaf7eb2
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/MultigridMobileController.php
@@ -0,0 +1,1621 @@
+<?php
+/***************************************
+ * Description: Multigrid - na mobilnikih
+ *
+ * Vprašanje je prisotno:
+ * tip 6
+ * tip 16
+ * tip 19
+ * tip 20
+ *
+ * Autor: Peter Hrvatin
+ * Created date: 9.05.2019
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+
+
+class MultigridMobileController extends Controller{
+
+ protected $spremenljivka;
+
+ public function __construct(){
+ parent::getGlobalVariables();
+ }
+
+ // Get instance
+ private static $_instance;
+
+ public static function getInstance(){
+
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new MultigridMobileController();
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za tabelo radio
+ */
+ public function radioMultigrid($spremenljivka){
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+
+ # koliko je stolpcev z manjkajočimi vrednostmi
+ $mv_count = 0;
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobietl
+ echo '<div class="grid_mobile radio '.($row['enota'] == 11 ? 'visual_scale' : '').' '.($row['enota'] == 12 ? 'smiley_scale' : '').' '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $first = true;
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '').(($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '')
+ $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ // preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ // Ugotovimo ali je na katerem gridu predhodno izbran missing oz. pridobimo text. vrednost izpolnjenega odg.
+ $is_missing = false;
+ $grid_data_value = '';
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ // Ugotovimo ali je na katerem gridu predhodno izbran missing
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+
+ // Pridobimo text. vrednost izpolnjenega odg.
+ if($srv_grids[$i]['id'] == $grid_id){
+ $grid_data_value = $srv_grids[$i]['naslov'];
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';
+
+ echo '</div>';
+
+
+ // IZPOLNJENA VREDNOST, ce obstaja in ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2){
+ echo '<div class="grid_mobile_result">'.($grid_id != '' ? $grid_data_value : '').'</div>';
+ }
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ $cnt = 0;
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids[$i]['id'];
+
+ $is_checked = (($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? true : false;
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids[$i]['id'];
+
+ $is_checked = ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? true : false;
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+
+ // Vizualna skala
+ if($row['enota'] == 11){
+ echo '<span class="category visual-radio-scale visual-radio-table '.$cssAlign.' '.($is_checked ? ' checked' : '').'"><label>';
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<span class="enka-vizualna-skala siv-'.$row['grids'].$value.'"></span>';
+
+ echo '</label></span>' . "\n";
+ }
+ // Smile-iji
+ elseif($row['enota'] == 12){
+ echo '<span class="category custom_radio_picture custom-radio-table '.$cssAlign.' '.($is_checked ? ' obarvan' : '').'"><label>';
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . '); customRadioTableSelectMobile(' . $row1['id'] . ', ' . $value. ');">';
+ echo '<span class="enka-custom-radio '.$spremenljivkaParams->get('customRadio').'"></span>';
+
+ echo '</label></span>' . "\n";
+ }
+ // Max Diff
+ elseif($row['enota'] == 5){
+ echo '<span class="category ' . $cssAlign . '">';
+
+ echo '<input data-col="'.$i.$row[0].'" type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+ }
+ else {
+ echo '<span class="category ' . $cssAlign . '">';
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="'.$value.'"' . ( $is_checked ? ' checked' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+ }
+
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti) - pri one against another tega ni
+ if($row['enota'] != 4)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+
+ // Vizualna skala - pobarvamo zvezdice
+ if($row['enota'] == 12 && $is_checked){
+ echo '<script>
+ $(document).ready( function(){ customRadioTableSelectMobile(\''.$row1['id'].'\', \''.$value.'\'); } );
+ </script>';
+ }
+ }
+
+ // Max Diff - urejanje navpicnega dela grupiranja radio button - vodoravni je urejen po defaultu s pomočjo atributa name
+ if($row['enota'] == 5){
+ echo '<script>
+ $(document).ready(
+ function(){
+ var col, elem, ime;
+ ime = "vrednost_' . $row1['id'] . '";
+
+ $("input[name=" + ime + "]").click(function() {
+ elem = $(this);
+ col = elem.data("col");
+
+ $("input[data-col=" + col + "]").prop("checked", false);
+ $("input[data-col=" + col + "]").parent().parent().removeClass("checked");
+
+ elem.prop("checked", true);
+ elem.parent().parent().addClass("checked");
+ });
+ }
+ );
+ </script>';
+ }
+
+ // One against another - beseda "ali"
+ if($row['enota'] == 4 && $cnt == 0){
+
+ echo '<div class="grid_mobile_title">';
+ echo self::$lang['srv_tip_sample_t6_4_vmes'];
+ echo '</div>';
+ }
+
+ $cnt++;
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+ // Semanticni diferencial in one against another - desna labela
+ if($row['enota'] == 1 || $row['enota'] == 4){
+
+ echo '<div class="grid_mobile_title">';
+
+ # po potrebi prevedemo naslov2 za semanticni diferencial
+ $naslov2 = Language::getInstance()->srv_language_vrednost($row1['id'], true);
+ if ($naslov2 != '') {
+ $row1['naslov2'] = $naslov2;
+ }
+
+ // Datapiping
+ $row1['naslov2'] = Helper::dataPiping($row1['naslov2']);
+
+ echo $row1['naslov2'];
+
+ echo '</div>';
+ }
+
+ // END grid_mobile_question
+ echo '</div>';
+
+ $first = false;
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+ /**
+ * @desc prikaze vnosno polje za dvojno tabelo radio
+ */
+ public function radioDoubleMultigrid($spremenljivka){
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+
+ # koliko je stolpcev z manjkajočimi vrednostmi
+ $mv_count = 0;
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='1' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ // se za desni del grida
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='2' ORDER BY vrstni_red");
+
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+ }
+
+ $indexLanguage++;
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobietl
+ echo '<div class="grid_mobile radio double '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='1' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+ // Cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja) - za part 2
+ $srv_data_grid2 = array();
+ $sql_grid = sisplet_query("SELECT d.* FROM srv_data_checkgrid" . get('db_table') . " d, srv_grid g WHERE d.spr_id='$row[id]' AND d.usr_id='" . get('usr_id') . "' AND d.loop_id $loop_id AND d.grd_id=g.id AND g.part='2' AND g.spr_id='$row[id]'");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid2[$row_grid['vre_id']] = $row_grid;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $first = true;
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '').(($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '')
+ $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ // preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ $grid_id2 = $srv_data_grid2[$row1['id']]['grd_id'];
+
+ // ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ /*if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';*/
+
+ echo '</div>';
+
+
+ // Podnaslov prve podtabele
+ if($row['grid_subtitle1'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle1'].'</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_1">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt6-3-1\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // Vmesna crta med prvim in drugim delom dvojne tabele
+ echo '<div class="grid_mobile_double_separator"></div>';
+
+
+ // Podnaslov druge podtabele
+ if($row['grid_subtitle2'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle2'].'</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_2">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids2) > 0) {
+
+ foreach ($srv_grids2 AS $j => $srv_grid) {
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<div class="grid_mobile_variable '.((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . ((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '_part_2"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '_part_2" value="' . $value . '"' . (((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids2[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt6-3-2\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables part2
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+
+ $first = false;
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za tabelo checkbox
+ */
+ public function checkboxMultigrid($spremenljivka){
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobitel
+ echo '<div class="grid_mobile checkbox '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache izpolnjenih podatkov
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_grid)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $sql1 = sisplet_query("SELECT id, naslov, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '').'>';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo '</div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';
+
+ echo '</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables">';
+
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $is_checked = ($grid_id == $value && $grid_id != '') ? true : false;
+
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing polje
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $is_checked = ($grid_id == $value && $grid_id != '' && !$is_missing) ? true : false;
+
+ echo '<label for="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="1" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"' : '').
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+ /**
+ * @desc prikaze vnosno polje za dvojno tabelo checkbox
+ */
+ public function checkboxDoubleMultigrid($spremenljivka){
+ global $lang;
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $srv_grids2 = array();
+
+ # koliko je stolpcev z manjkajočimi vrednostmi
+ $mv_count = 0;
+
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='1' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ // se za desni del grida
+ $sql_grid2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' AND part='2' ORDER BY vrstni_red");
+
+ $indexLanguage = 1;
+ while ($row_grid2 = mysqli_fetch_assoc($sql_grid2)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $indexLanguage);
+ if ($naslov != '') {
+ $row_grid2['naslov'] = $naslov;
+ }
+ $srv_grids2[$row_grid2['id']] = $row_grid2;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid2['other'] != 0) {
+ $mv_count++;
+ }
+
+ $indexLanguage++;
+ }
+
+
+ // Izrisemo celotno vsebino tabele za mobietl
+ echo '<div class="grid_mobile checkbox double '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache tabele srv_data_checkgrid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_cache = array();
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_cache)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $first = true;
+ $sql1 = sisplet_query("SELECT id, naslov, naslov2, hidden, other FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '').(($row1['hidden'] == 2) ? ' class="answer-disabled"' : '').'">';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ // po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '')
+ $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+ if (count($srv_grids2) > 0) {
+ foreach ($srv_grids2 AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+ if ($srv_grids2[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ /*if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';*/
+
+ echo '</div>';
+
+ // Podnaslov prve podtabele
+ if($row['grid_subtitle1'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle1'].'</div>';
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_1">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+
+ echo '<div class="grid_mobile_variable '.((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost 0
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids[$i]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // Vmesna crta med prvim in drugim delom dvojne tabele
+ echo '<div class="grid_mobile_double_separator"></div>';
+
+ // Podnaslov druge podtabele
+ if($row['grid_subtitle2'] != '')
+ echo '<div class="grid_mobile_double_subtitle">'.$row['grid_subtitle2'].'</div>';
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables part_2">';
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids2) > 0) {
+
+ foreach ($srv_grids2 AS $j => $srv_grid) {
+
+ $grid_id = $srv_data_cache[$row1['id']][$j]['grd_id'];
+
+ // izpišemo radio grida
+ // Other oz. missing
+ if ($srv_grid['other'] != 0) {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '').'">';
+
+ echo '<span class="missing ' . $cssAlign . '">';
+
+ # imamo missing vrednost
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) ? ' checked' : '') . ' data-calculation="0" vre_id="' . $row1['id'] . '" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // Navadna variabla
+ else {
+
+ $value = $srv_grids2[$j]['id'];
+
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.(((($grid_id == $value && $grid_id != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '').'">';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ # ni missing vrednost
+
+ //echo '<input type="checkbox" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (((($grid_id2 == $value && $grid_id2 != '') || ($presetValue == $value && $presetValue != 0)) && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids2[$i]['variable'] . '" vre_id = '.$row1['id'].' onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+ echo '<input type="checkbox" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="' . (($srv_grid['other'] != 0) ? 'grid_missing_value_' : 'vrednost_') . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grid['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, \'mmt\', ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>' . "\n";
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ // Text grida (posamezne vrednosti)
+ echo '<span class="grid_mobile_variable_title '.($srv_grid['other'] == 0 ? 'category' : 'missing').'">' . $srv_grid['naslov'] . '</span>';
+
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables part2
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+
+ $first = false;
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+
+
+ /**
+ * @desc prikaze vnosno polje za tabelo text in number
+ */
+ public function textMultigrid($spremenljivka){
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ // Nastavitev za prilagoditev mobilnih tabel (z razpiranjem ali brez)
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+
+ if ($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['num_useMin'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMax'] == 1)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ else
+ $limit = '';
+
+ //************Params za omejitev sliderjev
+ //tvorjenje omejitve********************************************************************************
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+ $limit_slider_mobile = '(min ' . $slider_MinNumLabel . ', max ' . $slider_MaxNumLabel . ')';
+ //************
+
+ // omejitev vnosa
+ if ($row['vsota_show'] == 1 && $row['ranking_k'] != '1' && $row['tip'] == 20) {
+ echo ' <label class="limit">' . $limit . '</label>';
+ }
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+
+
+ // Izrisemo celotno vsebino tabele za mobitel
+ echo '<div class="grid_mobile text '.($mobile_tables == 2 ? 'mobile_expanding' : '').'">';
+
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache textovnih odgovorov
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Cache missingov
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+
+ // Loop po posameznih vprasanjih (vrsticah)
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ echo '<div class="grid_mobile_question" id="vrednost_if_'.$row1['id'].'" '.(($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '').'>';
+
+
+ // NASLOV posameznega vprasanja
+ echo '<div class="grid_mobile_title">';
+
+ echo ' <div class="grid_mobile_title_text">';
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo $row1['naslov'];
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+ }
+
+ echo ' </div>';
+
+ // Puscica za razpiranje ce imamo vklopljene mobilne tabele z razpiranjem
+ if($mobile_tables == 2)
+ echo '<span class="faicon arrow_up mobile_expanding_arrow"></span>';
+
+ echo '</div>';
+
+
+ // VREDNOSTI znotraj vprasanja
+ echo '<div class="grid_mobile_variables">';
+
+
+ // Loop po posameznih VREDNOSTIH (stolpcih)
+ if (count($srv_grids) > 0) {
+
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ if ($srv_grid['other'] != 0)
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ else
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ if ($grid_id == $value) {
+ $vsebina = $srv_data_cache[$row1['id']][$i]['text'];
+ }
+
+
+ // Missing
+ if ($srv_grid['other'] != 0) {
+
+ $is_checked = ($grid_id == $value && $grid_id != '') ? true : false;
+
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<div class="grid_mobile_variable '.($is_checked ? ' checked' : '').'">';
+
+ # imamo missing nardimo radio
+ echo '<span class="missing ' . $cssAlign . '">';
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . ($is_checked ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</span>';
+
+ // izpišemo labelo grida
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ echo '<span class=" grid_mobile_variable_title ' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ echo '</label>';
+ }
+ // multitext
+ elseif ($row['tip'] == 19) {
+
+ echo '<div class="grid_mobile_variable">';
+
+ // izpišemo labelo grida
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ echo '<span class="grid_mobile_variable_title ' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</span>';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ echo '<textarea class="width_' . $taWidth . '" rows="' . $taHeight . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();">' . ($is_missing ? '' : $vsebina) . '</textarea>';
+ echo '</span>' . "\n";
+
+ // END grid_mobile_variable
+ echo '</div>';
+ }
+ // multinumber - rabimo JS checkNumber
+ else {
+
+ echo '<div class="grid_mobile_variable">';
+
+ // izpišemo labelo grida
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+ echo '<span class="grid_mobile_variable_title ' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</span>';
+
+ echo '<span class="category ' . $cssAlign . '">';
+ echo '<input type="text" class="width_' . $taWidth . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . ($is_missing ? '' : $vsebina) . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); checkBranching();">';
+
+ // multislider
+ //slider na PC, tablici in mobilniku
+ if ($row['ranking_k'] == 1) {
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0);
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0);
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0);
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0);
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0);
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0);
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1);
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+ //$slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ //$slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5);
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0);
+ $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : '';
+
+
+ if(get('lang_id') != null){
+ $lang_id = get('lang_id');
+ $ank_id = get('anketa');
+
+ $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$ank_id' AND spr_id='$spremenljivka' AND lang_id='$lang_id' ORDER BY label_id";
+ $sqlSlider = sisplet_query($sqlString);
+
+ while ($rowsqlSlider = mysqli_fetch_array($sqlSlider)) {
+ if($rowsqlSlider['label_id'] == 1){
+ $MinLabel = $rowsqlSlider['label'];
+ }
+ elseif($rowsqlSlider['label_id'] == 2){
+ $MaxLabel = $rowsqlSlider['label'];
+ }elseif($row['label_id'] == 0){
+ $custom = $rowsqlSlider['label'];
+ }
+ }
+
+ if($slider_DescriptiveLabel_defaults && $custom==''){ //ce so prednalozene opisne labele drsnika in nimamo se prevoda
+ $custom_ar = explode(';', $slider_DescriptiveLabel_defaults_naslov1);
+ }else{ //ce so custom opisne labele drsnika
+ $custom_ar = explode('; ', $custom);
+ }
+
+ // Ce slucajno nimamo prevedeno uporabimo original
+ $MinLabel = ($MinLabel == '') ? ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']) : $MinLabel;
+ $MaxLabel = ($MaxLabel == '') ? ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']) : $MaxLabel;
+ }
+ else{
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']);
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']);
+ }
+
+ echo '<div style="width:100%; height:150px">';
+
+ //$default_value = round(($row['vsota_limit']-$row['vsota_min']) / 2) + $row['vsota_min'];
+ $default_value = round(($slider_MaxNumLabel - $slider_MinNumLabel) / 2) + $slider_MinNumLabel;
+ $vrednost = ($vsebina == '') ? $default_value : $vsebina;
+
+ //labeli nad min in max drsnikov ############################################################
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel">';
+ } else if (get('mobile') == 1) { //ce mobilnik
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel_mobile">';
+ }
+ echo '<tbody>';
+ echo '<tr>';
+ echo '<td align="left">' . $MinLabel . '</td>';
+ echo '<td align="right">' . $MaxLabel . '</td>';
+ echo '</tr>';
+ echo '</tbody>';
+ echo '</table>';
+ //labeli nad min in max drsnikov - konec ####################################################
+
+ echo '<div class="sliderText" id="sliderText_' . $spremenljivka . '_' . $row1['id'] . '">' . $vrednost . '</div>';
+
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider"></div>';
+ }
+ else if (get('mobile') == 1) { //ce mobilnik
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider_grid_mobile"></div>';
+ }
+
+ echo '</div>';
+
+ // za custom opisne labele
+ // moznosti urejanja opisnih label drsnika
+ if($slider_VmesneDescrLabel){
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ if($custom == ''){ //ce nimamo prevoda opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ }else{ //ce mamo prevod opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1];
+ }
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ }
+ //za custom opisne labele - konec
+
+ ?>
+ <script>
+ $(function () {
+ slider_grid_init(<?=get('mobile')?>, <?=$spremenljivka?>, <?=$row1['id']?>, <?=$slider_MinNumLabel?>, <?=$slider_MaxNumLabel?>, <?=$vrednost?>, <?=$slider_handle?>, <?=$slider_handle_step?>, <?=$slider_VmesneNumLabel?>, <?=$slider_VmesneCrtice?>, <?=$slider_MinMaxNumLabelNew?>, <?=$slider_window_number?>, '<?=$slider_DescriptiveLabel_defaults_naslov1?>', <?=$slider_DescriptiveLabel_defaults?>, <?=$default_value?>, <?=$slider_nakazi_odgovore?>, <?=$slider_VmesneDescrLabel?>, '<?=$slider_CustomDescriptiveLabels?>');
+ });
+ </script>
+ <?
+ }
+
+ echo '</span>';
+
+ // END grid_mobile_variable
+ echo '</div>';
+ }
+ }
+ }
+
+ // END grid_mobile_variables
+ echo '</div>';
+
+
+ // END grid_mobile_question
+ echo '</div>';
+ }
+
+
+ // END grid_mobile
+ echo '</div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/NumberController.php b/main/survey/app/Controllers/Vprasanja/NumberController.php
new file mode 100644
index 0000000..13f312c
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/NumberController.php
@@ -0,0 +1,372 @@
+<?php
+/***************************************
+ * Description: Number
+ *
+ * Vprašanje je prisotno:
+ * tip 7
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\CheckController as Check;
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Controllers\Vprasanja\SystemVariableController as SystemVariable;
+use App\Models\Model;
+use enkaParameters;
+
+class NumberController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new NumberController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ //tvorjenje omejitve za sliderje v mobile razlicici********************************************************************************
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+
+ $limit_slider_mobile = '(min ' . $slider_MinNumLabel . ', max ' . $slider_MaxNumLabel . ')';
+ //**************************************************************************************************
+ //***************************
+
+
+ if ($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['num_useMin'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMax'] == 1)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ else
+ $limit = '';
+
+ if ($row['size'] == 2) {
+ if ($row['num_useMin2'] == 1 && $row['num_useMax2'] == 1 && $row['num_min2'] == $row['num_max2'])
+ $limit2 = '(' . $row['num_min2'] . ')';
+ elseif ($row['num_useMin2'] == 1 && $row['num_useMax2'] == 1)
+ $limit2 = '(min ' . $row['num_min2'] . ', max ' . $row['num_max2'] . ')';
+ elseif ($row['num_useMin2'] == 1)
+ $limit2 = '(min ' . $row['num_min2'] . ')';
+ elseif ($row['num_useMax2'] == 1)
+ $limit2 = '(max ' . $row['num_max2'] . ')';
+ else
+ $limit2 = '';
+ }
+
+ # preverimo ali je vrednost v bazi missing
+ $missing = Check::getInstance()->checkMissingForSpremenljivka($spremenljivka, $loop_id);
+
+ if ((int)$missing > 0) {
+ $srv_data_vrednost[$missing] = true;
+ }
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+ $sql1 = sisplet_query("SELECT text, text2 FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ //default sirina
+ if ($taWidth == -1)
+ $taWidth = 10;
+
+ //preverjanje praznega vnosa (-1)
+ $row1['text'] != -1 ? $text = $row1['text'] : $text = '';
+ $row1['text2'] != -1 ? $text2 = $row1['text2'] : $text2 = '';
+
+ $row1['text'] != -1 ? $value[1] = $row1['text'] : $value[1] = '';
+ $row1['text2'] != -1 ? $value[2] = $row1['text2'] : $value[2] = '';
+
+ $sql2 = sisplet_query("SELECT id, naslov, vrstni_red, other FROM srv_vrednost WHERE spr_id='$spremenljivka' order BY vrstni_red");
+ $array_others = array();
+
+ # zloopamo skozi vrednosti in ločeno pohandlamo veljavne in neveljavnej
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row2['id']);
+ if ($naslov == null || $naslov == '') {
+ $naslov = $row2['naslov'];
+ }
+
+ // Datapiping
+ $naslov = Helper::dataPiping($naslov);
+
+ if ((int)$row2['other'] == 0) {
+ # normalna vrednost
+
+ # po potrebi dodamo prelom
+ if ($taWidth > 40 && $row2['vrstni_red'] > 1) {
+ echo '<br>';
+ }
+
+ echo '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $row2['vrstni_red'] . '" ' . ($row['ranking_k'] == '1' && get('mobile') == 0 ? ' style="display:none;"' : '') . '>';
+
+ # če imamo enoto na levi jo izpišemo
+ if ($row['enota'] == 1) {
+ echo $naslov;
+ }
+
+ echo ' <input type="text" class="width_' . $taWidth . '" name="vrednost_' . $spremenljivka . '[]"'
+ #. ' id="vrednost_'.$spremenljivka.'_'.$row2['vrstni_red'].'" value="'.$value[$row2['vrstni_red']].'"'
+ . ' id="spremenljivka_' . $spremenljivka . '_vrednost_' . $row2['vrstni_red'] . '" value="' . (!$missing ? $value[$row2['vrstni_red']] : '') . '"'
+ . ' onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');"'
+ . ' onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); checkBranching();"'
+ . (!$missing ? '' : ' disabled') . '> ' . "\n";
+ # če imamo enoto na desni jo izpišemo
+ if ($row['enota'] == 2) {
+ echo $naslov;
+ }
+
+ echo '</label>';
+
+ } else {
+ # imamo polje drugo - ne vem, zavrnil...
+ $array_others[$row2['id']] = array(
+ 'naslov' => $naslov,
+ 'vrstni_red' => $row2['vrstni_red'],
+ 'value' => $text[$row2['vrstni_red']],
+ );
+
+ }
+
+ //omejitev vnosa
+ if ($row['vsota_show'] == 1 && ($row['ranking_k'] != '1' /*|| get('mobile') != 0*/)) {
+ if ($row2['vrstni_red'] > 1)
+ echo ' <label class="limit">' . $limit2 . '</label>';
+ else
+ echo ' <label class="limit">' . $limit . '</label>';
+ }
+ }
+
+ // slider na PC, no mobile
+ if ($row['ranking_k'] == '1') { //slider na PC, tablici in mobilniku
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0);
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0);
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0);
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0);
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0);
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0);
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1);
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+
+
+
+ if(get('lang_id') != null){
+ $lang_id = get('lang_id');
+ $ank_id = get('anketa');
+
+ $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$ank_id' AND spr_id='$spremenljivka' AND lang_id='$lang_id' ORDER BY label_id";
+ $sqlSlider = sisplet_query($sqlString);
+
+ while ($row = mysqli_fetch_array($sqlSlider)) {
+ if($row['label_id'] == 1){
+ $MinLabel = $row['label'];
+ }
+ elseif($row['label_id'] == 2){
+ $MaxLabel = $row['label'];
+ }elseif($row['label_id'] == 0){
+ $custom = $row['label'];
+ }
+ }
+
+ if($custom!=''){
+ $custom_ar = explode('; ', $custom); //polje za prevedene opisne labele drsnika
+ }
+
+ // Ce slucajno nimamo prevedeno uporabimo original
+ $MinLabel = ($MinLabel == '') ? ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']) : $MinLabel;
+ $MaxLabel = ($MaxLabel == '') ? ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']) : $MaxLabel;
+ }
+ else{
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']);
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']);
+ }
+
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5);
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0);
+ $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : '';
+
+ //za custom opisne labele
+ //moznosti urejanja opisnih label drsnika
+ if($slider_VmesneDescrLabel){
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ if($custom == ''){ //ce nimamo prevoda opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ }else{ //ce mamo prevod opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1];
+ }
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ }
+ //za custom opisne labele - konec
+
+
+ //spremenljivke za labele podrocij
+ $slider_labele_podrocij = ($spremenljivkaParams->get('slider_labele_podrocij') ? $spremenljivkaParams->get('slider_labele_podrocij') : 0); //za checkbox
+ $display_labele_podrocij = ($slider_labele_podrocij == 0) ? ' style="display:none;"' : '';
+ $slider_StevLabelPodrocij = ($spremenljivkaParams->get('slider_StevLabelPodrocij') ? $spremenljivkaParams->get('slider_StevLabelPodrocij') : 3);
+ $slider_table_td_width = 100 / $slider_StevLabelPodrocij; //spremenljivka za razporeditev sirine sliderja po podrocjih
+
+ for ($i = 1; $i <= $slider_StevLabelPodrocij; $i++) {
+ $slider_Labela_podrocja[$i] = ($spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') ? $spremenljivkaParams->get('slider_Labela_podrocja_' . $i . '') : self::$lang['srv_new_text']);
+ }
+
+
+ echo '<div style="width:95%">';
+
+
+ $default_value = round(($slider_MaxNumLabel - $slider_MinNumLabel) / 2) + $slider_MinNumLabel;
+ $vrednost = ($value[1] == '') ? $default_value : $value[1];
+
+
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_minmaxlabel">';
+ }
+ else if (get('mobile') == 1) { //ce mobilnik
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_minmaxlabel_mobile">';
+ }
+ echo '<tr>';
+ echo '<td align="left">' . $MinLabel . '</td>';
+ echo '<td align="right">' . $MaxLabel . '</td>';
+ echo '</tr>';
+ echo '</table>';
+
+
+ echo '<div class="sliderText" id="sliderText_' . $spremenljivka . '">' . $vrednost . '</div>';
+
+ // ce PC ali tablica
+ if (get('mobile') == 0 || get('mobile') == 2) {
+ echo '<div id="slider_' . $spremenljivka . '" class="slider"></div>';
+ $slider_podrocja_table_width = 85;
+ }
+ // ce mobilnik
+ else if (get('mobile') == 1) {
+ echo '<div id="slider_' . $spremenljivka . '" class="slider_mobile"></div>';
+ $slider_podrocja_table_width = 100;
+ }
+
+
+ echo '</div>';
+
+ ?>
+ <script>
+ $(function () {
+ slider_init(<?=get('mobile')?>, <?=$spremenljivka?>, <?=$slider_MinNumLabel?>, <?=$slider_MaxNumLabel?>, <?=$vrednost?>, <?=$slider_handle?>, <?=$slider_handle_step?>, <?=$slider_VmesneNumLabel?>, <?=$slider_VmesneCrtice?>, <?=$slider_MinMaxNumLabelNew?>, <?=$slider_window_number?>, '<?=$slider_DescriptiveLabel_defaults_naslov1?>', <?=$slider_DescriptiveLabel_defaults?>, <?=$default_value?>, <?=$slider_nakazi_odgovore?>, <?=$slider_VmesneDescrLabel?>, '<?=$slider_CustomDescriptiveLabels?>', '<?=$custom?>');
+ });
+ </script>
+ <?
+
+ echo '<br /><br />';
+
+ //tabela za labele podrocij in podrocja
+ echo '<table ' . $display_labele_podrocij . ' style="width:' . $slider_podrocja_table_width . '%; left: 5px;">';
+
+ //vrstica z graficnim prikazom podrocja
+ echo '<tr>';
+ for ($i = 1; $i <= $slider_StevLabelPodrocij; $i++) {
+ echo '<td width="' . $slider_table_td_width . '%" class="label_podrocje_prikaz"><div ></div></td>';
+ }
+ echo '</tr>';
+
+ //vrstica z labelami podrocji
+ echo '<tr>';
+ for ($j = 1; $j <= $slider_StevLabelPodrocij; $j++) {
+ echo '<td class="inline_labele_podrocij"><div id="slider_Labela_podrocja_' . $j . '_' . $spremenljivka . '" name="slider_Labela_podrocja_' . $j . '" class="inline_labele_podrocij" style="float:none; display:inline" ' . (strpos($slider_Labela_podrocja[$j], self::$lang['srv_new_text']) !== false || get('lang_id') != null ? ' default="1"' : '') . '>' . $slider_Labela_podrocja[$j] . '</div></td>';
+ }
+ echo '</tr>';
+ echo '</table>';
+ }
+
+ echo '</div>';
+ if (count($array_others) > 0) {
+ $missing = 1;
+ foreach ($array_others AS $oKey => $other) {
+ # missing vrednost
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $oKey;
+
+ if ($srv_data_vrednost[$oKey]) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu
+ $_checked = ($sel ? ' checked' : '');
+ // Tole ni definirano in ne more delat?? zakaj bi sploh kadarkoli bil missing disabled??
+ //$_disabled = ($is_missing && ($row1['other'] == 0 || $row1['other'] == 1) ? true : false);
+ $_disabled = false;
+
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+
+ $already_set_mv = array();
+ $sql_grid_mv = sisplet_query("SELECT naslov, other FROM srv_vrednost WHERE spr_id='" . $spremenljivka . "' AND other != 0");
+ while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) {
+ $already_set_mv[$row_grid_mv['other']] = $row_grid_mv['naslov'];
+ }
+
+ if ((($row['alert_show_99'] > 0 && isset($already_set_mv['-99']) && $already_set_mv['-99'] == $other['naslov'])
+ || ($row['alert_show_98'] > 0 && isset($already_set_mv['-98']) && $already_set_mv['-98'] == $other['naslov'])
+ || ($row['alert_show_97'] > 0 && isset($already_set_mv['-97']) && $already_set_mv['-97'] == $other['naslov']))
+ && $_checked == ''
+ )
+
+ $hide_missing = true;
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' missing" id="vrednost_if_' . $oKey . '"' . ' ' . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '">';
+ echo '<input type="checkbox" name="vrednost_mv_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $oKey . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="0" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $oKey . '\', \'' . $checkbox_limit . '\');' : '') . ' checkMissing(this);"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $other['naslov'] . '</label>';
+ echo '</div>';
+ }
+ }
+
+ SystemVariable::display($spremenljivka, $oblika);
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php b/main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php
new file mode 100644
index 0000000..de5581d
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/OneAgainstAnotherController.php
@@ -0,0 +1,291 @@
+<?php
+/***************************************
+ * Description: One against another
+ *
+ * Vprašanje je prisotno:
+ * tip 6
+ * tip 4
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+class OneAgainstAnotherController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new OneAgainstAnotherController();
+ }
+
+ /**
+ * @desc prikaze vnosno polje za one against another
+ */
+ function display($spremenljivka)
+ {
+
+ //echo "One against another!";
+
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ //$gridAlign = 1;
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ # polovimo vrednosti gridov, prevedemo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ // diferencial
+ //if ($row['enota'] == 1) {
+ $size += 2;
+ //}
+
+ # če imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30) {
+ $cellsize = round(80 / $size);
+ } else {
+ $cellsize = 'auto';
+ }
+
+ $spacesize = round(80 / $size / 4);
+
+ $bg = 1;
+
+ echo '<table class="grid_table multigrid" >' . "\n";
+
+
+ // echo '<colgroup class="question">';
+ // //echo '<col class="width_'.$gridWidth.'">';
+ // echo '<col class="width_15">';
+ // echo '</colgroup>';
+ // echo '<colgroup>';
+ // //echo '<col class="space">';
+ // echo '<col class="width_20">';
+ // echo '</colgroup>';
+ // echo '<colgroup class="category">';
+ // for ($i=1; $i<=$row['grids']; $i++)
+ // echo '<col>';
+ // echo '</colgroup>';
+ // if ($mv_count > 0) {
+ // echo '<colgroup>';
+ // echo '<col class="space">';
+ // echo '</colgroup>';
+ // echo '<colgroup class="missing">';
+ // for ($i=1; $i<=$mv_count; $i++)
+ // echo '<col>';
+ // echo '</colgroup>';
+ // }
+ // if ($row['enota'] > 0) {
+ // echo '<colgroup>';
+ // //echo '<col class="space">';
+ // echo '<col class="width_20">';
+ // echo '</colgroup>';
+ // //echo '<colgroup class="differential">';
+ // //echo '<col class="width_'.$gridWidth.'">';
+
+ // //echo '</colgroup>';
+ // }
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ # cache tabele srv_data_grid, da se ne dela vsakic posebej nov query (preberemo enkrat vse odgovore userja)
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+ # loop skozi srv_vrednost, da izpišemo vrstice z vrednostmi
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ # po potrebi prevedemo naslov
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') {
+ $row1['naslov'] = $naslov;
+ }
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0 && $srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '" ' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ echo $srv_grids[5]['id'];
+
+ //levi stolpec naslovov
+ echo ' <td class="question" style="text-align: right;">';
+ echo $row1['naslov'];
+ echo '</td>';
+
+
+ //radio buttoni
+
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+/* if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ } */
+
+ $value = $srv_grids[$i]['id'];
+
+ # izpišemo radio grida
+ if ($srv_grid['other'] != 0) {
+/* echo '<td class="missing' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' ' . $cssAlign . '">';
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+ echo '<span ' . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '></span>';
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ if ($i == 1) { //ce je to prvi radio button, dodaj ali
+ //echo '<td style="text-align: center;"> ali </td>';
+ echo '<td style="text-align: center;"> ' . self::$lang['srv_tip_sample_t6_4_vmes'] . ' </td>';
+ }
+
+ */
+ }else {
+ //echo '<td class="category ' . $cssAlign . '">';
+ echo '<td class="category style="text-align: center;">';
+ # ni missing vrednost
+ echo '<label for="vrednost_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '' && !$is_missing) ? ' checked' : '') . ($is_missing ? ' disabled' : '') . ' data-calculation="' . $srv_grids[$i]['variable'] . '" onclick="checkChecked(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>' . "\n";
+
+ if ($i == 1) { //ce je to prvi radio button, dodaj "ali"
+ echo '<td style="text-align: center;"> ' . self::$lang['srv_tip_sample_t6_4_vmes'] . ' </td>';
+ }
+ }
+
+ }
+ }
+
+ //desni stolpec naslovov
+ echo ' <td class="differential" style="text-align: left;">' . $row1['naslov2'] . '</td>' . "\n";
+
+ //missingi po desnem stolpcu
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ //echo ' <td></td>' . "\n";
+ $first_missing_value = false;
+ }
+
+ $value = $srv_grids[$i]['id'];
+
+ if ($srv_grid['other'] != 0) {
+ echo '<td class="missing' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' ' . $cssAlign . '">';
+ //echo '<td class="missing' . ((Helper::getCustomCheckbox() != 0) ? ' custom-radio custom-size-' . Helper::getCustomCheckbox() : '') . ' style="text-align: center;">';
+ # imamo missing vrednost
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $row1['id'] . '"' : '') . ' id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching(); setCheckedClass(this, null, ' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo $srv_grid['naslov'];
+ echo '</label>';
+
+ echo '</td>' . "\n";
+ }
+ }
+ }
+
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo '</table>' . "\n";
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/QuotaController.php b/main/survey/app/Controllers/Vprasanja/QuotaController.php
new file mode 100644
index 0000000..777a333
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/QuotaController.php
@@ -0,0 +1,57 @@
+<?php
+/***************************************
+ * Description: Quota
+ *
+ * Vprašanje je prisotno:
+ * tip 25
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+use App\Controllers\CheckController as Check;
+use App\Controllers\Controller;
+use App\Models\Model;
+
+
+class QuotaController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new QuotaController();
+ }
+
+ public function display($spremenljivka)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Izračunamo kvoto
+ $quota = Check::getInstance()->checkQuota(-$spremenljivka);
+
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (mysqli_num_rows($sql1) > 0) {
+ $row1 = mysqli_fetch_array($sql1);
+ $quota = $row1['text'];
+ }
+
+ echo ' <input type="text" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" value="' . $quota . '">';
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php b/main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php
new file mode 100644
index 0000000..9de8d5f
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/RadioCheckboxSelectController.php
@@ -0,0 +1,521 @@
+<?php
+/***************************************
+ * Description: Izpis sledečih tipov vprašanj: radio, checkbox in select
+ *
+ * Vprašanje je prisotno:
+ * tip 1
+ * tip 2
+ * tip 3
+ *
+ * Autor: Robert Šmalc
+ * Created date: 01.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+use SurveySetting;
+
+class RadioCheckboxSelectController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new RadioCheckboxSelectController();
+ }
+
+
+ public function display($spremenljivka, $oblika = null)
+ {
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // Pri vpogledu moramo skriti name atribut pri loopih, da se izpise prava vrednost
+ $hideName = ((get('loop_id') != null) && ($_GET['m'] == 'quick_edit')) ? true : false;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $stolpci = ($spremenljivkaParams->get('stolpci') ? $spremenljivkaParams->get('stolpci') : 1);
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ // Ce imamo slucajno vklopljeno nastavitev da so odgovori disabled
+ $disabled_vprasanje = ($spremenljivkaParams->get('disabled_vprasanje') == '1') ? true : false;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_dropdown_select = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_dropdown_select' . $_lang);
+ if ($srv_dropdown_select == '') $srv_dropdown_select = self::$lang['srv_dropdown_select'];
+
+ // DROPDOWN
+ if ($row['tip'] == 3) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $prvaVrstica_roleta = ($spremenljivkaParams->get('prvaVrstica_roleta') ? $spremenljivkaParams->get('prvaVrstica_roleta') : 1);
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+
+ if (!$row['info']) {
+ echo ' <select name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' size="' . ($row['orientation'] == '6' ? (mysqli_num_rows($sql1) + 1) . '" multiple' : '1"') . ' onchange="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.'); omejiSelectBox(' . $spremenljivka . ');">' . "\n";
+ }
+ elseif ($row['info']) {
+ echo ' <select name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' size="' . ($row['orientation'] == '6' ? (mysqli_num_rows($sql1) + 1) . '" multiple' : '1"') . ' onchange="drugo_' . $spremenljivka . '(); checkBranching(); ">' . "\n";
+ }
+
+ switch ($prvaVrstica_roleta) {
+
+ case "1":
+ echo ' <option value=""></option>' . "\n";
+ break;
+
+ case "2":
+ break;
+
+ case "3":
+ echo ' <option value="">' . $srv_dropdown_select . '...</option>' . "\n";
+ break;
+ }
+ }
+
+ // CHECKBOX
+ if ($row['tip'] == 2) {
+
+ if ($row['orientation'] != 6) {
+ $selected = Model::getOtherValue($spremenljivka);
+ echo '<input name="other_selected_vrednost_' . $spremenljivka . '" id="other_selected_vrednost_' . $spremenljivka . '" value="' . $selected . '" type="hidden">';
+ }
+ // Izberite s seznama
+ elseif ($row['orientation'] == 6) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+
+ if ($sbSize == 2) { //potrebno dodati predefinirano visino min 36px, ce sta samo dve moznosti v selectu, ker v FF, ni videti scrollbar-a
+ echo ' <select multiple style="height: 36px;" name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.'); ">' . "\n";
+ }
+ else {
+ echo ' <select multiple name="vrednost_' . $spremenljivka . '[]" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.'); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . '">' . "\n";
+ }
+
+ switch ($prvaVrstica) {
+ case "1":
+
+ break;
+ case "2":
+ echo ' <option value=""></option>' . "\n";
+ break;
+ case "3":
+ echo ' <option value="">' . $srv_dropdown_select . '...</option>' . "\n";
+ break;
+ }
+ }
+ }
+
+ // RADIO
+ if ($row['tip'] == 1) {
+
+ if ($row['orientation'] == 6) {
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $sbSize = ($spremenljivkaParams->get('sbSize') ? $spremenljivkaParams->get('sbSize') : 1);
+ $prvaVrstica = ($spremenljivkaParams->get('prvaVrstica') ? $spremenljivkaParams->get('prvaVrstica') : 1);
+
+ if ($prvaVrstica != 1) {
+ $sbSize = $sbSize + 1;
+ }
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+
+ if ($sbSize == 2) { //potrebno dodati predefinirano visino min 36px, ce sta samo dve moznosti v selectu, ker v FF, ni videti scrollbar-a
+ echo ' <select style="height: 36px;" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ', '.$checkbox_limit.');">' . "\n";
+ }
+ else {
+ echo ' <select name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" size="' . $sbSize . '" onclick="drugo_' . $spremenljivka . '(); checkBranching(); clickSelectBox(' . $spremenljivka . ','.$checkbox_limit.');">' . "\n";
+ }
+
+ switch ($prvaVrstica) {
+ case "1":
+ break;
+ case "2":
+ echo ' <option value=""></option>' . "\n";
+ break;
+ case "3":
+ echo ' <option value="">' . $srv_dropdown_select . '...</option>' . "\n";
+ break;
+ }
+ }
+ }
+
+ // cache, da vse preberemo naenkrat
+ $srv_data_vrednost = array();
+ $sql2_c = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row2_c = mysqli_fetch_array($sql2_c)) {
+ $srv_data_vrednost[$row2_c['vre_id']] = true;
+ }
+ # preverimo ali imamo izbran kak missing
+ $is_missing = false;
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ if ($row1['other'] == 0 || $row1['other'] == 1) {
+ } else {
+ if ($srv_data_vrednost[$row1['id']]) {
+ $is_missing = true;
+ }
+ }
+ }
+ if (mysqli_num_rows($sql1))
+ mysqli_data_seek($sql1, 0);
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $stolpci = ($spremenljivkaParams->get('stolpci') ? $spremenljivkaParams->get('stolpci') : 1);
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+ $checkbox_min_limit = ($spremenljivkaParams->get('checkbox_min_limit') ? $spremenljivkaParams->get('checkbox_min_limit') : 0);
+
+ // Ali skrivamo radio gumbe in checkboxe
+ $hideRadio = ($spremenljivkaParams->get('hideRadio') == 1) ? ' hideRadio' : '';
+
+ // Ali imamo prednastavljen radio ali checkbox (ce se nimamo odgovora)
+ $presetValue = ($spremenljivkaParams->get('presetValue') > 0 && empty($srv_data_vrednost)) ? $spremenljivkaParams->get('presetValue') : 0;
+
+ if ($stolpci > 1 && $row['orientation'] == 1 && get('mobile') != 1) {
+ echo '<div class="floatLeft width_' . round(100 / $stolpci, 0) . '">';
+ $kategorij = mysqli_num_rows($sql1);
+ $v_stolpcu = ceil($kategorij / $stolpci);
+ }
+
+ $i = 0;
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ if ($row1['other'] == 0 || $row1['other'] == 1) {
+ # normalna vrednost
+ $_id = 'spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'];
+ $missing = 0;
+ } else {
+ # missing vrednost
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'];
+ $missing = 1;
+ }
+
+ if (isset($srv_data_vrednost[$row1['id']])) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu (pri radio buttonih ne rabimo disablat polj)
+ $_checked = (($sel && !$is_missing) || ($sel && ($row1['other'] !== 0 && $row1['other'] != 1)) ? ' checked' : '');
+ $_disabled = ($is_missing && ($row1['other'] == 0 || $row1['other'] == 1) && $row['tip'] != 1 ? true : false);
+
+ // posebej za radio button opcijo da ne prikaže vprašanja in izpolni prvi odgovor
+ if ($row['tip'] == 1 && $row['hidden_default'] == 1 && $i == 0)
+ $_checked = ' checked';
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+ if ((($row['alert_show_99'] > 0 && $row1['variable'] == '-99')
+ || ($row['alert_show_98'] > 0 && $row1['variable'] == '-98')
+ || ($row['alert_show_97'] > 0 && $row1['variable'] == '-97'))
+ && $missing == 1 && $_checked == ''
+ )
+ $hide_missing = true;
+
+ //v kolikor je bil odgovor skrit, ga uporabniku ne prikažemo
+ if ($row1['hidden'] == 1)
+ $hide_missing = true;
+
+ // Ce imamo slucajno prednastavljeno vrednost
+ if ($presetValue > 0 && $presetValue == $row1['id'])
+ $_checked = ' checked';
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ // RADIO
+ if ($row['tip'] == 1) {
+
+ // Radio - izberite s seznama
+ if ($row['orientation'] == 6) {
+ echo '<option value="' . $row1['id'] . '"' . ($sel ? ' selected' : '') . ' id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" ' . (($row1['hidden'] == 1) ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>' . $row1['naslov'] . '</option>' . "\n";
+
+ }
+ // Radio - navpicno - text levo
+ elseif ($row['orientation'] == 7) {
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<table class="width_30">';
+
+ echo '<tr>';
+ echo '<td><label for="' . $_id . '">' . $row1['naslov'] . ' </label>';
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" id="spremenljivka_'.$spremenljivka.'_textfield_'.$row1['id'].'" value="'.$row3['text'].'" '.($_disabled ? ' disabled' : '').' onclick="$(\'#spremenljivka_'.$spremenljivka.'_vrednost_'.$row1['id'].'\').attr(\'checked\',true); checkBranching();">';
+ }
+ echo '</td>';
+
+ echo '<td align="right">';
+ echo '<label>';
+ echo '<input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\', \'' . $_id . '\');">';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '') .
+ '></span>';
+
+ echo '</label></td>';
+ echo '</tr>';
+ echo '</table>';
+ }
+ // Radio - custom checkobox??
+ elseif ($row['orientation'] == 9) {
+ echo '<div class="variabla custom_radio_picture ' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '"><input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\'); customRadioSelect(' . $row1['id'] . ', ' . $row1['variable'] . ');"> ';
+
+ echo '<span class="enka-custom-radio ' .
+ ($spremenljivkaParams->get('customRadio') ? $spremenljivkaParams->get('customRadio') : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() .'px;"': '').
+ '></span>';
+
+ echo '<div class="custom_radio_answer">(' . $row1['naslov'] . ')</div>';
+ echo '</label>';
+
+ //Pri smeških moramo pognati JS, da doda ustrezen razred 'obarvan'
+ if($_checked == ' checked'){
+ echo '<script>
+ $(document).ready( function(){ customRadioSelect(\'' . $row1['id'] . '\', \'' . $row1['variable'] . '\'); } );
+ </script>';
+ }
+ }
+ // Vizualna analogna skala
+ elseif ($row['orientation'] == 11) {
+ $stOdgovorov = mysqli_num_rows($sql1);
+
+ echo '<div class="variabla custom_radio visual-radio-scale ' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '"><input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\');"> ';
+ echo '<span class="enka-vizualna-skala siv-'.$stOdgovorov.$row1['naslov'].' '.((Helper::getCustomCheckbox() != 0) ? 'size-' . Helper::getCustomCheckbox(): '').'"></span>';
+ echo '<div class="custom_radio_answer '.((Helper::getCustomCheckbox() != 0) ? 'size-' . Helper::getCustomCheckbox(): '').'">(' . $row1['naslov'] . ')</div>';
+ echo '</label>';
+ }
+ // Radio - standard
+ else {
+ echo '<div class="variabla' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '"><input type="radio" ' . (!$hideName ? ' name="vrednost_' . $spremenljivka . '"' : '') . ' id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled || $disabled_vprasanje ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" onclick="checkChecked(this); checkBranching(); ' . ($row['onchange_submit'] == 1 ? ' submitForm();' : '') . ' setCheckedClass(this, \'1\');"> ';
+
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '') .
+ '></span>';
+ echo '' . $row1['naslov'] . '</label>';
+
+ // Ce je vprasanje disabled moramo vseeno postati vrednost
+ if($disabled_vprasanje){
+ echo '<input type="hidden" name="vrednost_'. $spremenljivka.'" value="'.key($srv_data_vrednost).'">';
+ }
+ }
+ }
+ // CHECKBOX
+ elseif ($row['tip'] == 2 || $row['tip'] == 27) {
+
+ // Checkbox - standard
+ if ($row['orientation'] != 6 && $row['orientation'] != 7) {
+ echo '<div class="variabla' . (($row1['hidden'] == 2) ? ' answer-disabled ' : '') . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . '>';
+
+ if($row['tip'] == 2){
+ echo '<label for="' . $_id . '"><input type="checkbox" name="vrednost_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : '1') . '" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . ' ' . ($missing == 1 ? ' checkMissing(this);' : '') . ' setCheckedClass(this, \'2\');"> ';
+ }
+ elseif($row['tip'] == 27){ //ce je heatmap, kjer je v uporabi checkbox za belezenje klikov na obmocja, je potrebno spremeniti "name"
+ echo '<label for="' . $_id . '"><input type="checkbox" name="vrednostHeatmap_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : '1') . '" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . ' ' . ($missing == 1 ? ' checkMissing(this);' : '') . ' setCheckedClass(this, \'2\');"> ';
+ }
+
+
+ // Font awesom checkbox custom
+ echo '<span class="enka-checkbox-radio' . (($row1['hidden'] == 2) ? ' answer-disabled' : '') . '" ' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '' . $row1['naslov'] . '</label>';
+ //v kolikor je odgovor skrit(1) ali disable(2), mu damo vrednost -2
+ if ($row1['hidden'] == 1 || $row1['hidden'] == 2)
+ echo '<input id="branch_' . $_id . '" name="cond_vrednost_' . $spremenljivka . '[]" value="' . $row1['id'] . '" type="hidden">';
+
+ }
+ // Checkbox - izberite s seznama
+ elseif ($row['orientation'] == 6) {
+ echo '<option value="' . $row1['id'] . '"' . ($sel ? ' selected' : '') . ' id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" ' . ($hide_missing ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>' . $row1['naslov'] . '</option>' . "\n";
+ }
+ // Checkbox - navpicno - text levo
+ elseif ($row['orientation'] == 7) {
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' ' . ($missing == 1 ? 'missing' : '') . ' ' . $_checked . ' ' . $hideRadio . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ($hide_missing ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>';
+ echo '<table class="width_30">';
+ //echo '<table style="width:30%">';
+ echo '<tr>';
+ //echo '<td><label for="'.$_id.'">'.$row1['naslov'].' </label></td>';
+ echo '<td><label for="' . $_id . '">' . $row1['naslov'] . ' </label>';
+
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();">' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching();" />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" id="spremenljivka_'.$spremenljivka.'_textfield_'.$row1['id'].'" value="'.$row3['text'].'" '.($_disabled ? ' disabled' : '').' onclick="$(\'#spremenljivka_'.$spremenljivka.'_vrednost_'.$row1['id'].'\').attr(\'checked\',true); checkBranching();">';
+ }
+ echo '</td>';
+ echo '<td align="right">';
+ echo '<label>';
+ echo '<input type="checkbox" name="vrednost_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $row1['id'] . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="' . ($missing == 1 ? '0' : '1') . '" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '') . ' ' . ($missing == 1 ? ' checkMissing(this);' : '') . ' setCheckedClass(this, \'2\',' . $row1['id'] . ');">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+
+ echo '</label>';
+ echo '</td>';
+ echo '</tr>';
+ echo '</table>';
+ }
+
+ }
+ // DROPDOWN
+ elseif ($row['tip'] == 3) {
+ # imamo dropdown
+ echo '<option value="' . $row1['id'] . '"' . ($sel ? ' selected' : '') . ' id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . ' data-calculation="' . ($missing == 1 ? '0' : $row1['variable']) . '" ' . ($hide_missing ? ' style="display:none"' : '') . (($row1['hidden'] == 2) ? ' disabled' : '') . '>' . $row1['naslov'] . '</option>' . "\n";
+ }
+
+
+ if ($row['tip'] != 3 && $row['orientation'] != 6) {//ce ni vprasanje tipa 3 (roleta) in ni orientacija 6 (select box)
+ //if ($row['tip'] != 3 && $row['orientation']!=6) {
+ if ($row['orientation'] != 7) { //ce ni orientacija 7 (postavitev: navpicno - tekst levo)
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching(); '.($checkbox_limit > 0 ? 'checkboxLimitTextbox(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '').'" >' . $row3['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" value="' . $row3['text'] . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="$(\'#spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '\').attr(\'checked\',true); checkBranching(); '.($checkbox_limit > 0 ? 'checkboxLimitTextbox(\'' . $spremenljivka . '\', \'' . $row1['id'] . '\', \'' . $checkbox_limit . '\');' : '').'" />';
+ }
+ }
+ echo '</div>' . "\n";
+ }
+
+ $i++;
+ if ($stolpci > 1 && $row['orientation'] == 1 && get('mobile') != 1) {
+ if ($i >= $v_stolpcu) {
+ echo '</div><div class="floatLeft width_' . round(100 / $stolpci, 0) . '">';
+ $i = 0;
+ }
+ }
+ }
+
+ if ($stolpci > 1 && $row['orientation'] == 1 && get('mobile') != 1)
+ echo '</div>';
+
+ // koncamo select
+ if ($row['tip'] == 3 || $row['orientation'] == 6) {
+ echo ' </select>' . "\n";
+
+ if ($row['tip'] == 2 && $row['orientation'] == 6) {
+ if (mysqli_num_rows($sql1) > 0) mysqli_data_seek($sql1, 0);
+ while ($row1 = mysqli_fetch_assoc($sql1)) {
+ if ($row1['hidden'] == 1 || $row1['hidden'] == 2)
+ echo '<input id="branch_' . $_id . '" name="cond_vrednost_' . $spremenljivka . '[]" value="' . $row1['id'] . '" type="hidden">';
+ }
+ }
+ // Ce je vprasanje disabled moramo vseeno postati vrednost
+ elseif($disabled_vprasanje){
+ echo '<input type="hidden" name="vrednost_'. $spremenljivka.'" value="'.key($srv_data_vrednost).'">';
+ }
+
+ if (mysqli_num_rows($sql1) > 0) mysqli_data_seek($sql1, 0);
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo '<br /><textarea name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" class="drugo_' . $spremenljivka . '" rows="' . $otherHeight . '" style="display:none; ' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="checkBranching();">' . $row3['text'] . '</textarea>';
+ else
+ echo '<br /><input type="text" name="textfield_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_textfield_' . $row1['id'] . '" class="drugo_' . $spremenljivka . '" value="' . $row3['text'] . '" style="display:none; ' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($_disabled ? ' disabled' : '') . ' onclick="checkBranching();" />';
+ }
+ }
+
+ ?>
+ <script>
+ function drugo_<?=$spremenljivka?> () {
+ $('.drugo_<?=$spremenljivka?>').hide();
+ $('#spremenljivka_<?=$spremenljivka?>_textfield_' + $('#vrednost_<?=$spremenljivka?>').val()).show();
+ }
+
+ </script><?
+
+ echo '</div>';
+
+ // vedno prikazujemo novo roleto
+ // text rolete ni pri multiple selectu in pri mobilni (pri tablici jo pustimo)
+ if (
+ $row['orientation'] != 6 && get('mobile') != 1 && get('forceShowSpremenljivka') !== true
+ ) {
+ ?>
+ <script>
+ $('select#vrednost_<?=$spremenljivka?>').chosen({search_contains: true});
+ </script>
+ <?
+ }
+ }
+
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/RankingController.php b/main/survey/app/Controllers/Vprasanja/RankingController.php
new file mode 100644
index 0000000..014bb37
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/RankingController.php
@@ -0,0 +1,1021 @@
+<?php
+/***************************************
+ * Description: Ranking
+ *
+ * Vprašanje je prisotno:
+ * tip 17
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+
+// Iz admin/survey
+use enkaParameters;
+use SurveySetting;
+use Common;
+use SurveyInfo;
+
+class RankingController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new RankingController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ // Pri WebSM anketi nimamo userja, zato ne izvajamo ajaxa
+ $ajax = 'true';
+ $usr_id = get('usr_id');
+ if (get('anketa') == get('webSMSurvey') && Common::checkModule('websmsurvey') == '1') {
+ $ajax = 'false';
+ $usr_id = 0;
+ }
+
+ //********* potrebno za pravilno prikazovanje predogleda in vpogled v posamezen podatek
+ $quick_view = json_encode(get('quick_view'));
+
+ if(isset($_GET['a'])){
+ if($_GET['a'] == 'preview_spremenljivka'){
+ $preview_spremenljivka = 1;
+ echo '
+ <script>
+ var usr_id = 0;
+ </script>
+ ';
+ }
+ else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ }
+ else{
+ $preview_spremenljivka = 0;
+ echo '
+ <script>
+ var usr_id = '.$usr_id.';
+ </script>
+ ';
+ }
+ //********* potrebno za pravilno prikazovanje predogleda in vpogled v posamezen podatek - konec
+
+
+ // premikanje - n==k
+ if ($row['design'] == 2 && get('mobile') == 0)
+ $this->displayPremikanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax);
+
+ // prestavljanje za SAZU - n>k
+ else if ($row['design'] == 0 && get('mobile') == 0
+ && SurveyInfo::getInstance()->checkSurveyModule('sazu')
+ && in_array($spremenljivka, array('11092569','11092563'))
+ )
+ $this->displayPrestavljanjeSAZU($spremenljivka, $preview_spremenljivka, $quick_view, $ajax);
+
+ // prestavljanje - n>k
+ else if ($row['design'] == 0 && get('mobile') == 0)
+ $this->displayPrestavljanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax);
+
+ // ostevilcevanje - mobile
+ else if ($row['design'] == 1 || $row['design'] == 3 || get('mobile') > 0)
+ $this->displayOstevilcevanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax, $oblika);
+ }
+
+
+ // Izrisemo podtip premikanje (n == k)
+ private function displayPremikanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ # če smo v quick_view mode ne omogočamo
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ //javascript za sortable (drag in drop)
+ echo "<script>
+ $(document).ready(
+ function(){
+ $('#sortzone_$spremenljivka').sortable({
+
+ items: '.handle, .handle_long',
+
+ opacity: '0.7',
+ //stop: function () {
+ stop: function (event, ui) {
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ frame_height_ranking_premikanje_dyn (ui, $spremenljivka);
+ if(" . $ajax . "){
+
+ var sortable_filtered_items = $('#sortzone_$spremenljivka').sortable({
+ items: 'div:visible'
+ });
+
+ $.post('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {
+ /*order: $('#sortzone_$spremenljivka:visible').sortable('serialize'), */
+ order: sortable_filtered_items.sortable('serialize'),
+ spremenljivka: $spremenljivka,
+ usr_id: usr_id,
+ anketa: srv_meta_anketa_id
+ });
+ }
+ },
+ over: function( event, ui ) {
+ //frame_height_ranking_premikanje_dyn (ui, $spremenljivka);
+ }
+ });
+ //checkBranching(); // dokler ne premakne elementa je -1, zato naj bo tudi v JS tako
+ // checkBranching() sprozimo samo, ce je spremenljivka skrita, ker je vkljucena v enem od pogojev na prejsnji strani
+ if ( $('div#spremenljivke_hidden div#spremenljivka_{$spremenljivka}').length > 0){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ }
+ );
+ </script>";
+ }
+
+
+ //ce je bil vrstni red popravljen ze prej (so ze vnosi v bazi)
+ $sql1 = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red");
+
+ $vre_idCache1 = array();
+ $otherCache1 = array();
+ $vre_idCache2 = array();
+ $otherCache2 = array();
+ $vre_idCacheN = array();
+ $vrstni_redCacheN = array();
+
+ if (($num = mysqli_num_rows($sql1)) != 0) {
+ //izracun visine
+ $size = $num * 50;
+
+ echo '<div class="sortholder">';
+
+ echo '<div id="sortzone_' . $spremenljivka . '" class="sortzone">';
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $sql2 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE id='$row1[vre_id]' ");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row2['id']);
+ if ($naslov != '') $row2['naslov'] = $naslov;
+
+ // Datapiping
+ $row2['naslov'] = Helper::dataPiping($row2['naslov']);
+
+ $value = $row2['naslov'];
+ $vre_id = $row2['id'];
+ array_push($vre_idCache1, $vre_id);
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'handle moving';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row2['other']; //drugo, po navadi missing
+ array_push($otherCache1, $other);
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+
+ }
+ echo '</div>';
+
+ //$sqlN = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0");
+ $sqlN = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red");
+ //izris stevilk pred vrednostmi
+ echo '<ul class="sorting">';
+ $stevec = 0;
+ //for ($i = 0; $i < mysqli_num_rows($sqlN); $i++) {
+ while ($rowN = mysqli_fetch_array($sqlN)) {
+ $spr_id = $rowN["spr_id"];
+ $vre_id = $rowN["vre_id"];
+ array_push($vre_idCacheN, $vre_id);
+ $vrstni_red = $rowN["vrstni_red"];
+ array_push($vrstni_redCacheN, $vrstni_red);
+ //$stevec = $i + 1;
+ //$stevec = $stevec + 1;
+ echo '<li id="frame_spremenljivka_'.$spremenljivka.'_vrednost_'.$vre_id.'" class="frame_spremenljivka_'.$spremenljivka.'">
+ <div class="frame_moving" data="'.$vrstni_red.'">' . $vrstni_red . '.</div>
+ </li>' . "\n";
+ }
+ echo '</ul>';
+
+ echo '</div>';
+
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCache1 = 0;
+ foreach($vre_idCache1 as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCache1[$indeksVre_idCache1]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCache1++;
+ }
+ $indeksvre_idCacheN = 0;
+ foreach($vre_idCacheN as $vre_id){
+ //**************
+ ?>
+ <script>
+ $(document).ready(function () {
+ frame_height_ranking_premikanje(<?=$spremenljivka?>, <?=$vre_id?>, <?=$vrstni_redCacheN[$indeksvre_idCacheN]?>);
+ });
+ </script>
+ <?
+ //********
+ $indeksvre_idCacheN++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+
+ } //ce gre za prvo popravljanje vrstnega reda (se ni vnosov v srv_data_rating)
+ else {
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql2 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ //izracun visine
+ $num = mysqli_num_rows($sql2);
+ $size = $num * 50;
+
+ echo '<div class="sortholder">';
+
+ echo '<div id="sortzone_' . $spremenljivka . '" class="sortzone">';
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row2['id']);
+ if ($naslov != '') $row2['naslov'] = $naslov;
+
+ // Datapiping
+ $row2['naslov'] = Helper::dataPiping($row2['naslov']);
+
+ $value = $row2['naslov'];
+ $vre_id = $row2['id'];
+ array_push($vre_idCache2, $vre_id);
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'handle moving';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row2['other']; //drugo, po navadi missing
+ array_push($otherCache2, $other);
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+
+ }
+ echo '</div>';
+
+ $sqlN = sisplet_query("SELECT id, spr_id, vrstni_red FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0");
+ //izris stevilk pred vrednostmi
+ $stevec = 0;
+ echo '<ul class="sorting">';
+ //for ($i = 0; $i < mysqli_num_rows($sqlN); $i++) {
+ while ($rowN = mysqli_fetch_array($sqlN)) {
+ $spr_id = $rowN["spr_id"];
+ $vre_id = $rowN["id"];
+ $vrstni_red = $rowN["vrstni_red"];
+ array_push($vre_idCacheN, $vre_id);
+ array_push($vrstni_redCacheN, $vrstni_red);
+ //$stevec = $i + 1;
+ $stevec = $stevec + 1;
+ echo '<li id="frame_spremenljivka_'.$spremenljivka.'_vrednost_'.$vre_id.'" class="frame_spremenljivka_'.$spremenljivka.'">
+ <div class="frame_moving" data="'.$stevec.'">' . $stevec . '.</div>
+ </li>' . "\n";
+ }
+ echo '</ul>';
+
+ echo '</div>';
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCache2 = 0;
+ foreach($vre_idCache2 as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCache2[$indeksVre_idCache2]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCache2++;
+ }
+ $indeksvre_idCacheN = 0;
+ foreach($vre_idCacheN as $vre_id){
+ //**************
+ ?>
+ <script>
+ $(document).ready(function () {
+ frame_height_ranking_premikanje(<?=$spremenljivka?>, <?=$vre_id?>, <?=$vrstni_redCacheN[$indeksvre_idCacheN]?>);
+ });
+ </script>
+ <?
+ //********
+ $indeksvre_idCacheN++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+ }
+ }
+
+ // Izrisemo podtip prestavljanje (n >= k)
+ private function displayPrestavljanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ //izracun visine
+ $num = mysqli_num_rows($sql1);
+ $size = $num * 37;
+
+ //nastavimo $max (maximum prenesenih vrednosti) -> ce lahko nosimo vse vrednosti ($row['ranking_k'] == 0) je $max stevilo vseh vrednotsti
+ if ($row['ranking_k'] == 0)
+ $max = mysqli_num_rows($sql1);
+ else
+ $max = $row['ranking_k'];
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ save('lang_id', (get('lang_id') == null) ? self::$lang['id'] : get('lang_id'));
+
+ //nismo presegli limita ranking_k
+ if ($count < $max) {
+ # če smo v quick_view mode ne omogočamo
+ //if (get('quick_view') == false) {
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ //javascript za drag in drop
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half2_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka, #half2_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ //stop: function (){
+ stop: function (event, ui){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ if(" . $ajax . "){
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ frame_height_ranking (ui, $spremenljivka);
+ },
+ over: function( event, ui ) {
+ frame_height_ranking (ui, $spremenljivka);
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ } //preneseno je bilo max stevilo vrednosti
+ else {
+ # če smo v quick_view mode ne omogočamo
+ //if (get('quick_view') == false) {
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ stop: function (){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ }
+
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ echo '<table class="ranking_table">';
+ echo '<tr>';
+ //zaslon razdelimo na dva dela - izris leve strani
+ echo '<td>';
+
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_ranking_avaliable_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_avaliable_categories' . $_lang);
+ if ($srv_ranking_avaliable_categories == '') $srv_ranking_avaliable_categories = self::$lang['srv_ranking_avaliable_categories'];
+
+ echo '<b>' . $srv_ranking_avaliable_categories . ':</b>';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone" style="height:' . $size . 'px">';
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ $vre_idCacheL = array();
+ $otherCacheL = array();
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+ array_push($vre_idCacheL, $vre_id);
+ $other = $row1['other']; //drugo, po navadi missing
+ array_push($otherCacheL, $other);
+
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+ $c = '';
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ }
+
+ echo '</div>';
+ echo '</td>';
+
+
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCacheL = 0;
+ foreach($vre_idCacheL as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCacheL[$indeksVre_idCacheL]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCacheL++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+
+ //srednja celica (stevilo prenesenih in spodaj puscica)
+ echo '<td class="middle">';
+ echo '<b>' . $count . '/' . $max . '</b>';
+ echo '<img src="' . self::$site_url . 'main/survey/skins/Modern/arrow.png" alt="arrow">';
+ echo '</td>';
+
+ //izris desne strani
+ echo '<td>';
+
+
+ $srv_ranking_ranked_categories = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_ranking_ranked_categories' . $_lang);
+ if ($srv_ranking_ranked_categories == '') $srv_ranking_ranked_categories = self::$lang['srv_ranking_ranked_categories'];
+
+ echo '<b>' . $srv_ranking_ranked_categories . ':</b>';
+
+ echo '<div class="dropholder">'; // ker na td ne primer position relative za nastavit position absolute na dropzone
+
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ $vre_idCacheD = array();
+ $otherCacheD = array();
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+ array_push($vre_idCacheD, $vre_id);
+ $length = strlen($value); //dolzina teksta kategorije odgovora
+ $style = '';
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ } else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+
+ $c = '';
+ $other = $row1['other']; //drugo, po navadi missing
+ array_push($otherCacheD, $other);
+
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . ' ' . $c . '">' . $value . '</div>' . "\n"; //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ }
+ echo '</div>';
+
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.)
+ $indeksVre_idCacheD = 0;
+ foreach($vre_idCacheD as $vre_id){
+ ?>
+ <script>
+ $(document).ready(function () {
+ customizeImageView4Respondent(<?=$row['tip']?>, <?=$spremenljivka?>, <?=$vre_id?>, <?=$ajax?>, srv_meta_anketa_id, '<?=self::$site_url?>', usr_id, <?=$otherCacheD[$indeksVre_idCacheD]?>, <?=get('mobile')?>, <?=$quick_view?>, <?=$preview_spremenljivka?>); //poklici funkcijo za ureditev draggable in droppable
+ });
+ </script>
+ <?
+ $indeksVre_idCacheD++;
+ }
+ //ureditev gladkega delovanja prikazovanja visjih blokov odgovorov (vecvrsticni, s slikami, ipd.) - konec
+
+
+ ?>
+ <script>
+ $(document).ready(function () {
+ question_height_ranking(<?=$spremenljivka?>);
+ });
+ </script>
+ <?
+
+
+ //izris osencenih polj (ranking_k)
+
+ echo '<ul>';
+ for ($i = 0; $i < $max; $i++) {
+ $stevec = $i + 1;
+ echo '<li>
+ <div class="frame_ranking" onHover="">' . $stevec . '.</div>
+ </li>' . "\n";
+ }
+ echo '</ul>';
+
+
+ echo '</div>'; //dropholder
+
+ echo '</td>';
+
+
+ echo '</tr>';
+ echo '</table>';
+ echo '</div>';
+
+ $sql2_Refresh = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' ");
+ while ($row2_Refresh = mysqli_fetch_array($sql2_Refresh)) {
+ $spr_id = $row2_Refresh["spr_id"];
+ $vre_id = $row2_Refresh["vre_id"];
+ $vrstni_red = $row2_Refresh["vrstni_red"];
+ if (!empty($row2_Refresh)) { //ce je ze kaj v bazi
+ ?>
+ <script>
+ $(document).ready(function () {
+ var trenutna_visina_prenesenega = $('#spremenljivka_<?=$spr_id?>_vrednost_<?=$vre_id?>').height()
+ //console.log(trenutna_visina_prenesenega);
+ var i = 0;
+ $('#half2_<?=$spr_id?>').siblings().children('li').children('div').each(function(){ //preleti prazne okvirje
+ i = i + 1;
+ if(<?=$vrstni_red?> == i){
+ $(this).height(trenutna_visina_prenesenega);
+ //console.log(i);
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ });
+ </script>
+ <?
+ }
+ }
+ }
+
+ // Izrisemo podtip prestavljanje za sazu (vodoravno postavljene slike)
+ private function displayPrestavljanjeSAZU($spremenljivka, $preview_spremenljivka, $quick_view, $ajax){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ //izracun visine
+ $size = 3 * 37;
+ $max = 3;
+
+ $sqlc = sisplet_query("SELECT * FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $count = mysqli_num_rows($sqlc);
+
+ save('lang_id', (get('lang_id') == null) ? self::$lang['id'] : get('lang_id'));
+
+ // nismo presegli limita ranking_k
+ if ($count < $max) {
+
+ # če smo v quick_view mode ne omogočamo
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+
+ //javascript za drag in drop
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half2_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka, #half2_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ //stop: function (){
+ stop: function (event, ui){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+
+ if(" . $ajax . "){
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ } //preneseno je bilo max stevilo vrednosti
+ else {
+ # če smo v quick_view mode ne omogočamo
+ //if (get('quick_view') == false) {
+ if ( (get('quick_view') || $preview_spremenljivka == 1) == false) {
+ echo "<script>
+ $(document).ready(
+ function(){
+
+ $('#half2_$spremenljivka div').dblclick(function() {
+ var litem = $(this).clone();
+ litem.appendTo($('#half_$spremenljivka'));
+ $(this).remove();
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ });
+
+ $('#half_$spremenljivka, #half2_$spremenljivka').sortable({
+ opacity: '0.7',
+ connectWith: ['#half_$spremenljivka'],
+
+ placeholder: 'frame_ranking_hover',
+
+ stop: function (){
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ if(" . $ajax . ")
+ $('#prestavljanje_$spremenljivka').load('" . self::$site_url . "main/survey/ajax.php?a=accept_ranking', {order: $('#half2_$spremenljivka').sortable('serialize'), spremenljivka: $spremenljivka, usr_id: usr_id, lang_id: " . get('lang_id') . ", anketa: srv_meta_anketa_id});
+ }
+ });
+ if(typeof checkBranching == 'function'){
+ checkBranching();
+ }
+ }
+ );
+
+ </script>";
+ }
+ }
+
+
+ // Izris drag in drop slik
+ echo '<div id="prestavljanje_' . $spremenljivka . '">';
+ echo '<div class="ranking_table">';
+
+
+ // izris zgornje vrstice iz kjer jemljemo slike
+ echo '<div class="grab_row">';
+
+ echo '<div id="half_' . $spremenljivka . '" class="dropzone">';
+
+ $sql1 = sisplet_query("SELECT id, naslov, other, if_id FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY RAND()");
+ //$sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' AND id NOT IN(SELECT vre_id FROM srv_data_rating WHERE spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id) ORDER BY FIELD(vrstni_red, $order)");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ }
+ else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+ $sql1V = sisplet_query("SELECT * FROM srv_data_rating WHERE vre_id = '$row1[id]' AND spr_id = '$spremenljivka' AND usr_id='" . get('usr_id') . "'");
+ if(mysqli_num_rows($sql1V) == 0){
+ // '#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . '">' . $value . '</div>' . "\n";
+ //echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . '" '.($row1['if_id'] > 0 ? ' style="display:none"' : '').'>' . $value . '</div>' . "\n";
+ }
+ }
+
+ echo '</div>';
+
+ // End grab_row
+ echo '</div>';
+
+
+ // izris spodnje vrstice kamor spustimo slike
+ echo '<div class="drop_row">';
+
+ // izris osencenih polj (ranking_k)
+ echo '<div class="drop_frames">';
+ for ($i = 1; $i <= 3; $i++) {
+ echo '<div class="frame_ranking">' . $i . '</div>' . "\n";
+ }
+ echo '</div>';
+
+ echo '<div id="half2_' . $spremenljivka . '" class="dropzone">';
+ $sql2 = sisplet_query("SELECT vre_id FROM srv_data_rating WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY vrstni_red ASC");
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $sql1 = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE id='$row2[vre_id]' ");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $value = $row1['naslov'];
+ $vre_id = $row1['id'];
+
+ if (get('mobile') == 0 || get('mobile') == 2) {// ce respondent uporablja PC ali tablico
+ $class = 'ranking';
+ }
+ else if (get('mobile') == 1) {
+ $class = 'ranking_mobile';
+ }
+
+ //'#spremenljivka_'+spremenljivka+'_vrednost_'+id
+ echo '<div id="spremenljivka_' . $spremenljivka . '_vrednost_' . $vre_id . '" class="' . $class . '">' . $value . '</div>' . "\n";
+ }
+ echo '</div>';
+
+
+ // END drop_row
+ echo '</div>';
+
+
+ // END ranking_table
+ echo '</div>';
+ echo '</div>';
+
+
+ // Large image on hover
+ echo '<script>
+ $(".ranking").hover(
+ function enter(el){
+ var content = $(this).html();
+
+ $(this).append( $("<div class=\"sazu_holder2\">" + content + "</div>") );
+ $(this).css("z-index", 3000);
+ },
+ function exit(){
+ $("div.sazu_holder2").remove();
+ $(".ranking").css("z-index", 20);
+ }
+ );
+ $(".ranking img").mousedown(
+ function(){
+ $("div.sazu_holder2").remove();
+ $(".ranking").css("z-index", 20);
+ }
+ );
+ </script>';
+ }
+
+ // Izrisemo podtip ostevilcevanje (mobile)
+ private function displayOstevilcevanje($spremenljivka, $preview_spremenljivka, $quick_view, $ajax, $oblika){
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql1 = sisplet_query("SELECT id, naslov, if_id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ //nastavimo $max (maximum prenesenih vrednosti) -> ce lahko nosimo vse vrednosti ($row['ranking_k'] == 0) je $max stevilo vseh vrednotsti
+ if ($row['ranking_k'] == 0)
+ $max = mysqli_num_rows($sql1);
+ else
+ $max = $row['ranking_k'];
+
+ $count = mysqli_num_rows($sql1);
+
+ $counter = 0;
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $sql2 = sisplet_query("SELECT * FROM srv_data_rating WHERE vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row2 = mysqli_fetch_array($sql2);
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '" id="vrednost_if_' . $row1['id'] . '"' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . '>';
+
+ // Poseben input za SAZU
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+ echo ' <input
+ vred_id='.$row1['id'].'
+ type="hidden"
+ name="spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '"
+ id="spremenljivka_' . $spremenljivka . '_ranking_cifre_' . $counter . '"
+ value="' . $row2['vrstni_red'] . '"
+ > ';
+
+ echo '<br />';
+
+ echo '<select class="sazu_select" id="sazu_select_'.$counter.'" onChange="sazuSelect(this.value, \''.$spremenljivka.'\', \''.$counter.'\');">
+ <option></option>
+ <option value="1" '.($row2['vrstni_red'] == "1" ? ' selected="selected"' : '').'>1</option>
+ <option value="2" '.($row2['vrstni_red'] == "2" ? ' selected="selected"' : '').'>2</option>
+ <option value="3" '.($row2['vrstni_red'] == "3" ? ' selected="selected"' : '').'>3</option>
+ </select>';
+
+ echo $row1['naslov'];
+ }
+ else{
+ echo ' <input
+ vred_id='.$row1['id'].'
+ type="hidden"
+ name="spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '"
+ id="spremenljivka_' . $spremenljivka . '_ranking_cifre_' . $counter . '"
+ value="' . $row2['vrstni_red'] . '"
+ > ';
+
+ echo '<br />';
+
+ echo '<select class="ranking_select" id="ranking_select_'.$counter.'" onChange="rankingSelect(this.value, \''.$spremenljivka.'\', \''.$counter.'\');">';
+ echo ' <option></option>';
+
+ // Ce imamo omejitev stevila izbir
+ for($i=1; $i<=$max; $i++){
+ echo ' <option value="'.$i.'" '.($row2['vrstni_red'] == $i ? ' selected="selected"' : '').'>'.$i.'</option>';
+ }
+
+ echo '</select>';
+
+ echo $row1['naslov'];
+ }
+
+ echo '</div>' . "\n";
+ $counter++;
+ }
+
+ // Preverimo in omogocimo/onemogocimo vrednosti pri loadu, ce imamo slucajno ze izpolnjene
+ echo '<script> $(document).ready(rankingSelectCheckAll()); </script>';
+
+ // Script za SAZU
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+ echo '<script> $(document).ready(sazuSelectCheck()); </script>';
+ }
+
+ if ($row['ranking_k'] != 0)
+ echo '<span class="limit">(' . self::$lang['srv_max_answers'] . ': ' . $max . ')</span>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/SystemVariableController.php b/main/survey/app/Controllers/Vprasanja/SystemVariableController.php
new file mode 100644
index 0000000..f0551df
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/SystemVariableController.php
@@ -0,0 +1,62 @@
+<?php
+/***************************************
+ * Description: Special system variables
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Models\Model;
+
+class SystemVariableController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new SystemVariableController();
+ }
+
+ /**
+ * @desc Prikaže checkboxe za vrednosti 99,98,97
+ */
+ public static function display($spremenljivka, $oblika)
+ {
+ $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND other IN (99,98,97) ORDER BY vrstni_red ");
+ $selected = Model::getOtherValue($spremenljivka);
+ echo '<input name="other_selected_vrednost_' . $spremenljivka . '" id="other_selected_vrednost_' . $spremenljivka . '" value="' . $selected . '" type="hidden">';
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ if ($selected == $row1['id'])
+ $sel = true;
+ else
+ $sel = false;
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . '">';
+ echo '<label for="missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '">';
+ echo '<input type="checkbox" name="vrednost_' . $spremenljivka . '[]" id="missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '" value="' . $row1['id'] . '"' . ($sel ? ' checked' : '') . ' spremenljivka="' . $spremenljivka . '" onclick=" checkBranching();"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $row1['naslov'] . '</label>';
+ echo '</div>' . "\n";
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/TextController.php b/main/survey/app/Controllers/Vprasanja/TextController.php
new file mode 100644
index 0000000..03c3fd3
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/TextController.php
@@ -0,0 +1,1022 @@
+<?php
+/***************************************
+ * Description: Textbox, Multitext
+ *
+ * Vprašanje je prisotno:
+ * tip 21
+ * tip 19
+ * tip 20
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+// Osnovni razredi
+use App\Controllers\CheckController as Check;
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Controllers\Vprasanja\SystemVariableController as SystemVariable;
+use App\Models\Model;
+use enkaParameters;
+
+class TextController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new TextController();
+ }
+
+
+ /************************************************
+ * Stara funkcija $this->displayMultitext($spremenljivka)
+ ************************************************/
+ public function multitext($spremenljivka)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // izracuni za sirino celic
+ $size = $row['grids'];
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $hideLabels = false;
+ $gridWidth = $spremenljivkaParams->get('gridWidth');
+ switch ($gridWidth) {
+ case -2:
+ $hideLabels = true;
+ $gridWidth = 30; // just in case če se kje kaj računa, itak je skrit.
+ break;
+ case -1:
+ case 0:
+ $gridWidth = 30;
+ break;
+ }
+ $gridAlign = (($spremenljivkaParams->get('gridAlign') > 0) ? $spremenljivkaParams->get('gridAlign') : 0);
+ $cssAlign = '';
+ if ($gridAlign == 1)
+ $cssAlign = ' alignLeft';
+ elseif ($gridAlign == 2)
+ $cssAlign = ' alignRight';
+
+ //$css = ' style = "width: '.$gridWidth.'%;" ';
+
+ if ($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['num_useMin'] == 1)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+ elseif ($row['num_useMax'] == 1)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ else
+ $limit = '';
+
+ //************Params za omejitev sliderjev
+ //tvorjenje omejitve********************************************************************************
+ $slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ $slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+ $limit_slider_mobile = '(min ' . $slider_MinNumLabel . ', max ' . $slider_MaxNumLabel . ')';
+ //************
+
+ // omejitev vnosa
+ if ($row['vsota_show'] == 1 && $row['ranking_k'] != '1' && $row['tip'] == 20) {
+ echo ' <label class="limit">' . $limit . '</label>';
+ }
+
+ # polovimo vrednosti gridov, prevedmo naslove in hkrati preverimo ali imamo missinge
+ $srv_grids = array();
+ $mv_count = 0; # koliko je stolpcev z manjkajočimi vrednostmi
+ # če polje other != 0 je grid kot missing
+ $sql_grid = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$row[id]' ORDER BY vrstni_red");
+
+ while ($row_grid = mysqli_fetch_assoc($sql_grid)) {
+ # priredimo naslov če prevajamo anketo
+ $naslov = Language::srv_language_grid($row['id'], $row_grid['id']);
+ if ($naslov != '') {
+ $row_grid['naslov'] = $naslov;
+ }
+ $srv_grids[$row_grid['id']] = $row_grid;
+ # če je označena kot manjkajoča jo prištejemo k manjkajočim
+ if ($row_grid['other'] != 0) {
+ $mv_count++;
+ }
+ }
+
+ echo ' <table class="grid_table multitext">' . "\n";
+
+ if ($hideLabels == false) {
+ echo '<colgroup class="question">';
+ echo '<col class="width_' . $gridWidth . '">';
+ echo '</colgroup>';
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ }
+ echo '<colgroup class="category">';
+ for ($i = 1; $i <= $row['grids']; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ if ($mv_count > 0) {
+ echo '<colgroup>';
+ echo '<col class="space">';
+ echo '</colgroup>';
+ echo '<colgroup class="missing">';
+ for ($i = 1; $i <= $mv_count; $i++)
+ echo '<col>';
+ echo '</colgroup>';
+ }
+
+ echo '<thead>';
+
+ echo ' <tr>' . "\n";
+ if ($hideLabels == false) {
+ echo ' <td></td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+
+ # če imamo mankajoče potem dodamo še en prazen stolpec za razmak
+ if ($mv_count > 0) {
+ $size += 1 + $mv_count;
+ }
+ # če imamo enoto povečamo št. stoplcev
+ if ($row['enota'] == 1) {
+ $size += 2;
+ }
+
+ //ce imamo nastavljno sirino prvega grida ostalih ne nastavljamo
+ if ($gridWidth == 30)
+ $cellsize = round(80 / $size);
+ else
+ $cellsize = 'auto';
+
+ $spacesize = round(80 / $size / 4);
+
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $taHeight = ($spremenljivkaParams->get('taHeight') ? $spremenljivkaParams->get('taHeight') : 1);
+ //default sirina
+ if ($taWidth == -1) {
+ $taWidth = 80;
+ } else {
+ //$taWidth = $taWidth * 10 * 2; // da dobimo % (opcije se od 1 - 5)
+ $taWidth = $taWidth * 10; // da dobimo % (opcije se od 1 - 9)
+ }
+
+ $bg = 1;
+
+ # Izpišemo TOP vrstico z labelami
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $g_id => $srv_grid) {
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+
+ // Datapiping
+ $srv_grid['naslov'] = Helper::dataPiping($srv_grid['naslov']);
+
+ # izpišemo labelo grida
+ echo '<td class="' . ($srv_grid['other'] == 0 ? 'category' : 'missing') . ' ' . $cssAlign . '">' . $srv_grid['naslov'] . '</td>' . "\n";
+ }
+ }
+ echo ' </tr>' . "\n";
+
+ echo '</thead>';
+
+ echo '<tbody>';
+
+ $bg++;
+
+ $orderby = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+
+ // Cache textovnih odgovorov
+ $srv_data_cache = array();
+ $sql2 = sisplet_query("SELECT * FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id ORDER BY grd_id");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ $srv_data_cache[$row2['vre_id']][$row2['grd_id']] = $row2;
+ }
+
+ // Cache missingov
+ $srv_data_grid = array();
+ $sql_grid = sisplet_query("SELECT * FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ while ($row_grid = mysqli_fetch_array($sql_grid)) {
+ $srv_data_grid[$row_grid['vre_id']] = $row_grid;
+ }
+
+
+ $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY FIELD(vrstni_red, $orderby)");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ # preverimo izbrano vrednost
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+
+ # ugotovimo ali je na katerem gridu predhodno izbran missing
+ $is_missing = false;
+ if (count($srv_grids) > 0) {
+ foreach ($srv_grids AS $i => $srv_grid) {
+ if ($srv_grid['other'] != 0) {
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ if ($srv_grids[$i]['id'] == $grid_id) {
+ $is_missing = true;
+ }
+ }
+ }
+ }
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ echo ' <tr id="vrednost_if_' . $row1['id'] . '"'/*.($row1['if_id']>0?' style="display:none"':'')*/ . '' . (($row1['hidden'] == 1) ? 'style="display:none"' : '') . (($row1['hidden'] == 2) ? 'class="answer-disabled"' : '') . '>' . "\n";
+
+ if ($hideLabels == false) {
+ echo ' <td class="question">' . $row1['naslov'];
+ if ($row1['other'] == 1) {
+ $sql3 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row3 = mysqli_fetch_array($sql3);
+
+ $otherWidth = ($spremenljivkaParams->get('otherWidth') ? $spremenljivkaParams->get('otherWidth') : -1);
+ $otherHeight = ($spremenljivkaParams->get('otherHeight') ? $spremenljivkaParams->get('otherHeight') : 1);
+
+ if ($otherHeight > 1)
+ echo ' <textarea name="textfield_' . $row1['id'] . '" rows="' . $otherHeight . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . '>' . ($is_missing ? '' : $row3['text']) . '</textarea>';
+ else
+ echo ' <input type="text" name="textfield_' . $row1['id'] . '" value="' . ($is_missing ? '' : $row3['text']) . '" style="' . ($otherWidth != -1 ? ' width:' . $otherWidth . '%;' : '') . '" ' . ($is_missing ? ' disabled' : '') . ' />';
+
+ //echo ' <input type="text" name="textfield_'.$row1['id'].'" value="'.($is_missing ? '' : $row3['text']).'" '.($is_missing ? ' disabled' : '').'>';
+ }
+ echo ' </td>' . "\n";
+ echo ' <td></td>' . "\n";
+ }
+ if (count($srv_grids) > 0) {
+ $first_missing_value = true;
+ foreach ($srv_grids AS $i => $srv_grid) {
+
+ if ($srv_grid['other'] != 0)
+ $grid_id = $srv_data_grid[$row1['id']]['grd_id'];
+ else
+ $grid_id = $srv_data_cache[$row1['id']][$i]['grd_id'];
+
+ $value = $srv_grid['id'];
+ $vsebina = '';
+
+ if ($grid_id == $value) {
+
+ $vsebina = $srv_data_cache[$row1['id']][$i]['text'];
+
+ //$row2 = mysqli_fetch_array($sql2);
+ }
+
+ if ((string)$srv_grid['other'] != '0' && $first_missing_value == true) {
+ # dodamo spejs pred manjkajočimi vrednostmi
+ echo '<td></td>';
+ $first_missing_value = false;
+ }
+ # izpišemo labelo grida
+ //multitext
+ if ($row['tip'] == 19) {
+ if ($srv_grid['other'] != 0) {
+ # imamo missing nardimo radio
+ echo '<td class="missing ' . $cssAlign . '">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category ' . $cssAlign . '">';
+ //echo '<input type="text" style="width:'.$taWidth.'em;" name="vrednost_'.$row1['id'].'_grid_'.$value.'" id="vrednost_'.$row1['id'].'_grid_'.$value.'" value="'.($is_missing ? '' : $vsebina).'" calculation="'.$srv_grid['variable'].'" '.($is_missing ? ' disabled class="disabled"' : '').'>';
+ echo '<textarea class="width_' . $taWidth . '" rows="' . $taHeight . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeyup="checkBranching();">' . ($is_missing ? '' : $vsebina) . '</textarea>';
+ echo '</td>' . "\n";
+ }
+
+ //multinumber - rabimo JS checkNumber
+ } else {
+ if ($srv_grid['other'] != 0) {
+ # imamo missing nardimo radio
+ echo '<td class="missing ' . $cssAlign . '">';
+ echo '<label for="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '">';
+ echo '<input type="radio" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="grid_missing_value_' . $row1['id'] . '_grid_' . $value . '" value="' . $value . '"' . (($grid_id == $value && $grid_id != '') ? ' checked' : '') . ' data-calculation="0" onclick="checkChecked(this); checkTableMissing(this); checkBranching();">';
+
+ // Font awesome
+ echo '<span class="enka-checkbox-radio ' . (($row1['hidden'] == 2) ? 'answer-disabled' : '') . '"' .
+ ((Helper::getCustomCheckbox() != 0) ? (' style="font-size:' . Helper::getCustomCheckbox() . 'px;"') : '') .
+ '></span>';
+ echo '</label>';
+ echo '</td>' . "\n";
+ } else {
+ echo '<td class="category ' . $cssAlign . '">';
+ echo '<input type="text" class="width_' . $taWidth . '" name="vrednost_' . $row1['id'] . '_grid_' . $value . '" id="vrednost_' . $row1['id'] . '_grid_' . $value . '" value="' . ($is_missing ? '' : $vsebina) . '" data-calculation="' . $srv_grid['variable'] . '" ' . ($is_missing ? ' disabled' : '') . ' onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); checkBranching();">';
+
+ //multislider
+ //if ($row['ranking_k'] == 1 && get('mobile') == 0) {
+ if ($row['ranking_k'] == 1) { //slider na PC, tablici in mobilniku
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $slider_handle = ($spremenljivkaParams->get('slider_handle') ? $spremenljivkaParams->get('slider_handle') : 0);
+ $slider_window_number = ($spremenljivkaParams->get('slider_window_number') ? $spremenljivkaParams->get('slider_window_number') : 0);
+ $slider_nakazi_odgovore = ($spremenljivkaParams->get('slider_nakazi_odgovore') ? $spremenljivkaParams->get('slider_nakazi_odgovore') : 0); //za checkbox
+ $slider_MinMaxNumLabelNew = ($spremenljivkaParams->get('slider_MinMaxNumLabelNew') ? $spremenljivkaParams->get('slider_MinMaxNumLabelNew') : 0);
+ $slider_MinMaxLabel = ($spremenljivkaParams->get('slider_MinMaxLabel') ? $spremenljivkaParams->get('slider_MinMaxLabel') : 0);
+ $slider_VmesneNumLabel = ($spremenljivkaParams->get('slider_VmesneNumLabel') ? $spremenljivkaParams->get('slider_VmesneNumLabel') : 0);
+ $slider_VmesneDescrLabel = ($spremenljivkaParams->get('slider_VmesneDescrLabel') ? $spremenljivkaParams->get('slider_VmesneDescrLabel') : 0);
+ $slider_VmesneCrtice = ($spremenljivkaParams->get('slider_VmesneCrtice') ? $spremenljivkaParams->get('slider_VmesneCrtice') : 0);
+ $slider_handle_step = ($spremenljivkaParams->get('slider_handle_step') ? $spremenljivkaParams->get('slider_handle_step') : 1);
+ $slider_MinLabel = ($spremenljivkaParams->get('slider_MinLabel') ? $spremenljivkaParams->get('slider_MinLabel') : "Minimum");
+ $slider_MaxLabel = ($spremenljivkaParams->get('slider_MaxLabel') ? $spremenljivkaParams->get('slider_MaxLabel') : "Maximum");
+ //$slider_MinNumLabel = ($spremenljivkaParams->get('slider_MinNumLabel') ? $spremenljivkaParams->get('slider_MinNumLabel') : 0);
+ //$slider_MaxNumLabel = ($spremenljivkaParams->get('slider_MaxNumLabel') ? $spremenljivkaParams->get('slider_MaxNumLabel') : 100);
+
+
+ $slider_NumofDescrLabels = ($spremenljivkaParams->get('slider_NumofDescrLabels') ? $spremenljivkaParams->get('slider_NumofDescrLabels') : 5);
+ $slider_DescriptiveLabel_defaults = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults') : 0);
+ $slider_DescriptiveLabel_defaults_naslov1 = ($spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') ? $spremenljivkaParams->get('slider_DescriptiveLabel_defaults_naslov1') : 0);
+ $displayMinMaxLabel = ($slider_MinMaxLabel == 0) ? ' style="display:none;"' : '';
+
+
+ if(get('lang_id') != null){
+ $lang_id = get('lang_id');
+ $ank_id = get('anketa');
+
+ $sqlString = "SELECT label, label_id FROM srv_language_slider WHERE ank_id='$ank_id' AND spr_id='$spremenljivka' AND lang_id='$lang_id' ORDER BY label_id";
+ $sqlSlider = sisplet_query($sqlString);
+
+ while ($rowsqlSlider = mysqli_fetch_array($sqlSlider)) {
+ if($rowsqlSlider['label_id'] == 1){
+ $MinLabel = $rowsqlSlider['label'];
+ }
+ elseif($rowsqlSlider['label_id'] == 2){
+ $MaxLabel = $rowsqlSlider['label'];
+ }elseif($row['label_id'] == 0){
+ $custom = $rowsqlSlider['label'];
+ }
+ }
+
+ if($slider_DescriptiveLabel_defaults && $custom==''){ //ce so prednalozene opisne labele drsnika in nimamo se prevoda
+ $custom_ar = explode(';', $slider_DescriptiveLabel_defaults_naslov1);
+ }else{ //ce so custom opisne labele drsnika
+ $custom_ar = explode('; ', $custom);
+ }
+
+ // Ce slucajno nimamo prevedeno uporabimo original
+ $MinLabel = ($MinLabel == '') ? ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']) : $MinLabel;
+ $MaxLabel = ($MaxLabel == '') ? ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']) : $MaxLabel;
+ }
+ else{
+ $MinLabel = ($spremenljivkaParams->get('MinLabel') ? $spremenljivkaParams->get('MinLabel') : self::$lang['srv_new_text']);
+ $MaxLabel = ($spremenljivkaParams->get('MaxLabel') ? $spremenljivkaParams->get('MaxLabel') : self::$lang['srv_new_text']);
+ }
+
+ //echo '<div style="width:100%">';
+ echo '<div style="width:100%; height:150px">';
+
+ //$default_value = round(($row['vsota_limit']-$row['vsota_min']) / 2) + $row['vsota_min'];
+ $default_value = round(($slider_MaxNumLabel - $slider_MinNumLabel) / 2) + $slider_MinNumLabel;
+ $vrednost = ($vsebina == '') ? $default_value : $vsebina;
+
+ //labeli nad min in max drsnikov ############################################################
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel">';
+ } else if (get('mobile') == 1) { //ce mobilnik
+ echo '<table ' . $displayMinMaxLabel . ' class="slider_grid_minmaxlabel_mobile">';
+ }
+ echo '<tbody>';
+ echo '<tr>';
+ echo '<td align="left">' . $MinLabel . '</td>';
+ echo '<td align="right">' . $MaxLabel . '</td>';
+ echo '</tr>';
+ echo '</tbody>';
+ echo '</table>';
+ //labeli nad min in max drsnikov - konec ####################################################
+
+ echo '<div class="sliderText" id="sliderText_' . $spremenljivka . '_' . $row1['id'] . '">' . $vrednost . '</div>';
+
+ //echo '<div style="display:inline-block;">'.$row['vsota_min'].'</div>';
+ //echo '<div id="slider_'.$spremenljivka.'_'.$row1['id'].'" class="slider"></div>';
+ //echo '<div style="display:inline-block;">'.$row['vsota_limit'].'</div>';
+ if (get('mobile') == 0 || get('mobile') == 2) {//ce PC ali tablica
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider"></div>';
+ } else if (get('mobile') == 1) { //ce mobilnik
+ echo '<div id="slider_' . $spremenljivka . '_' . $row1['id'] . '" class="slider_grid_mobile"></div>';
+ }
+
+ echo '</div>';
+
+ //za custom opisne labele
+ //moznosti urejanja opisnih label drsnika
+ if($slider_VmesneDescrLabel){
+ for($i=1; $i<=$slider_NumofDescrLabels; $i++){
+ if($custom == ''){ //ce nimamo prevoda opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = ($spremenljivkaParams->get('slider_Labela_opisna_'.$i) ? $spremenljivkaParams->get('slider_Labela_opisna_'.$i) : '');
+ }else{ //ce mamo prevod opisnih label za drsnika
+ $slider_CustomDescriptiveLabelsTmp = $custom_ar[$i-1];
+ }
+ $slider_CustomDescriptiveLabelsTmp = preg_replace("/\s|&nbsp;/",' ',$slider_CustomDescriptiveLabelsTmp); //za odstranitev morebitnih presledkov, ki lahko delajo tezave pri polju za drsnik
+ if($i == 1){
+ $slider_CustomDescriptiveLabels = $slider_CustomDescriptiveLabelsTmp;
+ }else{
+ $slider_CustomDescriptiveLabels .= "; ".$slider_CustomDescriptiveLabelsTmp;
+ }
+ }
+ }
+ //za custom opisne labele - konec
+
+ ?>
+ <script>
+ $(function () {
+ slider_grid_init(<?=get('mobile')?>, <?=$spremenljivka?>, <?=$row1['id']?>, <?=$slider_MinNumLabel?>, <?=$slider_MaxNumLabel?>, <?=$vrednost?>, <?=$slider_handle?>, <?=$slider_handle_step?>, <?=$slider_VmesneNumLabel?>, <?=$slider_VmesneCrtice?>, <?=$slider_MinMaxNumLabelNew?>, <?=$slider_window_number?>, '<?=$slider_DescriptiveLabel_defaults_naslov1?>', <?=$slider_DescriptiveLabel_defaults?>, <?=$default_value?>, <?=$slider_nakazi_odgovore?>, <?=$slider_VmesneDescrLabel?>, '<?=$slider_CustomDescriptiveLabels?>', '<?=$custom?>');
+ });
+ </script>
+ <?
+ }
+
+ echo '</td>' . "\n";
+
+ }
+ }
+ }
+ }
+
+ echo ' </tr>' . "\n";
+
+ $bg++;
+ }
+
+ echo '</tbody>';
+
+ echo ' </table>' . "\n";
+
+ // Izpis prejsnjih odgovorov (ce imamo vklopljeno nastavitev)
+ $prevAnswers = ($spremenljivkaParams->get('prevAnswers') ? $spremenljivkaParams->get('prevAnswers') : 0);
+ if($prevAnswers == 1)
+ self::display_prevAnswers($spremenljivka);
+ }
+
+ /************************************************
+ * Stara funkcija $this->displayTextbox($spremenljivka)
+ ************************************************/
+ public function textbox($spremenljivka, $oblika)
+ {
+ global $recaptcha_sitekey;
+ global $lang;
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ if($row['num_useMin'] == 1 && $row['num_useMax'] == 1 && $row['vsota_min'] == $row['vsota_limit'])
+ $limit = '('.$lang['srv_text_length_char_num'].$row['vsota_min'].')';
+ elseif($row['num_useMin'] == 1 && $row['num_useMax'] == 1)
+ $limit = '('.$lang['srv_text_length_char_num'].'min '.$row['vsota_min'].', max '.$row['vsota_limit'].')';
+ elseif($row['num_useMin'] == 1)
+ $limit = '('.$lang['srv_text_length_char_num'].'min '.$row['vsota_min'].')';
+ elseif($row['num_useMax'] == 1)
+ $limit = '('.$lang['srv_text_length_char_num'].'max '.$row['vsota_limit'].')';
+ else
+ $limit = '';
+
+ $taSize = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1);
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ $max_text_length = ($row['vsota_limit'] > 0 ? ' maxlength="'.$row['vsota_limit'].'"' : '');
+ $email_verify = ($spremenljivkaParams->get('emailVerify') ? $spremenljivkaParams->get('emailVerify') : 0);
+
+ //default sirina
+ if ($taWidth == -1)
+ $taWidth = 30;
+
+ # preverimo ali je vrednost v bazi missing
+ $missing = Check::getInstance()->checkMissingForSpremenljivka($spremenljivka, $loop_id);
+
+ if ((int)$missing > 0) {
+ $srv_data_vrednost[$missing] = true;
+ }
+
+ // Ce imamo slucajno vklopljeno nastavitev da so odgovori disabled
+ $disabled_vprasanje = ($spremenljivkaParams->get('disabled_vprasanje') == '1') ? true : false;
+
+ if ($row['upload'] == 1 || $row['upload'] == 2 ) // max size
+ echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . (1024 * 1024 * 100) . '">';
+
+ echo '<table class="text_vrednost"><tbody>' . "\n";
+ if ($row['orientation'] != 3)
+ echo '<tr>';
+
+ # za polja drugo
+ $array_others = array();
+
+ $sql1 = sisplet_query("SELECT id, naslov, vrstni_red, other, size, naslov2 FROM srv_vrednost WHERE spr_id='$row[id]' AND vrstni_red > 0 ORDER BY vrstni_red");
+
+ $i = 1;
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ # če ni polje drugo
+ if ((int)$row1['other'] == 0) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND vre_id='$row1[id]' AND loop_id $loop_id");
+ $row2 = mysqli_fetch_array($sql2);
+
+
+ // sirina celice td
+ $cell = $row['text_kosov'] == 1 ? 100 : $row1['size'];
+ $width = round(100 / $row['text_kosov'], 0);
+ // sirina vnosnega polja
+ $input = $taWidth;
+
+ if ($row['orientation'] == 3)
+ echo '<tr>';
+ echo '<td class="variabla">' . "\n";
+
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ //izpisi
+ if ($row['text_orientation'] == 1 || $row['text_orientation'] == 3) {
+ echo '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '">' . $row1['naslov'] . '</label>' . "\n";
+
+ if ($row['text_orientation'] == 3)
+ echo '<br>';
+ }
+
+
+ // Ni signature ali upload
+ if ($row['upload'] == 0 && $row['signature'] == 0) {
+
+ // if captcha == 1
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $captcha = ($spremenljivkaParams->get('captcha') ? $spremenljivkaParams->get('captcha') : 0);
+
+ if ($captcha == 1) {
+ echo '<div class="g-recaptcha" data-sitekey="' .$recaptcha_sitekey .'"></div>';
+ }
+ else {
+ $char_counter_events = $limit ? 'charCounter(this);' : '';
+
+ // Ce gre za email preverjamo pravilnost na blur in ne na keyup
+ $js_trigger = ($email_verify == 1) ? 'onBlur' : 'onKeyUp';
+
+ echo '<label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '">';
+
+ if ($taSize > 1) {
+ echo '<textarea name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' rows="' . $taSize . '" class="width_' . $input . '" onkeyup="checkBranching();'.$char_counter_events.'"' . (!$missing && !$disabled_vprasanje ? '' : ' disabled') . $max_text_length. '>' . (!$missing ? $row2['text'] : '') . '</textarea>';
+ } else {
+ echo '<input type="text" name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '" class="width_' . $input . '" '.($disabled_vprasanje ? ' disabled="disabled"' : '').' '.$js_trigger.'="checkBranching();'.$char_counter_events.'" value="' . (!$missing ? $row2['text'] : '') . '" ' . (!$missing && !$disabled_vprasanje ? '' : ' disabled') . $max_text_length. '>';
+ }
+
+ // Ce je vprasanje disabled moramo vseeno postati vrednost
+ if($disabled_vprasanje && !$missing){
+ echo '<input type="hidden" name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" value="'.$row2['text'].'">';
+ }
+
+ // prikazi counter znakov
+ if ($limit && !get('printPreview')) {
+ echo '<span id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '_counter" class="char_counter"></span>';
+ echo '<script>set_charCounter(\'spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '\');</script>';
+ }
+
+ echo '</label>';
+ }
+
+ } // Signature
+ elseif ($row['signature'] != 0 && $row['upload'] == 0) {
+ //***novo
+ echo ' <script src="' . self::$site_url . 'main/survey/js/signature/jquery.signaturepad.js"></script>' . "\n";
+ echo ' <!--[if lt IE 9]><script src="' . self::$site_url . 'main/survey/js/signature/flashcanvas.js"></script><![endif]-->' . "\n";
+
+ //za ureditev vpogleda v posamezno enoto
+ $quick_view = json_encode(get('quick_view'));
+
+ // options za risanje signature in ostale spremenljivke
+ echo '<script>
+ if('.$quick_view.'==1){
+ $("#clear_spremenljivka_' . $spremenljivka . '").attr("disabled", true);
+ //console.log("Izklopi gumb");
+ }
+ optionsPodpis[' . $spremenljivka . '] = { //options za signature knjižnico, ki niso default vrednosti
+ drawOnly : true //samo risanje podpisa
+ , clear: "#clear_spremenljivka_' . $spremenljivka . '" //gumb oz. polje za brisanje ima id
+ , output: "#signature-data_spremenljivka_' . $spremenljivka . '" //polje, kjer se prikaže output oz. podpis v json obliki
+ , validateFields: false //preverjanje vnosa podpisa in imena se ne izvaja
+ };
+
+ </script>
+ ';
+
+ //***novo
+
+ //$sqlSignature = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . get('usr_id') . "'");
+ $sqlSignature = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . get('usr_id') . "' AND code='" . $spremenljivka . "' ");
+ if (mysqli_num_rows($sqlSignature) > 0) {
+ $rowSignature = mysqli_fetch_array($sqlSignature);
+ $signaturefile = $rowSignature[0];
+
+
+ echo '
+ <script>
+ var polje_imena ="#spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"
+ $(document).ready(
+ function(){
+
+ $("#canvas_' . $spremenljivka . '").hide();
+ $("#podpis_slika_' . $spremenljivka . '").show();
+ if(' . sizeof($row2['text']) . ' > 0){
+ $("#spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '").val("' . $row2['text'] . '");
+ }
+ //$("#clear_spremenljivka_' . $spremenljivka . '").mousedown(function(){ //ob kliku na gumb miške dol
+ $("#clear_spremenljivka_' . $spremenljivka . '").click(function(){ //ob kliku
+ $("#canvas_' . $spremenljivka . '").show(); //pokazi canvas za podpis
+ $("#canvas_' . $spremenljivka . ' .sigWrapper").addClass("current");
+ podpisposlan[' . $spremenljivka . '] = 0;
+ $("#podpis_slika_' . $spremenljivka . '").remove(); //odstrani sliko podpisa
+ $.post("' . self::$site_url . 'main/survey/ajax.php?a=usr_id_data", //poslji podatke za brisanje podatkov o sliki iz baze in brisanje datoteke iz diska
+ {usr_id: ' . get('usr_id') . ', anketa: ' . srv_meta_anketa_id . ', spr_id: ' . $spremenljivka . ', vre_id: ' . $row1[id] . '});
+ });
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']); //omogoci risanje na canvas
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").mouseout(function(){ //ob izhodu miške iz površine za podpisovanje
+ if(!$("#signature-data_spremenljivka_' . $spremenljivka . '").val()){ //če ni nobenega podpisa
+ //console.log("Prazno!");
+ }else{ //drugače, če je podpisa prisoten
+ if(podpisposlan[' . $spremenljivka . '] == 0){
+ podpisposlan[' . $spremenljivka . '] = 1;
+
+ var signaturedata = $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']).getSignatureImage();
+ //console.log(signaturedata);
+ var signaturename = $("#signature-name_spremenljivka_' . $spremenljivka . '").val();
+ $("#signature-data_spremenljivka_' . $spremenljivka . '").val(signaturedata);
+ $("#signature-name_spremenljivka_' . $spremenljivka . '").val(signaturename);
+ }
+ }
+ });
+ }
+ );
+
+ </script>
+ ';
+ //echo $rowSignature[0];
+ } else {
+
+ //predelano - začetek urejanja javascript kode za delovanje podpisa
+ echo '
+ <script>
+ $(document).ready(
+ function(){
+
+ podpisposlan[' . $spremenljivka . '] = 0;
+
+ if('.$quick_view.'){
+ $("#clear_spremenljivka_' . $spremenljivka . '").attr("disabled", true);
+ }else{
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']); //omogoci risanje na canvas
+ }
+
+
+
+ $("#clear_spremenljivka_' . $spremenljivka . '").click(function(){ //ob kliku na gumb Clear
+ //console.log("Brišem");
+ podpisposlan[' . $spremenljivka . '] = 0;
+ $("#spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '").val("");//počisti polje z imenom
+ });
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").mouseout(function(){ //ob izhodu miške iz površine za podpisovanje
+
+ if(!$("#signature-data_spremenljivka_' . $spremenljivka . '").val()){ //če ni nobenega podpisa
+ //console.log("Prazno!");
+ }else{ //drugače, če je podpisa prisoten
+ //console.log("Nekaj je");
+ if(podpisposlan[' . $spremenljivka . '] == 0){
+ podpisposlan[' . $spremenljivka . '] = 1;
+
+ var signaturedata = $("#signature-pad_spremenljivka_' . $spremenljivka . '").signaturePad(optionsPodpis[' . $spremenljivka . ']).getSignatureImage();
+ //console.log(signaturedata);
+ var signaturename = $("#signature-name_spremenljivka_' . $spremenljivka . '").val();
+ $("#signature-data_spremenljivka_' . $spremenljivka . '").val(signaturedata);
+ $("#signature-name_spremenljivka_' . $spremenljivka . '").val(signaturename);
+ }
+ }
+ });
+
+ $("#signature-pad_spremenljivka_' . $spremenljivka . '").click(function(){ //ob kliku na gumb površino za podpisovanje
+ podpisposlan[' . $spremenljivka . '] = 0;
+ });
+ }
+ );
+ </script>
+ ';
+
+
+ //predelano - konec
+ }
+
+ // Dobimo sirino polja - ce je mobile ga pomanjsamo
+ if(get('mobile') == 1){
+ $width = 300;
+ $height = 150;
+ }
+ else{
+ $width = 600;
+ $height = 200;
+ }
+
+ echo '
+ <div id="signature-pad_spremenljivka_' . $spremenljivka . '">
+ <div id="canvas_' . $spremenljivka . '">
+
+ <div class="sig sigWrapper">
+ <canvas width="'.$width.'" height="'.$height.'" style="border:1px solid black"></canvas>
+ </div>
+ </div>
+ <div id="podpis_slika_' . $spremenljivka . '" hidden>
+ <img src="' . self::$site_url . 'main/survey/uploads/' . $signaturefile . '" style="width: '.$width.'px; height: '.$height.'px; border:1px solid black">
+ </div>
+ <div>
+
+ <input id="clear_spremenljivka_' . $spremenljivka . '" type="button" value="' . self::$lang['srv_signature_clear'] . '" class="sig_clear_button" style="width: '.$width.'px;">
+
+ <input id="signature-data_spremenljivka_' . $spremenljivka . '" type="text" value="" name="signature-data_spremenljivka_' . $spremenljivka . '" hidden><br />
+ ';
+
+
+ echo '
+ ' . self::$lang['srv_signature_name'] . ' ' . '<input type="text" name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '" ' . (!$missing ? '' : ' disabled') . '><br />
+
+ </div>
+ </div>
+ ';
+ }
+
+ // Smo v admin podatkih in uplodamo datoteko ali fotografijo
+ elseif( ($row['upload'] == 1 || $row['upload'] == 2) && ($_GET['t'] == 'postprocess' || $_GET['m'] == 'quick_edit') ){
+
+ $sqlUpload = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id='".get('usr_id')."' AND code='".$row2['text']."'");
+
+ // Ze imamo datoteko - moznost brisanja v adminu
+ if(mysqli_num_rows($sqlUpload) > 0){
+
+ $rowUpload = mysqli_fetch_array($sqlUpload);
+ $file = $rowUpload[0];
+
+ global $site_url;
+ echo '<div style="font-size:14px;"><a href="'.$site_url.'/main/survey/download.php?anketa='.get('anketa').'&code='.$row2['text'].'">'.$file.'</a></div>';
+
+ // Remove file button
+ if($_GET['quick_view'] != '1'){
+ echo '<div class="buttonwrapper floatLeft">
+ <a
+ class="ovalbutton ovalbutton_orange btn_savesettings"
+ href="#"
+ style="margin: 10px 0 0 0;"
+ id="remove_file_'.$spremenljivka.'_vrednost_'.$i.'"
+ onClick="removeUploadFromData(\''.get('usr_id').'\', \''.$spremenljivka.'\', \''.$row2['text'].'\')"
+ >';
+ echo self::$lang['srv_alert_upload_remove'];
+ echo '</div>';
+ }
+ }
+ // Uploadamo datoteko preko admina - TODO
+ else{
+
+ echo '<input name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '"
+ type="file"
+ id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"
+ class="pointer"
+ >';
+ }
+ }
+
+ // Upload
+ elseif ($row['upload'] == 1) {
+
+ echo '<input name="vrednost_' . $spremenljivka . '_kos_' . $row1['id'] . '"
+ type="file"
+ id="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '"
+ ' . (!$missing ? '' : ' disabled') . '
+ class="pointer"
+ onChange="checkUpload(this, \''.$spremenljivka.'_vrednost_'.$i.'\');"
+ >';
+
+ // Remove file button
+ echo '<div class="remove_file pointer"
+ id="remove_file_'.$spremenljivka.'_vrednost_'.$i.'"
+ style="display:none;"
+ onClick="removeUpload(\'spremenljivka_'.$spremenljivka.'_vrednost_'.$i.'\')"
+ >';
+ echo self::$lang['srv_alert_upload_remove'];
+ echo '</div>';
+ }
+
+ // Fotografiranje
+ elseif ($row['upload'] == 2) {
+
+ $inpname = 'vrednost_' . $spremenljivka . '_kos_' . $row1['id'];
+ $inpid = 'spremenljivka_' . $spremenljivka . '_vrednost_' . $i;
+
+ echo '<label class="custom-foto-upload" for="'.$inpid. '"></label>';
+ echo '<input class="upload_foto_file" name="'.$inpname . '" type="file" accept="image/*" id="'.$inpid. '" capture="camera">';
+ echo '<div class="fotoresults_delete upload_fotoresults_delete pointer" id="upload_fotoresults_delete_'.$inpid.'" onClick="delete_upload_foto(\''.$inpid.'\');">'.$lang['srv_alert_foto_remove'].'</div>';
+
+ echo '<div id="upload_foto_result_'.$inpid.'_holder">
+ <img id="upload_foto_result_'.$inpid. '" class="upload_foto_result" src="#">
+ </div>';
+
+ echo '<div class="fotoparent" id="fotoparent_'.$inpid.'" style="visibility: hidden; display : none;">
+ <div class="fotoresults_div">
+ <p style="padding: 4px;"><i>'.self::$lang['srv_resevanje_foto_result_title'].'</i></p>
+
+ <div class="fotoresults" id="fotoresults_'.$inpid.'">
+ <p>'.self::$lang['srv_resevanje_foto_pre_result'].'</p>
+ </div>
+ <div class="fotoresults_delete pointer" id="fotoresults_delete_'.$inpid.'" onClick="delete_snapshot(\''.$inpid.'\');">'.$lang['srv_alert_foto_remove'].'</div>
+ </div>
+ <input id="foto_'.$inpid.'" type="hidden" name="foto_'.$inpname.'" value=""/>
+
+ <div class="my_camera_div">
+ <p style="padding: 4px;"><i>'.self::$lang['srv_resevanje_foto_snap_title'].'</i></p>
+
+ <div class="my_camera" id="my_camera_'.$inpid.'"></div>
+
+ <!-- A button for taking snaps -->
+ <button type="button" class="record_foto" onClick="take_snapshot(\''.$inpid.'\');"></button>
+ </div>
+ </div>';
+ ?>
+
+ <!-- Configure a few settings and attach camera -->
+ <script language="JavaScript">
+ //dobi osnovni id iputa spremenljivke
+ var inpid = '<?php echo $inpid; ?>';
+
+ //deklarira vse potrebno za funkcionalnost fotografiranja
+ FotoDeclaration(inpid, '<?php echo self::$site_url; ?>');
+
+ //prikazi uploadano datoteko v primeru navadnega uploada ali prek mobilnika
+ function readURL(input) {
+ if (input.files && input.files[0]) {
+ var reader = new FileReader();
+
+ reader.onload = function (e) {
+ $('#upload_foto_result_'+inpid).css("display", "inline");
+ $('#upload_foto_result_'+inpid).attr('src', e.target.result);
+ $('#upload_fotoresults_delete_'+inpid).show();
+ };
+
+ reader.readAsDataURL(input.files[0]);
+ }
+ }
+
+ //ko se navadni upload spremeni, zazeni F za prikaz slike
+ $("#"+inpid).change(function(){
+ readURL(this);
+ });
+ </script>
+ <?php
+ }
+
+
+ if ($row['text_orientation'] == 2) {
+ echo '<br><label for="spremenljivka_' . $spremenljivka . '_vrednost_' . $i . '">' . $row1['naslov'] . '</label>' . "\n";
+ }
+
+ // omejitev vnosa
+ if ($row['vsota_show'] == 1) {
+ echo '<label class="limit">' . $limit . '</label>';
+ }
+
+ echo '</td>' . "\n";
+ if ($row['orientation'] == 3)
+ echo '</tr>';
+ }
+ else {
+ # imamo polje drugo - ne vem, zavrnil...
+ $array_others[$row1['id']] = array(
+ 'naslov' => $row1['naslov'],
+ 'vrstni_red' => $row1['vrstni_red']
+ );
+ }
+
+ $i++;
+ }
+
+ if ($row['orientation'] != 3)
+ echo '</tr>';
+
+ echo '</tbody></table>' . "\n";
+
+ if (count($array_others) > 0) {
+ $missing = 1;
+ foreach ($array_others AS $oKey => $other) {
+ # missing vrednost
+ $_id = 'missing_value_spremenljivka_' . $spremenljivka . '_vrednost_' . $oKey;
+
+ if ($srv_data_vrednost[$oKey]) {
+ $sel = true;
+ } else {
+ $sel = false;
+ }
+
+ # če nimamo missingov in je trenutni enak izbranemu, ali če imamo misinge inje trenutni enak izbranemu misingu
+ $_checked = ($sel ? ' checked' : '');
+ // Tole ni definirano in ne more delat?? zakaj bi sploh kadarkoli bil missing disabled??
+ //$_disabled = ($is_missing && ($row1['other'] == 0 || $row1['other'] == 1) ? true : false);
+ $_disabled = false;
+
+ $naslov = Language::getInstance()->srv_language_vrednost($oKey);
+ if ($naslov != '') $other['naslov'] = $naslov;
+
+ // Ali skrivamo missing ne vem in ga prikazemo sele ob opozorilu
+ $hide_missing = false;
+
+ $already_set_mv = array();
+ $sql_grid_mv = sisplet_query("SELECT naslov, other FROM srv_vrednost WHERE spr_id='" . $spremenljivka . "' AND other != 0");
+ while ($row_grid_mv = mysqli_fetch_array($sql_grid_mv)) {
+ $already_set_mv[$row_grid_mv['other']] = $row_grid_mv['naslov'];
+ }
+
+ if ((($row['alert_show_99'] > 0 && isset($already_set_mv['-99']) && $already_set_mv['-99'] == $other['naslov'])
+ || ($row['alert_show_98'] > 0 && isset($already_set_mv['-98']) && $already_set_mv['-98'] == $other['naslov'])
+ || ($row['alert_show_97'] > 0 && isset($already_set_mv['-97']) && $already_set_mv['-97'] == $other['naslov']))
+ && $_checked == ''
+ )
+ $hide_missing = true;
+
+ $checkbox_limit = ($spremenljivkaParams->get('checkbox_limit') ? $spremenljivkaParams->get('checkbox_limit') : 0);
+
+ echo '<div class="variabla' . $oblika['cssFloat'] . ' missing" id="vrednost_if_' . $oKey . '"' . ' ' . ($hide_missing ? ' style="display:none"' : '') . '>';
+ echo '<label for="' . $_id . '">';
+ echo '<input type="checkbox" name="vrednost_mv_' . $spremenljivka . '[]" id="' . $_id . '" value="' . $oKey . '"' . $_checked . ($_disabled ? ' disabled' : '') . ' data-calculation="1" onclick="checkBranching(); ' . ($checkbox_limit > 0 ? 'checkboxLimit(\'' . $spremenljivka . '\', \'' . $oKey . '\', \'' . $checkbox_limit . '\');' : '') . ' checkMissing(this);"> ';
+ // Font awesome checkbox
+ echo '<span class="enka-checkbox-radio" '.((Helper::getCustomCheckbox() != 0) ? 'style="font-size:' . Helper::getCustomCheckbox() . 'px;"' : '').'></span>';
+ echo '' . $other['naslov'] . '</label>';
+ echo '</div>';
+ }
+ }
+
+ SystemVariable::display($spremenljivka, $oblika);
+
+ // Izpis prejsnjih odgovorov (ce imamo vklopljeno nastavitev)
+ $prevAnswers = ($spremenljivkaParams->get('prevAnswers') ? $spremenljivkaParams->get('prevAnswers') : 0);
+ if($prevAnswers == 1)
+ self::display_prevAnswers($spremenljivka);
+ }
+
+
+ // Prikazemo stare odgovore pod vprasanjem (nastavitev prevAnswers)
+ private function display_prevAnswers($spremenljivka){
+
+ echo '<div class="text_prevAnswers">';
+ echo self::$lang['srv_prevAnswers'].':';
+
+ echo '<div class="text_prevAnswers_list">';
+
+ //$sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id!='" . get('usr_id') . "' AND vre_id='$row1[id]' AND loop_id $loop_id");
+ $sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='".$spremenljivka."' AND usr_id!='".get('usr_id')."' ORDER BY id DESC limit 30");
+ while($row = mysqli_fetch_array($sql)){
+ echo '<p>';
+ echo $row['text'];
+ echo '</p>';
+ }
+
+ $sqlC = sisplet_query("SELECT count(*) FROM srv_data_text" . get('db_table') . " WHERE spr_id='".$spremenljivka."' AND usr_id!='".get('usr_id')."'");
+ $rowC = mysqli_fetch_array($sqlC);
+ if($rowC['count(*)'] > 30){
+ // gumb "vec" da prikazemo vse
+ echo '<span class="more" onClick="show_prevAnswers_all(\''.$spremenljivka.'\');">('.self::$lang['srv_more'].'...)</span>';
+
+ // div za izris vseh
+ echo '<div id="text_prevAnswers_popup_'.$spremenljivka.'" class="text_prevAnswers_popup"></div>';
+ }
+
+ echo '</div>';
+
+ echo '</div>';
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Controllers/Vprasanja/VprasanjaController.php b/main/survey/app/Controllers/Vprasanja/VprasanjaController.php
new file mode 100644
index 0000000..c34b1c3
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/VprasanjaController.php
@@ -0,0 +1,944 @@
+<?php
+/***************************************
+ * Description: Tukaj kličemo vse tipe vprašanj, ki so nato v posameznih razredih
+ * Autor: Robert Šmalc
+ * Created date: 29.02.2016
+ **************************************
+ * TIPI VPRAŠANJ:
+ * radio -> tip = 1
+ * checkbox -> tip = 2
+ * select -> tip = 3
+ * text -> tip = 4 // ni vec v uporabi
+ * besedilo* -> tip = 21
+ * label -> tip = 5
+ * multigrid -> tip = 6
+ * multicheckbox -> tip = 16
+ * multitext -> tip = 19
+ * multinumber -> tip = 20
+ * number -> tip = 7
+ * compute -> tip = 22 // samo v naprednejših anketah (ifi ali test anketa)
+ * quota -> tip = 25 // samo v naprednejših anketah (ifi ali test anketa)
+ * datum -> tip = 8
+ * ranking -> tip = 17
+ * vsota -> tip = 18
+ * grid - multiple -> tip = 24
+ * iz knjiznice -> tip = 23 // podtip nam pove za tip vprasanja, ki ga poiscemo glede na variablo
+ * SN-imena -> tip = 9
+ * Map-lokacija -> tip = 26
+ * HeatMap -> tip = 27
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+
+use App\Controllers\Controller;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Controllers\StatisticController as Statistic;
+use App\Controllers\Vprasanja\ComputeController as Compute;
+use App\Controllers\Vprasanja\DatumController as Datum;
+use App\Controllers\Vprasanja\DoubleController as Double;
+use App\Controllers\Vprasanja\DragDropController as DragDrop;
+use App\Controllers\Vprasanja\DynamicController as Dynamic;
+use App\Controllers\Vprasanja\ImenaController as Imena;
+use App\Controllers\Vprasanja\MaxDiffController as MaxDiff;
+use App\Controllers\Vprasanja\MultigridController as Multigrid;
+use App\Controllers\Vprasanja\MultigridMobileController as MultigridMobile;
+use App\Controllers\Vprasanja\NumberController as Number;
+use App\Controllers\Vprasanja\OneAgainstAnotherController as OneAgainstAnother;
+use App\Controllers\Vprasanja\QuotaController as Quota;
+use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
+use App\Controllers\Vprasanja\RankingController as Ranking;
+use App\Controllers\Vprasanja\SystemVariableController as SystemVariable;
+use App\Controllers\Vprasanja\TextController as Text;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Controllers\Vprasanja\VsotaController as Vsota;
+use App\Controllers\Vprasanja\MapsController as Maps;
+use App\Controllers\Vprasanja\ImageHotSpotController as HotSpot;
+use App\Controllers\Vprasanja\HeatMapController as HeatMap;
+use App\Models\Model;
+use Branching;
+use enkaParameters;
+use SurveyInfo;
+use SurveySetting;
+use SurveySlideshow;
+use UserAccess;
+
+
+class VprasanjaController extends Controller
+{
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance) {
+ self::refreshVariables();
+ return self::$_instance;
+ }
+
+ return new VprasanjaController();
+ }
+
+ private function refreshVariables()
+ {
+ return parent::getAllVariables();
+ }
+
+ /**
+ * @desc prikaze spremenljivke v trenutni grupi
+ */
+ public function displaySpremenljivke(){
+
+ if (!get('printPreview')) {
+ // poiscemo vprasanja s prejsnje strani, ki imajo vklopljeno statistiko
+ Statistic::displayStatistika();
+
+ // zgeneriramo sistemske spremenljivke
+ Header::getInstance()->displaySistemske();
+
+ // prikazemo skrita ze odgovorjena vprasanja
+ Vprasanja::getInstance()->displaySpremenljivkeHidden();
+ }
+
+ $offset = 0;
+ $zaporedna = 1;
+
+ if (SurveyInfo::getInstance()->getSurveyCountType() > 0) {
+ // Preštejemo koliko vprašanj je bilo do sedaj
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='" . get('grupa') . "'");
+ $rowg = mysqli_fetch_assoc($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+
+ $sqlCountPast = sisplet_query("SELECT count(*) as cnt FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND g.vrstni_red < '$vrstni_red' ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
+ $rowCount = mysqli_fetch_assoc($sqlCountPast);
+ $offset = $rowCount['cnt'];
+ }
+
+ // poiscemo vprasanja / spremenljivke
+ // če imamo pri posamezni spremenljivki nastavljeno da jo prikazujemo na začetku vsake strani
+ if (get('displayAllPages')) {
+ $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka AS s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='" . get('anketa') . "' ORDER BY g.vrstni_red, s.vrstni_red ASC");
+ }
+ else {
+ // Optimizirano
+ $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka AS s, srv_grupa g WHERE ((s.gru_id='" . get('grupa') . "' AND s.visible='1' AND g.ank_id='" . get('anketa') . "') OR (s.showOnAllPages = '1' AND s.visible='1' AND g.ank_id='" . get('anketa') . "')) AND s.gru_id=g.id ORDER BY g.vrstni_red, s.vrstni_red ASC");
+ }
+
+
+ if(SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter')
+ )
+ $evoli_teammeter = true;
+ else
+ $evoli_teammeter = false;
+
+ while ($row = mysqli_fetch_array($sql)) {
+
+ // Izbira departmenta za modul EVOLI TEAMMETER / evoli_quality_climate / evoli_teamship_meter / evoli_organizational_employeeship_meter na prvi strani
+ if($evoli_teammeter){
+
+ // Ce smo na prvi strani in izpisujemo drugo vprasanje
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='" . get('grupa') . "'");
+ $rowg = mysqli_fetch_assoc($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+ if($zaporedna == 2 && $rowg['vrstni_red'] == 1){
+ // Dobimo id skupine (podjetja) za respondenta
+ $sqlGroupTM = sisplet_query("SELECT d.* FROM srv_data_vrednost_active d, srv_spremenljivka s, srv_grupa g
+ WHERE g.ank_id='" . get('anketa') . "' AND d.usr_id='" . get('usr_id') . "' AND s.skupine='1'
+ AND s.id=d.spr_id AND g.id=s.gru_id");
+ $rowGroupTM = mysqli_fetch_array($sqlGroupTM);
+
+ // Loop cez vse oddelke (departments) za izbrano skupino (podjetje)
+ $sqlTM = sisplet_query("SELECT d.* FROM srv_evoli_teammeter_department d, srv_evoli_teammeter tm WHERE d.tm_id=tm.id AND tm.skupina_id='".$rowGroupTM['vre_id']."'");
+ if(mysqli_num_rows($sqlTM) > 0){
+
+ echo ' <div id="spremenljivka_evoli_tm_department" class="spremenljivka lang_pick">' . "\n";
+
+ // Izbira oddelka z dropdown menijem
+ if(isset($_GET['language']) && $_GET['language'] == '1'){
+ echo ' <p><div class="naslov"><span class="reminder">*</span>Prosimo izberite vašo ekipo, oddelek ali delovno skupino v vaši organizaciji:</div>';
+ echo ' <div class="variable_holder clr"><div class="variabla"><select name="evoli_tm_department" id="evoli_tm_department">';
+
+ echo '<option value="0">Izberite s seznama</option>';
+ while($rowTM = mysqli_fetch_array($sqlTM)){
+ echo '<option value="' . $rowTM['id'] . '">' . $rowTM['department'] . '</option>';
+ }
+
+ echo ' </select></div></div>';
+ echo '</p>' . "\n";
+ }
+ else{
+ echo ' <p><div class="naslov"><span class="reminder">*</span>Please indicate your team, department or working group in your organisation:</div>';
+ echo ' <div class="variable_holder clr"><div class="variabla"><select name="evoli_tm_department" id="evoli_tm_department">';
+
+ echo '<option value="0">Select from dropdown</option>';
+ while($rowTM = mysqli_fetch_array($sqlTM)){
+ echo '<option value="' . $rowTM['id'] . '">' . $rowTM['department'] . '</option>';
+ }
+
+ echo ' </select></div></div>';
+ echo '</p>' . "\n";
+ }
+
+ echo ' </div>' . "\n";
+ }
+ }
+ }
+
+ if ($zaporedna == 1 && get('loop_id') == null) { // preverimo, ce je na tej strani LOOP in redirectamo na prvo vrednost
+
+ $if_id = Find::find_parent_loop($row['id']);
+ if ($if_id > 0) {
+ $sql1 = sisplet_query("SELECT if_id FROM srv_loop WHERE if_id = '$if_id'");
+ $row1 = mysqli_fetch_array($sql1);
+
+ save('loop_id', Find::getInstance()->findNextLoopId($row1['if_id']));
+
+ if (get('loop_id') != null) {
+ $loop_id = '&loop_id=' . get('loop_id');
+ }
+ else {
+ $loop_id = '';
+ save('grupa', Find::getInstance()->findNextGrupa());
+ if (get('grupa') == 0) save('grupa', 'end');
+ }
+
+ header('Location: ' . SurveyInfo::getSurveyLink() . '&grupa=' . get('grupa') . $loop_id . Header::getSurveyParams() . get('cookie_url') . '');
+ return;
+ }
+ }
+
+ //ce gre za glasovanje in smo eno vprasanje ze prikazali, ostalih ne prikazemo
+ if ((SurveyInfo::getInstance()->getSurveyType() != 0) || ($zaporedna == 1))
+ Vprasanja::getInstance()->displaySpremenljivka($row['id'], $offset, $zaporedna);
+
+ $zaporedna++;
+ }
+
+
+ // JS za mobilno razpiranje tabel
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+ if($mobile_tables == 2){
+
+ echo '<script>
+ $(document).ready(
+ function(){
+ mobileMultigridExpandable();
+ }
+ );
+ </script>';
+ }
+
+ // JS za razpiranje tabel znotraj bloka s to nastavitvijo
+ echo '<script>
+ $(document).ready(
+ function(){
+ questionsExpandable();
+ }
+ );
+ </script>';
+
+
+ echo '<script>
+ var comments = init_comments_save();
+
+ // GDPR popup
+ $(".gdpr_popup_trigger").click(function(){ show_gdpr_about(\''.get('lang_id').'\'); });
+ </script>';
+ }
+
+ /**
+ * @desc prikazemo skrita ze odgovorjena vprasanja
+ */
+ public function displaySpremenljivkeHidden()
+ {
+
+ $sqlg = sisplet_query("SELECT vrstni_red FROM srv_grupa WHERE id='" . get('grupa') . "'");
+ $rowg = mysqli_fetch_array($sqlg);
+ $vrstni_red = $rowg['vrstni_red'];
+
+ echo "\n";
+ echo '<!-- hidden -->' . "\n";
+ echo '<div id="spremenljivke_hidden" style="display:none">' . "\n";
+
+ // pri skritih gledamo za nazaj, in ce smo v loopu ne smemo upostevat trenutnega loopa
+ $loop_id = get('loop_id');
+ save('loop_id', null, 1);
+
+ // Izpisemo vprasanja ki so uporabljena v pogoju in so bila resena na prejsnjih straneh oz. tudi na isti strani ce gre za skupine ali jezike
+ $sql = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND (g.vrstni_red<'$vrstni_red' OR (g.vrstni_red='$vrstni_red' AND s.skupine>'0')) ORDER BY g.vrstni_red ASC, s.vrstni_red ASC");
+ while ($row = mysqli_fetch_array($sql)) {
+ if ($this->inCondition($row['id'])) {
+ $this->displaySpremenljivka($row['id']);
+ }
+ }
+
+ save('loop_id', $loop_id, 1);
+
+ echo '</div>' . "\n";
+ echo '<!-- /hidden -->' . "\n\r\n\r";
+
+ }
+
+ /**
+ * @desc prikaze komentar spremenljivke
+ * shrani se v srv_Data_text, kjer je spr_id=0 in vre_id=$spremenljivka
+ */
+ public function displaySpremenljivkaComment($spremenljivka){
+
+ // Preverimo, ce so komentarji v placljivem paketu
+ $userAccess = UserAccess::getInstance(self::$global_user_id);
+ if(!$userAccess->checkUserAccess($what='komentarji'))
+ return;
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $srv_qct = SurveySetting::getInstance()->getSurveyMiscSetting('question_comment_text');
+ $question_resp_comment_show_open = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment_show_open');
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (get('lang_id') != null) $_lang = '_' . get('lang_id'); else $_lang = '';
+ $srv_comment = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_question_respondent_comment' . $_lang);
+ $comment = $srv_comment != '' ? $srv_comment : self::$lang['srv_question_respondent_comment'];
+
+ if (get('lang_id') != null) {
+ $qct = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_question_comment_text_' . get('lang_id'));
+ if ($qct != '') $srv_qct = $qct;
+ }
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $sql = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='0' AND vre_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row = mysqli_fetch_array($sql);
+
+ echo '<div class="comment red" onclick="$(\'#question_resp_comment_' . $spremenljivka . '\').toggle();" >' . $comment . '</div>
+ <div class="variable_holder ' . ($question_resp_comment_show_open == 1 ? 'display_none' : '') . '" id="question_resp_comment_' . $spremenljivka . '">
+ <div class="variabla question_comment">
+ <textarea name="question_comment_' . $spremenljivka . '" id="question_comment_' . $spremenljivka . '">' . $row['text'] . '</textarea>
+ </div>
+ </div>';
+ }
+
+ /**
+ * @desc prikaze spremenljivko
+ */
+ public function displaySpremenljivka($spremenljivka, $offset = 0, $zaporedna = null)
+ {
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $rowl = Language::srv_language_spremenljivka($spremenljivka);
+ if (strip_tags($rowl['naslov']) != '') $row['naslov'] = $rowl['naslov'];
+ if (strip_tags($rowl['info']) != '') $row['info'] = $rowl['info'];
+ if ($rowl['vsota'] != '') $row['vsota'] = $rowl['vsota'];
+
+
+ // da dela tudi userjem brez JS, po defaultu vedno prikazemo vsa vprasanja, ki jih potem skrivamo z JS
+ $display = '';
+
+ // smo v vpogledu in izpisujemo spremenljivko iz loopa
+ $loop_style = (get('loop_id') != null && $_GET['m'] == 'quick_edit') ? ' quick_edit_loop' : '';
+
+ // hidden_default je pri radio buttnu opcija, da je vprasanje skrito, shrani pa se po defaultu prvi odgovor
+
+ if ($row['tip'] == 22 || $row['tip'] == 25 /*|| ($row['tip']==1 && $row['hidden_default']==1)*/) {
+ $display = 'display_none'; // compute ali kvota vprašanje je vedno skrito
+ }
+
+ // Class za tipe ki jih v hitrem urejanju izpisemo v eni vrstici
+ $simple = (!in_array($row['tip'], array(5, 6, 16, 19, 20, 17))) ? ' simple' : '';
+
+ // Class za nagovor - ce ima crto ali ne
+ $nagovor_line = '';
+ if ($row['tip'] == 5) {
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $nagovorLine = ($spremenljivkaParams->get('nagovorLine') ? $spremenljivkaParams->get('nagovorLine') : 0);
+
+ // Brez crte
+ if ($nagovorLine == 1)
+ $nagovor_line = 'hide_border';
+ // S crto
+ elseif ($nagovorLine == 2)
+ $nagovor_line = 'show_border';
+ }
+
+ /*
+ * V kolikor sistemsk spremenljivka je uporabljena v pogoju, potem preverimo, vrednost odgovora sistemske spremenljivke in omenjen odgovor v našem primeru samo nagovor prikažemo
+ */
+ $display_sistemske = '';
+ $sql_if = sisplet_query("SELECT * FROM srv_branching WHERE element_spr='$spremenljivka'");
+ $row_if = mysqli_fetch_object($sql_if);
+ if (!empty($row_if->parent)) {
+ $sql_condition = sisplet_query("SELECT * FROM srv_condition WHERE if_id='$row_if->parent'");
+ $row_condition = mysqli_fetch_object($sql_condition);
+
+ # V kolikor imamo pogoj, potem preverimo, če je pogoj vezan na sistemske in skrite spremenljivke
+ if (!empty($row_condition)) {
+ $sql_spr_sistem = sisplet_query("SELECT id FROM srv_spremenljivka WHERE id='$row_condition->spr_id' AND sistem=1 AND visible=0");
+ if ($sql_spr_sistem->num_rows > 0)
+ $display_sistemske = 'display_none';
+ }
+
+ $sql_condition_vred = sisplet_query("SELECT * FROM srv_condition_vre WHERE cond_id='$row_condition->id'");
+ $row_condition_vred = mysqli_fetch_object($sql_condition_vred);
+
+ //preverimo, še če je bilo to vprašanje odgovorjeno in izbrana vrednost odgovora enaka našemu pogoji pri IF stavku
+ $sql_data_cond = sisplet_query("SELECT * FROM srv_data_vrednost_active WHERE usr_id='" . get('usr_id') . "' AND spr_id='$row_condition->spr_id'");
+ $row_data_cond = mysqli_fetch_object($sql_data_cond);
+
+ if (!empty($row_data_cond->vre_id) && !empty($row_condition_vred->vre_id) && ($row_data_cond->vre_id == $row_condition_vred->vre_id)) {
+ $display_sistemske = '';
+ }
+ }
+
+
+ if ((self::$admin_type <= $row['dostop'] && self::$admin_type >= 0) || (self::$admin_type == -1 && $row['dostop'] == 4)) {
+ // ok
+ } else {
+ $display = 'display_none'; // user iz sispleta nima dostopa do vprasanja
+ return; // ce damo samo display na none, se npr. v IFih spet pokaze vprasanje...
+ }
+
+
+ if (get('forceShowSpremenljivka')) { // za prikaz spremenljivke v analizi in mogoče še kje
+ $display = '';
+ }
+ echo "\n\r\n\r";
+ echo ' <!-- spremenljivka -->' . "\n";
+ echo ' <div id="spremenljivka_' . $spremenljivka . '" class="spremenljivka ' . $simple . ' ' . $nagovor_line . ' tip_' . $row['tip'] . ' ' . $loop_style . ' ' . $display . $display_sistemske . ($row['dostop'] < 4 ? ' limited' : '') . '" data-vrstni_red="' . $row['vrstni_red'] . '">' . "\n";
+
+ // izpis tekstovnega pogoja
+ if (isset($_GET['displayifs']) && $_GET['displayifs'] == '1') {
+ $b = new Branching(get('anketa'));
+ $parents = $b->get_parents($row['id']);
+
+ $parents = explode('p_', $parents);
+ foreach ($parents AS $key => $val) {
+ if (is_numeric(trim($val))) {
+ $parents[$key] = (int)$val;
+ } else {
+ unset($parents[$key]);
+ }
+ }
+
+ echo '<div>';
+ foreach ($parents AS $if) {
+ echo '<p>';
+ $b->conditions_display($if);
+ $b->blocks_display($if);
+ echo '</p>';
+ }
+ echo '</div>';
+ }
+
+ echo ' <input type="hidden" name="visible_' . $spremenljivka . '" id="visible_' . $spremenljivka . '" value="' . ($display == '' || $row['hidden_default'] == 1 ? '1' : '0') . '">' . "\n";
+
+ $oblika = array();
+
+ $oblika['orientation'] = $row['orientation'];
+
+ // pri multigridu ne pustimo spremembe orientacije - spremembe ne pustimo tudi ce je resevalec mobitl
+ if (($row['orientation'] == 0 || $row['orientation'] == 2)
+ && $row['tip'] != 6 && $row['tip'] != 16 && $row['tip'] != 19 && $row['tip'] != 20
+ && get('mobile') == 0
+ ) {
+
+ // ce ni besedilo
+ if($row['tip'] != 21){
+ $oblika['cssFloat'] = ' floatLeft';
+ }
+ // ce je besedilo in postavitev vodoravno ob vprasanju
+ else{
+ $oblika['cssFloat'] = ' besediloObVprasanju';
+ }
+
+ // ce je vodoravno ob vprasanju
+ if ($row['orientation'] == 0) {
+ $oblika['divClear'] = '';
+ }
+ // ce je vodoravno pod vprasanjem
+ else {
+ $oblika['divClear'] = 'clr';
+ $oblika['cssLineBreak'] = '<br>';
+ }
+ }
+ else {
+ $oblika['cssFloat'] = '';
+ $oblika['divClear'] = 'clr';
+ }
+
+ // datapiping
+ $row['naslov'] = Helper::dataPiping($row['naslov']);
+
+ // izpisemo statistiko za radio, checkbox, dropdown in multigrid
+ if ($row['stat'] == 1 && ($row['tip'] <= 3 || $row['tip'] == 6)) {
+ echo ' <div id="stat_' . $spremenljivka . '" class="stat">' . "\n";
+ echo ' </div>' . "\n";
+ }
+
+ // stevilcenje
+ if ((SurveyInfo::getInstance()->getSurveyCountType() > 0 || isset($_GET['displayvariables']) && $_GET['displayvariables'] > 0) && get('forceShowSpremenljivka') == false) {
+ echo '<div class="counter">';
+ if (SurveyInfo::getInstance()->getSurveyCountType() == 1) {
+ echo $zaporedna + $offset . ")&nbsp;";
+ }
+ if (SurveyInfo::getInstance()->getSurveyCountType() == 2 || isset($_GET['displayvariables']) && $_GET['displayvariables'] == 1) {
+ echo strip_tags($row['variable']) . '&nbsp;-&nbsp;';
+ }
+ if (SurveyInfo::getInstance()->getSurveyCountType() == 3) {
+ echo $zaporedna + $offset . ")&nbsp;" . strip_tags($row['variable']) . '&nbsp;-&nbsp;';
+ }
+ echo '</div>';
+ }
+
+
+ echo '<div class="naslov ' . $oblika['cssFloat'] . '">';
+
+ if ($row['reminder'] > 0) // statusi: reminder, in še kaj
+ echo '<span class="reminder">*</span>';
+
+ echo $row['naslov'];
+ if ($row['info'] != '')
+ echo '<p class="spremenljivka_info">' . $row['info'] . '</p>';
+
+ echo '</div>';
+
+ // nagovor nima nicesar
+ if ($row['tip'] != 5) {
+
+ // ce je besedilo in postavitev vodoravno ob vprasanju
+ if($row['tip'] == 21 && $row['orientation'] == 0){
+ echo '<div class="variable_holder besediloObVprasanju ' . $oblika['divClear'] . '" ' . ($row['hidden_default'] == 1 ? 'style="display:none"' : '') . '>';
+ }
+ else{
+ // ce je postavitev vodoravno pod vprasanjem
+ if($row['orientation'] == 2){
+ echo '<div class="variable_holder vodoravno_pod_vprasanjem '.$oblika['divClear'].'" '.($row['hidden_default'] == 1 ? 'style="display:none"' : '').'>';
+ }
+ // ce je postavitev vodoravno ob vprasanju
+ elseif($row['orientation'] == 0){
+ echo '<div class="variable_holder vodoravno_ob_vprasanju '.$oblika['divClear'].'" '.($row['hidden_default'] == 1 ? 'style="display:none"' : '').'>';
+ }
+ else{
+ //echo '<div class="variable_holder '.$oblika['divClear'].'" ' . ($row['hidden_default'] == 1 ? 'style="display:none"' : 'style="display:inline"').'>';
+ echo '<div class="variable_holder '.$oblika['divClear'].'" ' . ($row['hidden_default'] == 1 ? 'style="display:none"' : '').'>';
+ }
+ }
+
+ if ($rowa['mass_insert'] == '1' && $_GET['m'] != 'quick_edit')
+ $this->displayMassVnos($spremenljivka, $oblika);
+ else
+ $this->displayVnos($spremenljivka, $oblika);
+
+ echo '</div>';
+ }
+
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ if (SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment') == 1 &&
+ get('forceShowSpremenljivka') == false &&
+ !$_GET['hidecomment'] == 1 &&
+ ($_GET['preview'] == 'on' && $_GET['testdata'] == 'on')
+ ) {
+ $this->displaySpremenljivkaComment($spremenljivka);
+ }
+
+ $ss = new SurveySlideshow(get('anketa'));
+ $ss_setings = $ss->getSettings();
+
+ // timer na spremenljivki
+ if ($row['timer'] > 0 && $row['gru_id'] == $_GET['grupa']) {
+ echo '<script>' . "\n";
+ echo 'setTimeout(\'submitForm()\', ' . ($row['timer'] * 1000) . ');' . "\n";
+ echo '</script>' . "\n";
+ }
+ else if ((int)$row['timer'] > 0 && SurveyInfo::getInstance()->checkSurveyModule('slideshow')) {
+ echo '<script>' . "\n";
+ # če smo v prezentaciji in imamo nastavljen autostart
+
+ # če smo na prvi strani in mamo nastavljen autostart z timerjem
+ if (!isset($_GET['grupa']) && ($ss_setings['autostart'] == 1 || $ss_setings['autostart'] == 3)) {
+ echo 'setTimeout(\'submitForm()\', ' . ($row['timer'] * 1000) . ');' . "\n";
+ }
+ if (!isset($_GET['grupa']) && ((int)$ss_setings['autostart'] == 2 || (int)$ss_setings['autostart'] == 3)) {
+ echo '$(".spremenljivka").addClass("pointer");' . "\n";
+ # autostart z klikom
+ echo '$(".spremenljivka").live("click", function(event) {submitForm()});' . "\n";
+ }
+ echo ' </script>' . "\n";
+ }
+
+ echo '</div>'; // spremenljivka
+ }
+
+ /**
+ * preveri, ce se spremenljivka pojavi v katerem izmed pogojev, da jo je potrebno izpisati
+ *
+ * @param mixed $spremenljivka
+ */
+ private function inCondition($spremenljivka)
+ {
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_condition WHERE spr_id='$spremenljivka'");
+ $row = mysqli_fetch_array($sql);
+ if ($row['count'] > 0)
+ return true;
+
+ $sql = sisplet_query("SELECT COUNT(*) AS count FROM srv_calculation WHERE spr_id='$spremenljivka'");
+ $row = mysqli_fetch_array($sql);
+ if ($row['count'] > 0)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * prikaze vnos spremenljivke za masovno vnasanje vprasalnika
+ *
+ * @param mixed $spremenljivka
+ * @param mixed $oblika
+ */
+ function displayMassVnos($spremenljivka, $oblika)
+ {
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ switch ($row['tip']) {
+ case 1:
+ case 3:
+ $sql = sisplet_query("SELECT id, vrstni_red FROM srv_vrednost WHERE spr_id='$spremenljivka' AND other='1' ORDER BY vrstni_red ASC");
+ $input = '';
+ $js = '';
+ while ($row = mysqli_fetch_array($sql)) {
+ $input .= ' <input type="text" name="textfield_' . $row['id'] . '" style="display:none" id="textfield_' . $row['id'] . '">';
+ $js .= ' if (this.value == \'' . $row['vrstni_red'] . '\') document.getElementById(\'textfield_' . $row['id'] . '\').style.display = \'inline\'; else document.getElementById(\'textfield_' . $row['id'] . '\').style.display = \'none\'; ';
+ }
+ echo '<input type="text" name="vrednost_' . $spremenljivka . '" onkeyup="checkBranching(); ' . $js . '" id="vrednost_' . $spremenljivka . '">';
+ echo $input;
+ break;
+
+ case 2:
+ $sql = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red ASC");
+ echo '<table>';
+ while ($row = mysqli_fetch_array($sql)) {
+ echo '<tr><td>' . $row['naslov'] . '</td><td><input type="text" name="vrednost_' . $spremenljivka . '[]" onkeyup="checkBranching();" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $row['id'] . '"></td>';
+ if ($row['other'] == 1) echo '<td><input type="text" name="textfield_' . $row['id'] . '"></td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+ break;
+
+ case 6:
+ $sql = sisplet_query("SELECT id, naslov, other FROM srv_vrednost WHERE spr_id='$spremenljivka' ORDER BY vrstni_red ASC");
+ echo '<table>';
+ while ($row = mysqli_fetch_array($sql)) {
+ echo '<tr><td>' . $row['naslov'] . '</td><td><input type="text" name="vrednost_' . $row['id'] . '" onkeyup="checkBranching();" id="spremenljivka_' . $spremenljivka . '_vrednost_' . $row['id'] . '"></td>';
+ if ($row['other'] == 1) echo '<td><input type="text" name="textfield_' . $row['id'] . '"></td>';
+ echo '</tr>';
+ }
+ echo '</table>';
+ break;
+
+ default:
+ $this->displayVnos($spremenljivka, $oblika);
+ break;
+ }
+ }
+
+ /**
+ * @desc prikaze polja za vnos
+ */
+ function displayVnos($spremenljivka, $oblika = null)
+ {
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ // Pridobimo parametre
+ // nalozimo parametre spremenljivke
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ // Izrisemo ustrezno vsebino vprasanja glede na tip
+ switch($row['tip']){
+
+ // Radio, checkbox, dropdown
+ case 1:
+ case 2:
+ case 3:
+
+ if ($row['orientation'] != 8 && $row['orientation'] != 10) {
+ RadioCheckboxSelect::getInstance()->display($spremenljivka, $oblika);
+ }
+ elseif ($row['orientation'] == 8) {
+ if(get('mobile') == 1)
+ RadioCheckboxSelect::getInstance()->display($spremenljivka, $oblika);
+ else
+ DragDrop::getInstance()->display($spremenljivka);
+ }
+ elseif($row['orientation'] == 10){
+ HotSpot::getInstance()->display($spremenljivka);
+ }
+
+ break;
+
+
+ // Tabela - radio
+ case 6:
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // Izris multigrida s postopnim resevanjem
+ if($row['dynamic_mg'] > 0 && !get('printPreview')){
+
+ if ($row['dynamic_mg'] == 1 || $row['dynamic_mg'] == 3 || $row['dynamic_mg'] == 5)
+ Dynamic::getInstance()->multigrid($spremenljivka);
+ else
+ Dynamic::getInstance()->verticalMultigrid($spremenljivka);
+ }
+ // Izris radio multigrida na mobitelu
+ elseif (get('mobile') == 1 && $mobile_tables > 0) {
+
+ // Dvojni multigrid
+ if($row['enota'] == 3)
+ MultigridMobile::getInstance()->radioDoubleMultigrid($spremenljivka);
+ else
+ MultigridMobile::getInstance()->radioMultigrid($spremenljivka);
+ }
+ // Ostali podtipi tabel
+ else{
+
+ // Izris glede na podtip
+ switch($row['enota']){
+
+ // Multigrid z dropdownom
+ case 2:
+ Multigrid::getInstance()->dropdown($spremenljivka);
+ break;
+
+ // Dvojni multigrid
+ case 3:
+ Double::getInstance()->grid($spremenljivka);
+ break;
+
+ // OneAgainstAnother
+ case 4:
+ OneAgainstAnother::getInstance()->display($spremenljivka);
+ break;
+
+ // MaxDiff
+ case 5:
+ MaxDiff::getInstance()->display($spremenljivka);
+ break;
+
+ // SelectBox
+ case 6:
+ Multigrid::getInstance()->selectBox($spremenljivka);
+ break;
+
+ // Grid drag and drop
+ case 9:
+ DragDrop::getInstance()->grid($spremenljivka);
+ break;
+
+ // Image hotspot za radio grid
+ case 10:
+ HotSpot::getInstance()->grid($spremenljivka);
+ break;
+
+ // Navaden multigrid
+ default:
+ Multigrid::getInstance()->display($spremenljivka);
+ break;
+ }
+ }
+
+ break;
+
+
+ // Tabela - checkbox
+ case 16:
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // Izris checkbox multigrida na mobitelu
+ if (get('mobile') == 1 && $mobile_tables > 0) {
+
+ // Dvojni multigrid
+ if($row['enota'] == 3)
+ MultigridMobile::getInstance()->checkboxDoubleMultigrid($spremenljivka);
+ else
+ MultigridMobile::getInstance()->checkboxMultigrid($spremenljivka);
+ }
+ // Izris glede na podtip
+ else{
+ switch($row['enota']){
+
+ // Dvojni multicheckboxa
+ case 3:
+ Double::getInstance()->checkGrid($spremenljivka);
+ break;
+
+ // SelectBox
+ case 6:
+ Multigrid::getInstance()->selectBox($spremenljivka);
+ break;
+
+ // Navaden checkbox
+ case 0:
+ Multigrid::getInstance()->checkbox($spremenljivka);
+ break;
+
+ // Grid drag and drop
+ case 9:
+ DragDrop::getInstance()->grid($spremenljivka);
+ break;
+ }
+ }
+
+ break;
+
+
+ // Tabela - multitext in multinumber
+ case 19:
+ case 20:
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $mobile_tables = SurveySetting::getInstance()->getSurveyMiscSetting('mobile_tables');
+
+ // Izris text in number multigrida na mobitelu
+ if (get('mobile') == 1 && $mobile_tables > 0) {
+ MultigridMobile::getInstance()->textMultigrid($spremenljivka);
+ }
+ // Izris navadnega text in number multigrida
+ else{
+ Text::getInstance()->multitext($spremenljivka);
+ }
+
+ break;
+
+
+ // Multi Tabela
+ case 24:
+ Multigrid::getInstance()->multiple($spremenljivka);
+ break;
+
+
+ // Textbox - tega ni vec... naj zaenkrat se ostane za kaksno staro anketo...
+ case 4:
+
+ echo '<div class="variabla ' . $oblika['cssFloat'] . '">';
+ $sql1 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row1 = mysqli_fetch_array($sql1);
+
+ $taSize = ($spremenljivkaParams->get('taSize') ? $spremenljivkaParams->get('taSize') : 1);
+ $taWidth = ($spremenljivkaParams->get('taWidth') ? $spremenljivkaParams->get('taWidth') : -1);
+ //default sirina
+ if ($taWidth == -1)
+ $taWidth = 30;
+
+ if ($taSize > 1)
+ echo ' <textarea name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" rows="' . $taSize . '" style="width: ' . $taWidth . 'em;" onkeyup="checkBranching();"' . ($selected ? ' disabled' : '') . '>' . $row1['text'] . '</textarea>';
+ else
+ echo ' <input type="text" name="vrednost_' . $spremenljivka . '" id="vrednost_' . $spremenljivka . '" style="width: ' . $taWidth . 'em;" onkeyup="checkBranching();" value="' . $row1['text'] . '" ' . ($selected ? ' disabled' : '') . '>';
+ echo '</div>';
+
+ SystemVariable::getInstance()->display($spremenljivka, $oblika);
+
+ break;
+
+
+ // Textbox
+ case 21:
+ Text::getInstance()->textbox($spremenljivka, $oblika);
+ break;
+
+
+ // Number
+ case 7:
+ Number::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Datum
+ case 8:
+ Datum::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Generator imen (SN)
+ case 9:
+ Imena::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Ranking
+ case 17:
+
+ // Image hotspot ranking
+ if($row['design'] == 3){
+ HotSpot::getInstance()->ranking($spremenljivka, $oblika);
+ }
+ else{
+ Ranking::getInstance()->display($spremenljivka, $oblika);
+ }
+
+ break;
+
+
+ // Vsota
+ case 18:
+ Vsota::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Compute
+ case 22:
+ Compute::getInstance()->display($spremenljivka);
+ break;
+
+
+ // Kvota
+ case 25:
+ Quota::getInstance()->display($spremenljivka);
+ break;
+
+
+ // Maps / lokacija
+ case 26:
+ Maps::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // HeatMap
+ case 27:
+ HeatMap::getInstance()->display($spremenljivka, $oblika);
+ break;
+
+
+ // Nagovor - prazno
+ case 5:
+ default:
+ break;
+ }
+ }
+
+}
diff --git a/main/survey/app/Controllers/Vprasanja/VsotaController.php b/main/survey/app/Controllers/Vprasanja/VsotaController.php
new file mode 100644
index 0000000..ad79de7
--- /dev/null
+++ b/main/survey/app/Controllers/Vprasanja/VsotaController.php
@@ -0,0 +1,112 @@
+<?php
+/***************************************
+ * Description: Vsota
+ *
+ * Vprašanje je prisotno:
+ * tip 18
+ *
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+namespace App\Controllers\Vprasanja;
+
+use App\Controllers\Controller;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\LanguageController as Language;
+use App\Models\Model;
+use enkaParameters;
+
+class VsotaController extends Controller
+{
+
+ public function __construct()
+ {
+ parent::getGlobalVariables();
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ private static $_instance;
+
+ public static function getInstance()
+ {
+
+ if (self::$_instance)
+ return self::$_instance;
+
+ return new VsotaController();
+ }
+
+ public function display($spremenljivka, $oblika)
+ {
+ $row = Model::select_from_srv_spremenljivka($spremenljivka);
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $selected = Model::getOtherValue($spremenljivka);
+
+
+ $order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
+ $sql1 = sisplet_query("SELECT id, naslov, if_id FROM srv_vrednost WHERE spr_id = '$spremenljivka' AND vrstni_red>0 ORDER BY FIELD(vrstni_red, $order)");
+
+ $max = mysqli_num_rows($sql1);
+ $counter = 0;
+ $sum = 0;
+
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ $gridWidth = (($spremenljivkaParams->get('gridWidth') > 0) ? $spremenljivkaParams->get('gridWidth') : 30);
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $naslov = Language::getInstance()->srv_language_vrednost($row1['id']);
+ if ($naslov != '') $row1['naslov'] = $naslov;
+
+ // Datapiping
+ $row1['naslov'] = Helper::dataPiping($row1['naslov']);
+
+ $sql2 = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " WHERE vre_id='$row1[id]' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ $row2 = mysqli_fetch_array($sql2);
+
+ //preverjanje skritega vprasanja(-2)
+ $row2['text'] != -2 ? $text = $row2['text'] : $text = '';
+
+
+ echo '<div class="variabla_sum width_' . $gridWidth . '" id="vrednost_if_' . $row1['id'] . '" ' . ($row1['if_id'] > 0 ? ' style="display:none"' : '') . '>';
+ //echo ' <label for="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '">' . $row1['naslov'] . '</label>';
+ //echo ' <label style="width:200px;display: inline-block;" for="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '">' . $row1['naslov'] . '</label>';
+ echo ' <label class="vsota_besedilo" for="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '">' . $row1['naslov'] . '</label>';
+ echo ' <input type="text" name="spremenljivka_' . $spremenljivka . '_vrednost_' . $row1['id'] . '" id="spremenljivka_' . $spremenljivka . '_sestevanec_' . $counter . '" value="' . $text . '" onkeypress="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . ');" onkeyup="checkNumber(this, ' . $row['cela'] . ', ' . $row['decimalna'] . '); calcSum(' . $spremenljivka . ', ' . $max . ', ' . $row['vsota_limit'] . ');" onBlur="checkBranching();" ' . ($selected ? ' disabled' : '') . '>';
+
+ echo '</div>' . "\n";
+ $counter++;
+ $sum += (double)$text;
+ }
+
+ if ($row['vsota_limit'] != 0 && $row['vsota_limit'] == $row['vsota_min'])
+ $limit = '(' . $row['vsota_min'] . ')';
+ elseif ($row['vsota_limit'] != 0 && $row['vsota_min'] != 0)
+ $limit = '(min ' . $row['vsota_min'] . ', max ' . $row['vsota_limit'] . ')';
+ elseif ($row['vsota_limit'] != 0)
+ $limit = '(max ' . $row['vsota_limit'] . ')';
+ elseif ($row['vsota_min'] != 0)
+ $limit = '(min ' . $row['vsota_min'] . ')';
+
+ $rowl = Language::srv_language_spremenljivka($spremenljivka);
+ if ($rowl['vsota'] != '') $row['vsota'] = $rowl['vsota'];
+ if ($row['vsota'] == '') $row['vsota'] = self::$lang['srv_vsota_text'];
+
+ echo '<div class="variabla_sum width_' . $gridWidth . ' sum" id="vsota_' . $row['id'] . '">';
+ //echo ' <label for="spremenljivka_' . $spremenljivka . '_vsota">' . $row['vsota'] . '</label>';
+ //echo ' <label style="width:200px;display: inline-block;" for="spremenljivka_' . $spremenljivka . '_vsota">' . $row['vsota'] . '</label>';
+ echo ' <label class="vsota_besedilo" for="spremenljivka_' . $spremenljivka . '_vsota">' . $row['vsota'] . '</label>';
+ echo ' <input type="text" name="spremenljivka_' . $spremenljivka . '_vsota_' . $row['id'] . '" id="spremenljivka_' . $spremenljivka . '_vsota" value="' . $sum . '" disabled class="def">';
+ echo '</div>' . "\n";
+
+ if ($row['vsota_show'] == 1)
+ echo ' <label class="limit_vsota">' . $limit . '</label>';
+
+ }
+} \ No newline at end of file
diff --git a/main/survey/app/Models/Model.php b/main/survey/app/Models/Model.php
new file mode 100644
index 0000000..dbeab7e
--- /dev/null
+++ b/main/survey/app/Models/Model.php
@@ -0,0 +1,308 @@
+<?php
+/***************************************
+ * Description: Glavni model, ki skrbi za povezovanje s podatkovno bazo
+ * Autor: Robert Šmalc
+ * Created date: 22.01.2016
+ *****************************************/
+namespace App\Models;
+
+// Iz admin/survey
+use SurveyAdvancedParadataLog;
+
+
+class Model
+{
+
+ /**
+ * @param object $db A PDO database connection
+ */
+ function __construct($db)
+ {
+ try {
+ $this->db = $db;
+ } catch (PDOException $e) {
+ exit('Database connection could not be established.');
+ }
+ }
+
+
+ /**
+ * @desc Vrne vse uporabnike iz baze
+ */
+ public static function db_select_users()
+ {
+ return sisplet_query("SELECT name, surname, id, email FROM users ORDER BY name ASC");
+ }
+
+ /**
+ * @desc Vrne podatke o uporabniku
+ */
+ public static function db_select_user($uid)
+ {
+ return sisplet_query("SELECT name, surname, id, email FROM users WHERE id='$uid'");
+ }
+
+
+ /** Ob spremembi označimo da je potrebno osvežit tabelo s seznamom anket
+ *
+ */
+ public static function setUpdateSurveyList()
+ {
+ # popravimo še polje za osvežitev podatkov seznama anket uporablja class: class.SurveyList.php
+ $updateString = "INSERT DELAYED INTO srv_survey_list (id, updated) VALUES ('" . get('anketa') . "', '1') ON DUPLICATE KEY UPDATE updated='1'";
+
+ $s = sisplet_query($updateString);
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+
+ /**
+ * pobere in zakesira podatke o spremenljivki (ker se to zlo velikokrat bere)
+ *
+ * @param mixed $spremenljivka
+ */
+ public static function select_from_srv_spremenljivka($spremenljivka)
+ {
+ $anketa = get('anketa');
+ $srv_premenljivka = get('select_from_srv_spremenljivka');
+
+ if (array_key_exists($spremenljivka, get('select_from_srv_spremenljivka'))) {
+ return $srv_premenljivka[$spremenljivka];
+ }
+
+ // tole se splaca tam kjer se itak vse spremenljivke preberejo, sam vprasanje, ce se povsod??
+ $sql = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$anketa'");
+ while ($row = mysqli_fetch_array($sql)) {
+ $srv_premenljivka[$row['id']] = save('select_from_srv_spremenljivka[' . $row['id'] . ']', $row, 1);
+ }
+ if (array_key_exists($spremenljivka, get('select_from_srv_spremenljivka'))) {
+ return $srv_premenljivka[$spremenljivka];
+ }
+
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE id = '$spremenljivka'");
+
+ $srv_premenljivka[$spremenljivka] = mysqli_fetch_array($sql);
+
+ return $srv_premenljivka[$spremenljivka];
+
+ }
+
+ public static function generate_order_by_field($spremenljivka, $usr_id = 0)
+ {
+
+ $orderby_array = array();
+ $order = '';
+
+ $randomsort = false;
+
+ $sql1 = sisplet_query("SELECT random, vrstni_red FROM srv_vrednost WHERE spr_id = '$spremenljivka' ORDER BY vrstni_red ASC");
+ while ($row1 = mysqli_fetch_assoc($sql1)) {
+
+ if ($order != '') $order .= ", ";
+
+ // zapecene na tem mestu (oz. normalno sortirane)
+ // pustimo sortiranje po vrstnem redu
+ if ($row1['random'] == 0) {
+ $orderby_array[$row1['vrstni_red']] = $row1['vrstni_red'];
+ $order .= "'" . $row1['vrstni_red'] . "'";
+ }
+ // random sortirane vrednosti
+ elseif ($row1['random'] == 1) {
+
+ $randomsort = true;
+
+ // da se pri vracanju nazaj znova ne randomizirajo odgovori
+ $seed = '';
+ if ($usr_id > 0) {
+ $seed_num = (int)$usr_id + (int)$spremenljivka;
+ mt_srand($seed_num);
+ $seed = mt_rand();
+ }
+
+ // na random izberemo (tiste, ki se random sortirajo) in jih damo na prosto mesto
+ $sql2 = sisplet_query("SELECT vrstni_red FROM srv_vrednost WHERE spr_id='$spremenljivka' AND random='1' ORDER BY RAND(" . $seed . ")");
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ if (!in_array($row2['vrstni_red'], $orderby_array)) {
+ $orderby_array[$row1['vrstni_red']] = $row2['vrstni_red'];
+ $order .= "'" . $row2['vrstni_red'] . "'";
+ break;
+ }
+ }
+ }
+ // Sortiranje po abecedi padajoče ali naraščajoče
+ elseif ($row1['random'] == 2 || $row1['random'] == 3) {
+
+ // mysql default = ASC
+ if ($row1['random'] == 3)
+ $asc_desc = "DESC";
+
+ $sql2 = sisplet_query("SELECT vrstni_red FROM srv_vrednost WHERE spr_id='$spremenljivka' AND (random='2' OR random='3') ORDER BY naslov " . $asc_desc);
+ while ($row2 = mysqli_fetch_assoc($sql2)) {
+ if (!in_array($row2['vrstni_red'], $orderby_array)) {
+ $orderby_array[$row1['vrstni_red']] = $row2['vrstni_red'];
+ $order .= "'" . $row2['vrstni_red'] . "'";
+
+ break;
+ }
+ }
+ }
+
+ // Posebno sortiranje posebej za NIJZ glede na dan v tednu (samo na nijz virtualki)
+ global $site_domain;
+ if(($spremenljivka == '9907732' || $spremenljivka == '9907735' || $spremenljivka == '9921570' || $spremenljivka == '9921573') && $site_domain == 'anketa.nijz.si'){
+
+ $day_of_week = date('w');
+ // Popravimo nedeljo iz 0 na 7
+ if($day_of_week == 0)
+ $day_of_week = 7;
+
+ $order = '';
+ for($i=0; $i<7; $i++){
+
+ $order .= '\'';
+ $order .= ($day_of_week + $i > 7) ? $day_of_week+$i-7 : $day_of_week+$i;
+ $order .= '\', ';
+ }
+
+ $order = substr($order, 0, -2);
+ }
+ }
+
+ if ($order == '') $order = '1';
+
+
+ // Ce nismo v admin vmesniku (preview) ne shranjujemo vrstnega reda
+ if(!isset($_GET['a']) || $_GET['a'] != 'preview_spremenljivka'){
+
+ // Shranimo vrstni red ce imamo random
+ if($randomsort){
+
+ $vrstni_red = str_replace('\'', "", $order);
+ $vrstni_red = str_replace(' ', "", $vrstni_red);
+
+ $sql = sisplet_query("INSERT INTO srv_data_random_spremenljivkaContent
+ (usr_id, spr_id, vrstni_red)
+ VALUES
+ ('".$usr_id."', '".$spremenljivka."', '".$vrstni_red."')
+ ON DUPLICATE KEY UPDATE vrstni_red='".$vrstni_red."'
+ ");
+ if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+ // Napredni parapodatki - belezenje vrstnega reda pri random
+ if (SurveyAdvancedParadataLog::getInstance()->paradataEnabled() && $randomsort){
+
+ $event_type = 'question';
+ $event = 'random_sort';
+
+ $data = array('usr_id' => $usr_id);
+ $data['data'] = array(
+ 'spr_id' => $spremenljivka,
+ 'vre_order' => mysqli_real_escape_string($GLOBALS['connect_db'], $order)
+ );
+
+ SurveyAdvancedParadataLog::getInstance()->logData($event_type, $event, $data);
+ }
+ }
+
+
+ return $order;
+ }
+
+ /**
+ * pri masovnem vnosu, vnasalci vnasajo kot vrednost vrstni_red, ki ga je treba sedaj pretvoriti v ID
+ *
+ * @param mixed $spr_id
+ * @param mixed $vrednost
+ */
+ public static function mass_insert($spr_id, $tip, $vrednost)
+ {
+
+ switch ($tip) {
+ case 1:
+ case 3:
+ $sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spr_id' AND vrstni_red='$vrednost'");
+ $row = mysqli_fetch_array($sql);
+ return $row['id'];
+ break;
+
+ case 2:
+ $i = 1;
+ foreach ($vrednost AS $key => $val) {
+ if ($val == 1) {
+ $sql = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$spr_id' AND vrstni_red='$i'");
+ $row = mysqli_fetch_array($sql);
+ $vrednost[$key] = $row['id'];
+ }
+ $i++;
+ }
+ return $vrednost;
+ break;
+
+ default:
+ return $vrednost;
+ }
+
+ }
+
+ /**
+ * uporabniku pobrise status lurkerja (da je dejansko nekaj vnesel)
+ *
+ */
+ public static function user_not_lurker()
+ {
+
+ // ni vec lurker, vse je ok
+ if (get('lurker') == 0)
+ return '';
+
+ // cache podatkov iz baze
+ if (get('lurker') == -1) {
+ $sql = sisplet_query("SELECT lurker FROM srv_user WHERE id='" . get('usr_id') . "'");
+ $row = mysqli_fetch_array($sql);
+ save('lurker', $row['lurker']);
+ }
+
+ // pobrisemo mu status lurkerja
+ if (get('lurker') == 1) {
+ $sql = sisplet_query("UPDATE srv_user SET lurker='0' WHERE id = '" . get('usr_id') . "'");
+ save('lurker', 0);
+ }
+
+ }
+
+ /**
+ * @desc polovimo vrednost 99,98,97, če jo imamo shranjeno
+ */
+ public static function getOtherValue($spremenljivka)
+ {
+ $getOtherValue = get('getOtherValue');
+
+ if (array_key_exists($spremenljivka, $getOtherValue)) {
+ return $getOtherValue[$spremenljivka];
+ }
+
+ $stringOther = "SELECT vre_id FROM srv_specialdata_vrednost WHERE spr_id='" . $spremenljivka . "' AND usr_id='" . get('usr_id') . "'";
+
+ $sqlOther = sisplet_query($stringOther);
+ $rowOther = mysqli_fetch_assoc($sqlOther);
+
+ return save('getOtherValue[' . $spremenljivka . ']', $rowOther['vre_id'], 1);
+ }
+
+ /**
+ * @desc polovimo vrednost 99,98,97, če jo imamo shranjeno
+ */
+ public static function setOtherValue($spremenljivka, $vrednost = null)
+ {
+ if ($vrednost != null)
+ $sqlInsert = sisplet_query("INSERT INTO srv_specialdata_vrednost (spr_id, vre_id, usr_id) " .
+ "VALUES ('" . $spremenljivka . "', '" . $vrednost . "', '" . get('usr_id') . "') " .
+ "ON DUPLICATE KEY UPDATE vre_id='" . $vrednost . "'");
+ else
+ $sqlDelete = sisplet_query("DELETE from srv_specialdata_vrednost WHERE spr_id = '" . $spremenljivka . "' AND usr_id = '" . get('usr_id') . "'");
+ return mysqli_affected_rows($GLOBALS['connect_db']);
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/Models/SaveSurvey.php b/main/survey/app/Models/SaveSurvey.php
new file mode 100644
index 0000000..be62517
--- /dev/null
+++ b/main/survey/app/Models/SaveSurvey.php
@@ -0,0 +1,1628 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 26.02.2016
+ *****************************************/
+
+namespace App\Models;
+
+
+// Osnovni razredi
+use App\Controllers\CheckController as Check;
+use App\Controllers\Controller;
+use SurveyInfo;
+use SurveySetting;
+use Common;
+use enkaParameters;
+
+// Iz admin/survey
+
+
+// Vprašanja
+
+class SaveSurvey extends Model
+{
+
+ public function __construct()
+ {
+ // Definiramo globalne spremenljivke, ki jih kasneje uporabljamo v funkcijah
+ global $admin_type;
+ global $lang;
+
+ //self::$admin_type = $admin_type;
+ //$this->lang = $lang;
+
+ }
+
+ /************************************************
+ * Get instance
+ ************************************************/
+ protected static $_instance;
+
+ public static function getInstance()
+ {
+ if (self::$_instance) {
+ self::refreshVariables();
+ return self::$_instance;
+ }
+
+ return new SaveSurvey();
+ }
+
+ private function refreshVariables()
+ {
+ return (new Controller())->getGlobalVariables();
+ }
+
+
+ /**
+ * obdela poslano stran in jo shrani v bazo
+ * za (vecino) podatkovnih querijev se podatki kesirajo v zgornje ^ spremenljivke, in se jih naenkrat shrani v bazo v posted_commit()
+ *
+ * @param mixed $preskocena_stran v primeru, da stran preskocimo, to zapisemo v bazo v srv_user_grupa
+ * @param mixed $spr_id podamo v primeru, da shranjujemo samo 1 spremenljivko (in ne celo stran), uporablja se pri urejanju podatkov
+ */
+ public function posted($preskocena = 0, $spr_id = 0){
+ global $lang;
+ global $admin_type;
+
+
+ // Modul panel - status - shranimo v cookie, ker drugace se vcasih ne ohrani do konca ce so strani preskocene
+ if(isset($_POST['panel_status']) && $_POST['panel_status'] != ''){
+ setcookie('panel_status', $_POST['panel_status'], 0, '/');
+ }
+
+ Check::getInstance()->check_captcha();
+
+ # če smo samo v predogledu uporabnika ne shranjujemo
+ if (get('quick_view') == true) {
+ return false;
+ }
+
+ $loop_id = get('loop_id') == null ? "NULL" : "'" . get('loop_id') . "'";
+
+ $rowa = SurveyInfo::getInstance()->getSurveyRow();
+
+ // podatke shranimo v vsakem primeru, ker jih v neaktivni ali predogledu potem na koncu zbrisemo!!!
+
+ // updatamo, ce ne gre za preskoceno stran. pri preskoceni strani, pa updatamo samo prvic
+ if ($preskocena == 0 || get('preskocena_first') == 1) {
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $date = SurveySetting::getInstance()->getSurveyMiscSetting('survey_date');
+
+ if ($date == 0) $_time_insert = "NOW()"; else $_time_insert = "''";
+
+ if (isset($_GET['language'])) save('language', (int)$_GET['language']); else save('language', $lang['id']);
+ // popravimo cas updata
+ $s = sisplet_query("UPDATE srv_user SET time_edit = " . $_time_insert . ", language='" . get('language') . "' WHERE id='" . get('usr_id') . "'");
+ if (!$s) {
+ echo 'err3433' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ // po straneh
+ sisplet_query("REPLACE INTO srv_user_grupa" . get('db_table') . " (gru_id, usr_id, time_edit, preskocena) VALUES ('" . get('grupa') . "', '" . get('usr_id') . "', " . $_time_insert . ", '$preskocena')");
+ if ($preskocena == 1) save('preskocena_first', 0);
+
+ # potrebno bo osvežit seznam anket
+ Model::setUpdateSurveyList();
+ }
+
+ SurveySetting::getInstance()->Init(get('anketa'));
+ $question_resp_comment = SurveySetting::getInstance()->getSurveyMiscSetting('question_resp_comment');
+
+
+ /**
+ * Tele spremenljivke so za vse INSERTe, ki se vnasajo v tabele (z imenom spremenljivke)
+ * Namen je ta, da se vnosi kesirajo in naenkrat vnesejo v bazo, kar pohitri celotno zadevo
+ * V bazo ne shranjuje v tej funkciji, ampak se potem dodatno poklice se posted_commit()
+ */
+ $srv_data_grid = '';
+ $srv_data_vrednost = '';
+ $srv_data_text = '';
+ $srv_data_checkgrid = '';
+ $srv_data_textgrid = '';
+ $srv_data_rating = '';
+ $srv_data_vrednost_cond = '';
+ $srv_data_map = '';
+ $srv_data_heatmap = '';
+
+ if ($preskocena == 1) {
+ $srv_data_grid = get('cache_srv_data_grid');
+ $srv_data_vrednost = get('cache_srv_data_vrednost');
+ $srv_data_text = get('cache_srv_data_text');
+ $srv_data_checkgrid = get('cache_srv_data_checkgrid');
+ $srv_data_textgrid = get('cache_srv_data_textgrid');
+ $srv_data_rating = get('cache_srv_data_rating');
+ $srv_data_vrednost_cond = get('cache_srv_data_vrednost_cond');
+ $srv_data_map = get('cache_srv_data_map');
+ $srv_data_heatmap = get('cache_srv_data_heatmap');
+ }
+
+ // shranjevanje pri hitrem editiranju vnosov - preskocimo vprasanja z uploadom ker drugace zgubimo datoteke
+ if (isset($_GET['m']) && $_GET['m'] == 'quick_edit'){
+ $sql = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g
+ WHERE s.gru_id=g.id AND g.ank_id='" . get('anketa') . "' AND s.visible='1' AND '$admin_type' <= s.dostop
+ AND !(s.tip='21' AND (s.upload='1' OR s.upload='2' OR s.signature='1'))
+ ORDER BY s.vrstni_red ASC");
+ }
+ // shranjevanje vseh spremenljivk na enkrat pri all pages preview-u
+ elseif (get('displayAllPages')) {
+ $sql = sisplet_query("SELECT s.* FROM srv_spremenljivka s, srv_grupa g
+ WHERE s.gru_id=g.id AND g.ank_id='" . get('anketa') . "' AND s.visible='1' AND '$admin_type' <= s.dostop
+ ORDER BY s.vrstni_red ASC");
+ }
+ // normalno shranjevanje
+ elseif ($spr_id == 0){
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka
+ WHERE gru_id='" . get('grupa') . "' AND visible='1' AND '$admin_type' <= dostop
+ ORDER BY vrstni_red ASC");
+ }
+ // shranimo samo 1 spremenljivko (pri popravljanju podatkov v bazi)
+ elseif ($spr_id > 0){
+ $sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE id='$spr_id'");
+ }
+
+ // gremo cez vprasanja v trenutni grupi (strani)
+ while ($row = mysqli_fetch_array($sql)) {
+
+ // vnesemo komentar vprasanja
+ if ($question_resp_comment == 1) {
+ $text = $_POST['question_comment_' . $row['id']];
+ sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE spr_id='0' AND vre_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+ if ($text != '') {
+ if (isset($_POST['inicialke']) && $_POST['inicialke'] != '')
+ $text = '<b>' . $_POST['inicialke'] . '</b> (__DATE__):' . "\n\r" . $text;
+ $s = sisplet_query("INSERT INTO srv_data_text" . get('db_table') . " (spr_id, vre_id, text, usr_id) VALUES ('0', '$row[id]', '$text', '" . get('usr_id') . "')");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+ }
+
+ }
+
+ if (($row['tip'] < 14) || ($row['tip'] > 15)) {
+
+ // pri ratingu ne smemo brisat kadar se shranjuje preko ajaxa
+ if ($row['tip'] != 17
+ || ($row['tip'] == 17 &&
+ ($row['design'] == 1 || $row['design'] == 3 || get('mobile') > 0)
+ )
+ )
+
+ add('cache_delete', $row['id'] . ',');
+ }
+ else {
+
+ save('loop_AW', $_POST['loop_AW']);
+ save('ime_AW', $_POST['ime_AW']);
+
+ if ($row['podpora'] == 1) {
+ $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND ((emotion=1 AND countE<6) OR (emotionINT=1)) ORDER BY countE ");
+ } elseif ($row['podpora'] == 2) {
+ $sql1 = sisplet_query("SELECT * FROM srv_data_imena WHERE usr_id='" . get('usr_id') . "' AND ((social=1 AND countS<6) OR (socialINT=1)) AND ((emotion<1 OR countE>5) AND (emotionINT<1)) ORDER BY countS ");
+ }
+
+ if (get('ime_AW') - 1 != -1)
+ if (mysqli_num_rows($sql1) > 0)
+ mysqli_data_seek($sql1, get('ime_AW') - 1);
+ else
+ if (mysqli_num_rows($sql1) > 0)
+ mysqli_data_seek($sql1, mysqli_num_rows($sql1) - 1);
+
+ $row1 = mysqli_fetch_array($sql1);
+
+ sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "' AND vre_id='$row1[id]'");
+ sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+ sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+ }
+
+
+ // če imamo polja 99,98,97 shranimo te vrednosti ( vrednost_$row[id]_other )
+ if (isset($_POST['other_selected_vrednost_' . $row['id']]) && $_POST['other_selected_vrednost_' . $row['id']] != "")
+ $saved_other = Model::setOtherValue($row['id'], $_POST['other_selected_vrednost_' . $row['id']]);
+ else // pobrišemo morebitne zapise
+ $deleted_other = Model::setOtherValue($row['id'], null);
+
+
+ $hasOthers = $this->savePostedSpecialVars($row);
+ if ($row['tip'] != 5) { // ni nagovor
+
+
+ // radio ali select - dodaten pogoj zaradi spola pri glasovanju, ki ga preverjamo na koncu
+ if (($row['tip'] == 1 || $row['tip'] == 3) && (($rowa['survey_type'] != 0) || ($row['vrstni_red'] == 1))) {
+
+ $vrednost = (isset($_POST['vrednost_' . $row['id']]) ? $_POST['vrednost_' . $row['id']] : null);
+
+ if ($rowa['mass_insert'] == 1 && $_GET['m'] != 'quick_edit' && $_GET['a'] != 'edit_data_question_save') $vrednost = Model::mass_insert($row['id'], $row['tip'], $_POST['vrednost_' . $row['id']]);
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ // ce je drag-drop postavitev (orientation == 8)
+ if ($row['orientation'] == 8 && get('mobile') != 1) {
+ $sql_8 = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+ $row_8 = mysqli_fetch_array($sql_8);
+ $vrednost_8 = $row_8['vre_id'];
+ $srv_data_vrednost .= "('$row[id]', '$vrednost_8', '" . get('usr_id') . "', $loop_id),";
+ }
+
+ if ($vrednost > 0) {
+ $srv_data_vrednost .= "('$row[id]', '$vrednost', '" . get('usr_id') . "', $loop_id),";
+
+ Model::user_not_lurker();
+
+ if ($_POST['textfield_' . $vrednost] != '')
+ $srv_data_text .= "('$row[id]', '$vrednost', '" . $_POST['textfield_' . $vrednost] . "', '', '" . get('usr_id') . "', $loop_id),";
+ }
+ else {
+
+ }
+ }
+ else {
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+
+ // checkbox
+ } elseif ($row['tip'] == 2) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ //ce je drag-drop postavitev (orientation == 8)
+ if ($row['orientation'] == 8 && get('mobile') != 1) {
+
+ $sql_8 = sisplet_query("SELECT vre_id FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+
+ while ($row_8 = mysqli_fetch_array($sql_8)) {
+ $vrednost_8 = $row_8['vre_id'];
+ $srv_data_vrednost .= "('$row[id]', '$vrednost_8', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+
+ if (isset($_POST['vrednost_' . $row['id']])) {
+
+ $vrednost = $_POST['vrednost_' . $row['id']];
+
+ if ($rowa['mass_insert'] == 1 && $_GET['m'] != 'quick_edit' && $_GET['a'] != 'edit_data_question_save') $vrednost = Model::mass_insert($row['id'], $row['tip'], $_POST['vrednost_' . $row['id']]);
+
+ //ce ni drag-drop postavitev (orientation != 8)
+ if ($row['orientation'] != 8 || get('mobile') == 1) {
+ foreach ($vrednost AS $key => $val) {
+ if ($val > 0) {
+ $srv_data_vrednost .= "('$row[id]', '$val', '" . get('usr_id') . "', $loop_id),";
+
+ Model::user_not_lurker();
+
+ if (isset($_POST['textfield_' . $val]) && $_POST['textfield_' . $val] != '')
+ $srv_data_text .= "('$row[id]', '$val', '" . $_POST['textfield_' . $val] . "', '', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+ }
+
+ }
+
+ // če imamo if na vprašanjij, imamo v arrayu vrednosti katere so -2
+ if (isset($_POST['cond_vrednost_' . $row['id']])) {
+ $vrednost = $_POST['cond_vrednost_' . $row['id']];
+ foreach ($vrednost AS $key => $val) {
+ if ($val > 0) {
+ $srv_data_vrednost_cond .= "('$row[id]', '$val', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+ }
+ } else {
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+
+ // multigrid
+ } elseif ($row['tip'] == 6 && $row['enota'] != 3) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $grid_id = $_POST['vrednost_' . $row1['id']];
+
+ // $grid_id > 0
+ if ((string)$grid_id != "") {
+ # grid_id je lahko tudi negativen za missing vrednosti
+ $srv_data_grid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+ }
+ else {
+ // če imamo if na vprašanju, imamo v arrayu vrednosti katere so -2
+ if (isset($_POST['cond_vrednost_' . $row1['id']])) {
+ $srv_data_grid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '-2', $loop_id),";
+ }
+ }
+
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ $srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+
+ //ureditev za drag and drop grid
+ if ($row['enota'] == 9) { //ce je postavitev drag and drop
+ $sql_9 = sisplet_query("SELECT vre_id, grd_id FROM srv_data_grid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+ while ($row_9 = mysqli_fetch_array($sql_9)) {
+ $vrednost_9 = $row_9['vre_id'];
+ $grd_id_9 = $row_9['grd_id'];
+ $srv_data_grid .= "('$row[id]', '$vrednost_9', '" . get('usr_id') . "', $grd_id_9, $loop_id),";
+ }
+ }
+ }
+ else {
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+ //double multigrid
+ } elseif ($row['tip'] == 6 && $row['enota'] == 3) {
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $grid_id = $_POST['vrednost_' . $row1['id']];
+ $grid_id2 = $_POST['vrednost_' . $row1['id'] . '_part_2'];
+
+ if ((string)$grid_id != "") // $grid_id > 0
+ { # grid_id je lahko tudi negativen za missing vrednosti
+ $srv_data_checkgrid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+ }
+ else {
+ }
+
+ if ((string)$grid_id2 != "") // $grid_id2 > 0
+ { # grid_id2 je lahko tudi negativen za missing vrednosti
+ $srv_data_checkgrid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id2', $loop_id),";
+ Model::user_not_lurker();
+ }
+
+ // vsebino text polja vnesemo v vsakem primeru
+ if (isset($_POST['textfield_' . $row1['id']]) && $_POST['textfield_' . $row1['id']] != '') {
+ $srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+
+ } else {
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+
+ // multicheckbox
+ } elseif ($row['tip'] == 16) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
+
+ $sql2 = sisplet_query("SELECT id FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ if (mysqli_num_rows($sql2) > 0)
+ mysqli_data_seek($sql2, 0);
+
+ // Ce imamo select-boxe moramo drugace obdelat podatke
+ if ($row['enota'] == 6) {
+ $vrednost = $_POST['vrednost_' . $row1['id']];
+
+ foreach ($vrednost AS $key => $val) {
+ $srv_data_checkgrid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$val', $loop_id),";
+ Model::user_not_lurker();
+ }
+ } else {
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $grid_id = $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']];
+
+ // $grid_id > 0
+ if ((string)$grid_id != ""){
+ # grid_id je lahko tudi negativen za missing vrednosti
+ $srv_data_checkgrid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+ }
+ else {
+ }
+ }
+ }
+
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ $srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+ //ureditev za drag and drop grid
+ if ($row['enota'] == 9) { //ce je postavitev drag and drop
+ $sql_9 = sisplet_query("SELECT vre_id, grd_id FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id='$row[id]' AND usr_id='" . get('usr_id') . "'");
+ while ($row_9 = mysqli_fetch_array($sql_9)) {
+ $vrednost_9 = $row_9['vre_id'];
+ $grd_id_9 = $row_9['grd_id'];
+ $srv_data_checkgrid .= "('$row[id]', '$vrednost_9', '" . get('usr_id') . "', $grd_id_9, $loop_id),";
+ }
+ }
+
+ } else {
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+ // multitext
+ } elseif ($row['tip'] == 19) {
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
+
+ $sql2 = sisplet_query("SELECT id, other FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ //$sql2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+ if (mysqli_num_rows($sql2) > 0)
+ mysqli_data_seek($sql2, 0);
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $value = $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']];
+ $grid_id = $row2['id'];
+
+ # če mamo missing
+ if ($row2['other'] != 0
+ && isset($_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']])
+ && $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']] != ''
+ ) {
+ $srv_data_grid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+
+ }
+ else if ($value != '') {
+ $srv_data_textgrid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', '$value', $loop_id),";
+ Model::user_not_lurker();
+ }
+ else {
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '-1')");
+ // ta je bil ze prej zakomentiran...
+ }
+
+ }
+
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ $srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+
+ } else {
+
+ // Poseben primer za modul sazu in komentarje na razvrscanje regij
+ if(SurveyInfo::getInstance()->checkSurveyModule('sazu')){
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
+
+ $sql2 = sisplet_query("SELECT id, other FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ if (mysqli_num_rows($sql2) > 0)
+ mysqli_data_seek($sql2, 0);
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $value = $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']];
+ $grid_id = $row2['id'];
+
+ if ($value != '') {
+ $srv_data_textgrid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', '$value', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ $srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+ }
+ else
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+
+ // multinumber
+ } elseif ($row['tip'] == 20) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
+
+ $sql2 = sisplet_query("SELECT id, other FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ //$sql2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+ if (mysqli_num_rows($sql2) > 0)
+ mysqli_data_seek($sql2, 0);
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+ $value = $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']];
+ $grid_id = $row2['id'];
+
+ # če mamo missing
+ if ($row2['other'] != 0
+ && isset($_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']])
+ && $_POST['vrednost_' . $row1['id'] . '_grid_' . $row2['id']] != ''
+ ) {
+ $srv_data_grid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+
+ } else if ($value != '') {
+ Model::user_not_lurker();
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id, text) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$grid_id', '$value')");
+ $srv_data_textgrid .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', '$value', $loop_id),";
+ } else {
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '-1')");
+ // ze prej ...
+ }
+
+ }
+
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
+ $srv_data_text .= "('$row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+
+ }
+
+ } else {
+ //$grid_id = $row2['id'];
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id, text) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$grid_id', '-2')");
+ //$srv_data_textgrid .= "('$row[id]', '$row1[id]', '".get('usr_id')."', '$grid_id', '-2'),";
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+ // multiple grid (kombinirana tabela)
+ } elseif ($row['tip'] == 24) {
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $spr_sql = sisplet_query("SELECT s.id, s.tip, s.enota FROM srv_grid_multiple m, srv_spremenljivka s WHERE m.parent='$row[id]' AND m.spr_id=s.id ORDER BY m.vrstni_red");
+ if (!$spr_sql) echo mysqli_error($GLOBALS['connect_db']);
+ while ($spr_row = mysqli_fetch_array($spr_sql)) {
+
+ add('cache_delete', $spr_row['id'] . ',');
+
+ if ($spr_row['tip'] == 6) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '" . $spr_row['id'] . "'");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ $grid_id = $_POST['multi_' . $spr_row['id'] . '_' . $row1['id']];
+
+ if ((string)$grid_id != "") // $grid_id > 0
+ { # grid_id je lahko tudi negativen za missing vrednosti
+ //sisplet_query("INSERT INTO srv_data_grid".get('db_table')." (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$grid_id')");
+ $srv_data_grid .= "('$spr_row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+ } else {
+ //sisplet_query("INSERT INTO srv_data_grid".get('db_table')." (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '-1')");
+ //$srv_data_grid .= "('$row[id]', '$row1[id]', '".get('usr_id')."', '-1'),";
+ }
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
+ $srv_data_text .= "('$spr_row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+
+ } elseif ($spr_row['tip'] == 16) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spr_row[id]'");
+
+ $sql2 = sisplet_query("SELECT id FROM srv_grid WHERE spr_id = '$spr_row[id]' ORDER BY vrstni_red");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+ //$sql2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+ if (mysqli_num_rows($sql2) > 0)
+ mysqli_data_seek($sql2, 0);
+ // Ce imamo select-boxe moramo drugace obdelat podatke
+ if ($spr_row['enota'] == 6) {
+ $vrednost = $_POST['multi_' . $spr_row['id'] . '_' . $row1['id']]; //name="multi_'.$row_spr['id'].'_'.$row2['id'].'[]"
+ foreach ($vrednost AS $key => $val) {
+ $srv_data_checkgrid .= "('$spr_row[id]', '$row1[id]', '" . get('usr_id') . "', '$val', $loop_id),";
+ Model::user_not_lurker();
+ }
+ } else {
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $grid_id = $_POST['multi_' . $spr_row['id'] . '_' . $row1['id'] . '_grid_' . $row2['id']];
+ if ((string)$grid_id != "") // $grid_id > 0
+ { # grid_id je lahko tudi negativen za missing vrednosti
+ //sisplet_query("INSERT INTO srv_data_checkgrid (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$grid_id')");
+ $srv_data_checkgrid .= "('$spr_row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+ } else {
+ //sisplet_query("INSERT INTO srv_data_checkgrid (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '-1')");
+ // ta je bil ze prej zakomentiran..
+ }
+ }
+ }
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
+ $srv_data_text .= "('$spr_row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+
+ } elseif ($spr_row['tip'] == 19) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spr_row[id]'");
+
+ $sql2 = sisplet_query("SELECT id, other FROM srv_grid WHERE spr_id = '$spr_row[id]' ORDER BY vrstni_red");
+ if (!$sql2) echo mysqli_error($GLOBALS['connect_db']);
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ //$sql2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+ if (mysqli_num_rows($sql2) > 0)
+ mysqli_data_seek($sql2, 0);
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $value = $_POST['multi_' . $spr_row['id'] . '_' . $row1['id'] . '_grid_' . $row2['id']];
+ $grid_id = $row2['id'];
+
+ # če mamo missing
+ if ($row2['other'] != 0
+ && isset($_POST['multi_' . $spr_row['id'] . '_' . $row1['id'] . '_grid_' . $row2['id']])
+ && $_POST['multi_' . $spr_row['id'] . '_' . $row1['id'] . '_grid_' . $row2['id']] != ''
+ ) {
+ $srv_data_grid .= "('$spr_row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+
+ } else if ($value != '') {
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id, text) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$grid_id', '$value')");
+ $srv_data_textgrid .= "('$spr_row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', '$value', $loop_id),";
+ Model::user_not_lurker();
+ } else {
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '-1')");
+ // ta je bil ze prej zakomentiran...
+ }
+
+ }
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
+ $srv_data_text .= "('$spr_row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+
+ } elseif ($spr_row['tip'] == 20) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$spr_row[id]'");
+
+ $sql2 = sisplet_query("SELECT id, other FROM srv_grid WHERE spr_id = '$spr_row[id]' ORDER BY vrstni_red");
+
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ //$sql2 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$row[id]' ORDER BY vrstni_red");
+ if (mysqli_num_rows($sql2) > 0)
+ mysqli_data_seek($sql2, 0);
+
+ while ($row2 = mysqli_fetch_array($sql2)) {
+
+ $value = $_POST['multi_' . $spr_row['id'] . '_' . $row1['id'] . '_grid_' . $row2['id']];
+ $grid_id = $row2['id'];
+
+ # če mamo missing
+ if ($row2['other'] != 0
+ && isset($_POST['multi_' . $spr_row['id'] . '_' . $row1['id'] . '_grid_' . $row2['id']])
+ && $_POST['multi_' . $spr_row['id'] . '_' . $row1['id'] . '_grid_' . $row2['id']] != ''
+ ) {
+ $srv_data_grid .= "('$spr_row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', $loop_id),";
+ Model::user_not_lurker();
+
+ } else if ($value != '') {
+ Model::user_not_lurker();
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id, text) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$grid_id', '$value')");
+ $srv_data_textgrid .= "('$spr_row[id]', '$row1[id]', '" . get('usr_id') . "', '$grid_id', '$value', $loop_id),";
+ } else {
+ //sisplet_query("INSERT INTO srv_data_textgrid (spr_id, vre_id, usr_id, grd_id) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '-1')");
+ // ze prej ...
+ }
+
+ }
+
+ // vsebino text polja vnesemo v vsakem primeru
+ if ($_POST['textfield_' . $row1['id']] != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '".$_POST['textfield_'.$row1['id']]."', '".get('usr_id')."')");
+ $srv_data_text .= "('$spr_row[id]', '$row1[id]', '" . $_POST['textfield_' . $row1['id']] . "', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+
+ }
+
+ }
+
+ }
+
+ } else {
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+ // textbox
+ } elseif ($row['tip'] == 4) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+ $vrednost = $_POST['vrednost_' . $row['id']];
+ if ($vrednost != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, text, usr_id) VALUES ('$row[id]', '$vrednost', '".get('usr_id')."')");
+ $srv_data_text .= "('$row[id]', '', '$vrednost', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ } else {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-1', '".get('usr_id')."')");
+ //$srv_data_vrednost .= "('$row[id]', '-1', '".get('usr_id')."'),";
+ }
+ } else {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-2', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+
+
+ }
+ // TEXTBOX
+ elseif ($row['tip'] == 21) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $empty = true;
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]'");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ // posebej pohendlamo upload datotek ali fotografijo, ce je respondent uporoabil navadni upload slike
+ if ($row['upload'] == 1 || ($row['upload'] == 2 && !$_POST['foto_vrednost_' . $row['id'] . '_kos_' . $row1['id']])) {
+
+ $path_parts = pathinfo($_FILES['vrednost_' . $row['id'] . '_kos_' . $row1['id']]["name"]);
+ $ext = $path_parts['extension'];
+ $name = substr($path_parts['filename'], 0, 25);
+
+ $file_allowed = true;
+
+ // Preverimo ce je file type dovoljen (prava koncnica)
+ if( !in_array(strtolower($ext), array("jpeg", "jpg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx")) ){
+ $file_allowed = false;
+ }
+
+ // Preverimo ce je file velikost ok
+ if( (int)(filesize($_FILES['vrednost_' . $row['id'] . '_kos_' . $row1['id']]["tmp_name"]) / 1024 / 1024) > 16 ){
+ $file_allowed = false;
+ }
+
+ // Ce imamo izbran file in je ok koncnica in velikost
+ if (strlen($name) > 0 && $file_allowed) {
+ $filename = get('usr_id') . '_' . $name . '.' . $ext;
+
+ move_uploaded_file($_FILES['vrednost_' . $row['id'] . '_kos_' . $row1['id']]["tmp_name"], 'uploads/' . $filename);
+ $vrednost = uniqid();
+
+ //pri fotografiji naredi tukaj da zbrise iz mape uploads morebitno prejsnjo sliko narejeno z webcam (lahko, da sta razlicna exstensiona in se ne povozi)
+ sisplet_query("INSERT INTO srv_data_upload (ank_id, usr_id, code, filename) VALUES ('" . get('anketa') . "', '" . get('usr_id') . "', '$vrednost', '$filename')");
+ }
+ // Ni bil nalozen noben file
+ else {
+ $vrednost = '';
+ }
+
+ }
+ elseif($row['upload'] == 2){
+ $encoded_data = $_POST['foto_vrednost_' . $row['id'] . '_kos_' . $row1['id']];
+
+ if($encoded_data != ''){
+ $binary_data = base64_decode( $encoded_data );
+
+ $filename = get('usr_id') . '_' . $row['id'] . '_' . get('anketa') . '.jpg';
+
+ // save to server (beware of permissions)
+ $result = file_put_contents( 'uploads/' . $filename, $binary_data );
+ if (!$result){
+ die("Could not save image! Check file permissions.");
+ }
+ else{
+ $vrednost = uniqid();
+
+ sisplet_query("INSERT INTO srv_data_upload (ank_id, usr_id, code, filename) VALUES ('" . get('anketa') . "', '" . get('usr_id') . "', '$vrednost', '$filename')");
+ }
+ }
+ //ni bilo datoteke
+ else {
+ $vrednost = '';
+ }
+ }
+ // posebej pohendlamo signature - shranjevanje slike
+ elseif ($row['signature'] == 1) {
+
+ //if (isset($_POST['signature-data_spremenljivka_'.$row['id']])){ // če so prišli podatki, nadaljuj
+ if ($_POST['signature-data_spremenljivka_' . $row['id']] != "" || $_POST['vrednost_' . $row['id'] . '_kos_' . $row1['id']] != "") { // če so prišli podatki o podpisu ali o imenu v polju
+
+ $podatki_slika = $_POST['signature-data_spremenljivka_' . $row['id']]; //podatki za generiranje slike
+ $vrednost = $_POST['vrednost_' . $row['id'] . '_kos_' . $row1['id']]; //vnešeno besedilo v input polje Podpis osebe
+ $signature_name = $vrednost;
+
+ $vrednost_signature = $row['id']; //vrednost, ki se beleži v bazi kot spr_id
+
+ $sqlIsFilename = sisplet_query("SELECT filename FROM srv_data_upload WHERE usr_id = '" . get('usr_id') . "' AND ank_id = '" . get('anketa') . "' AND code = '" . $row['id'] . "' ");
+
+ $rowSqlIsFilename = mysqli_fetch_array($sqlIsFilename);
+
+ if (mysqli_num_rows($sqlIsFilename) == 0) { //ce ni nicesar v bazi, ustvari datoteko s sliko in vpisi informacijo v bazo
+ //odstranitev sumnikov in presledkov iz vnesenega imena podpisanega za shranjevanje datoteke
+ $posebni_znaki = array("č", "ć", "ž", "š", "đ", "Č", "Ć", "Ž", "Š", "Đ");
+ $navadni_znaki = array("c", "c", "z", "s", "d", "C", "C", "Z", "S", "D");
+ $signature_name = str_replace($posebni_znaki, $navadni_znaki, $signature_name); //replace posebnih znakov (tako, ime datoteke ne bo sporno)
+ $signature_name = str_replace(" ", "_", $signature_name); //replace presledka
+
+ $data_pieces = explode(",", $podatki_slika);
+ $encoded_image = $data_pieces[1];
+ $decoded_image = base64_decode($encoded_image);
+ $data = $decoded_image;
+ $im = imagecreatefromstring($data);
+ if ($im !== false) {
+ imagesavealpha($im, true); //da reši črno sliko
+ imagepng($im, './uploads/' . get('usr_id') . '_' . $row['id'] . '_' . get('anketa') . '.png'); //ustvarjeno sliko prenesi v mapo, kjer se nahajajo tudi upload datoteke
+ imagedestroy($im);
+ } else {
+ echo 'An error occurred.';
+ }
+
+ //vpisi v bazo, v tabelo, kjer se vpisujejo datoteke, ki se uploadajo, podatke o generirani sliki podpisa
+ $filename_signature = get('usr_id') . '_' . $row['id'] . '_' . get('anketa') . '.png';
+
+ sisplet_query("INSERT INTO srv_data_upload (ank_id, usr_id, code, filename) VALUES ('" . get('anketa') . "', '" . get('usr_id') . "', '$vrednost_signature', '$filename_signature')");
+
+ }
+ }
+ else {
+ $vrednost = '';
+ }
+ }
+ else {
+ $vrednost = $_POST['vrednost_' . $row['id'] . '_kos_' . $row1['id']];
+ }
+
+ if ($vrednost != '') {
+ $srv_data_text .= "('$row[id]', '$row1[id]', '$vrednost', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ $empty = false;
+ }
+ }
+
+ if ($empty) {
+ if (isset($_POST['vrednost_mv_' . $row['id']])) {
+ $srv_data_vrednost .= "('$row[id]', '" . $_POST['vrednost_mv_' . $row['id']][0] . "', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+
+ if ($row['variable'] == 'email' && $row['sistem'] == '1') {
+ if (trim($vrednost) != '' && (int)$rowa['email_to_list'] == 1) {
+ User::addUserEmailToList(trim($vrednost));
+ }
+
+ # sinhroniziramo spremembo emaila z vabili.
+ User::sinhronizeInvitationEmail($vrednost);
+ }
+
+ }
+ else {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-2', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+ // NUMBER
+ elseif ($row['tip'] == 7) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $empty = true;
+
+ $i = 1;
+ if (isset($_POST['vrednost_' . $row['id']])) {
+ $vrednost = $_POST['vrednost_' . $row['id']];
+
+ $text = '';
+ $text2 = '';
+
+ foreach ($vrednost AS $key => $val) {
+ if ($i == 1) {
+ if ($val != '' && $val != '-') {
+ $text = $val;
+ $empty = false;
+
+ Model::user_not_lurker();
+ }
+ else {
+ }
+
+ } else {
+
+ if ($val != '' && $val != '-') {
+ $text2 = $val;
+ $empty = false;
+
+ Model::user_not_lurker();
+ }
+ else {
+ }
+ }
+
+ $i++;
+ }
+
+ }
+
+ if (!$empty) {
+ $srv_data_text .= "('$row[id]', '', '$text', '$text2', '" . get('usr_id') . "', $loop_id),";
+ } else {
+ if (isset($_POST['vrednost_mv_' . $row['id']])) {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-2', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '" . $_POST['vrednost_mv_' . $row['id']][0] . "', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+
+ } else {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-2', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+
+ // compute
+ } elseif ($row['tip'] == 22) {
+
+ if (isset($_POST['vrednost_' . $row['id']])) {
+
+ $val = $_POST['vrednost_' . $row['id']];
+
+ //if ($val == 'NaN') $val = '-1'; // ce je kateri od odgovorov missing, je tudi kalkulacija missing
+ if ($val == 'NaN') $val = '-88'; // ce je kateri od odgovorov missing, je tudi kalkulacija missing
+
+ if ($val != '') {
+ $srv_data_text .= "('$row[id]', '', '$val', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ else {
+ }
+ }
+
+ // kvota
+ } elseif ($row['tip'] == 25) {
+
+ if (isset($_POST['vrednost_' . $row['id']])) {
+
+ $val = $_POST['vrednost_' . $row['id']];
+
+ if ($val == 'NaN') $val = '-1'; // ce je kateri od odgovorov missing, je tudi kvota missing
+
+ if ($val != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, text, usr_id) VALUES ('$row[id]', '$val', '".get('usr_id')."')");
+ $srv_data_text .= "('$row[id]', '', '$val', '', '" . get('usr_id') . "', $loop_id),";
+
+ Model::user_not_lurker();
+ }
+ else {
+ }
+ }
+
+ // 8_datum
+ } elseif ($row['tip'] == 8) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+ if (isset($_POST['vrednost_mv_' . $row['id']]) && count($_POST['vrednost_mv_' . $row['id']]) > 0) {
+ $srv_data_vrednost .= "('$row[id]', '" . $_POST['vrednost_mv_' . $row['id']][0] . "', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ } else {
+
+ $vrednost = $_POST['vrednost_' . $row['id']];
+ if ($vrednost != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, text, usr_id) VALUES ('$row[id]', '$vrednost', '".get('usr_id')."')");
+ $srv_data_text .= "('$row[id]', '', '$vrednost', '', '" . get('usr_id') . "', $loop_id),";
+
+ Model::user_not_lurker();
+ }
+ else {
+ }
+ }
+ } else {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-2', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+ // ranking
+ } elseif ($row['tip'] == 17) {
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ // cifre - ostevilcevanje
+ if ($row['design'] == 1 || get('mobile') > 0) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]' AND vrstni_red>0 ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ if (isset($_POST['spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id']])) {
+ $vrednost = $_POST['spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id']];
+ if ($vrednost != '') {
+ //sisplet_query("REPLACE INTO srv_data_rating (spr_id, vre_id, usr_id, vrstni_red) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$vrednost')");
+ $srv_data_rating .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$vrednost', $loop_id),";
+ Model::user_not_lurker();
+ } else {
+ //sisplet_query("DELETE FROM srv_data_rating WHERE vre_id='$row1[id]' AND usr_id='".get('usr_id')."'");
+ }
+ }
+ }
+ }
+ // n==k (sortable)
+ else if ($row['design'] == 2) {
+ // shranjuje preko ajaxa
+ }
+ // n>k
+ else if ($row['design'] == 0) {
+ // shranjuje preko ajaxa
+ }
+ // ranking image hotspot
+ else if ($row['design'] == 3) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]' AND vrstni_red>0 ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ if (isset($_POST['spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id']])) {
+ $vrednost = $_POST['spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id']];
+ if ($vrednost != '') {
+ //sisplet_query("REPLACE INTO srv_data_rating (spr_id, vre_id, usr_id, vrstni_red) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$vrednost')");
+ $srv_data_rating .= "('$row[id]', '$row1[id]', '" . get('usr_id') . "', '$vrednost', $loop_id),";
+ Model::user_not_lurker();
+ } else {
+ //sisplet_query("DELETE FROM srv_data_rating WHERE vre_id='$row1[id]' AND usr_id='".get('usr_id')."'");
+ }
+ }
+ }
+ }
+ }
+ else {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-2', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+
+ // vsota
+ } elseif ($row['tip'] == 18) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]' AND vrstni_red>0 ORDER BY vrstni_red");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ if (isset($_POST['spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id']])) {
+
+ $vrednost = $_POST['spremenljivka_' . $row['id'] . '_vrednost_' . $row1['id']];
+ if ($vrednost != '') {
+ //$s = sisplet_query("REPLACE INTO srv_data_text (spr_id, vre_id, usr_id, text) VALUES ('$row[id]', '$row1[id]', '".get('usr_id')."', '$vrednost')");
+ $srv_data_text .= "('$row[id]', '$row1[id]', '$vrednost', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ }
+ }
+ }
+
+ } else {
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+ } //imena
+ elseif ($row['tip'] == 9) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ $empty = true;
+
+ $sql1 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row[id]' ORDER BY vrstni_red ASC");
+
+ $vrednost = $_POST['spremenljivka_' . $row['id']];
+
+ // ce imamo 1 textarea dobimo 1 string, ki ga moremo razbit na posamezna imena (locena z entri)
+ if ($row['design'] == 2) {
+ $vrednost = preg_replace('!(\r?\n){2,}!', '\r\n', $vrednost);
+ $vrednost = explode('\r\n', $vrednost);
+ }
+
+ foreach ($vrednost AS $key => $val) {
+
+ $row1 = mysqli_fetch_array($sql1);
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id2]', '$row1[id]', 'aaa', '".get('usr_id')."')");
+
+ if ($val != '') {
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$row1[id]', '$val', '".get('usr_id')."')");
+ $srv_data_text .= "('$row[id]', '$row1[id]', '$val', '', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ $empty = false;
+ }
+ }
+
+ if ($empty) {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-1', '".get('usr_id')."')");
+ //$srv_data_vrednost .= "('$row[id]', '-1', '".get('usr_id')."'),";
+ }
+
+ } else {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '-2', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+
+ } //Map - Lokacija
+ elseif ($row['tip'] == 26) {
+ //get type of map - 1=my location, 2=multilocation
+ $enota = $row['enota'];
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+
+ //get input type - marker, polyline, polygon
+ $spremenljivkaParams = new enkaParameters($row['params']);
+
+ $input = $spremenljivkaParams->get('multi_input_type');
+
+ foreach ($_POST['vrednost_' . $row['id']] AS $key => $val) {
+
+ $data = explode("|", $val);
+
+ //izberi lokacijo
+ if($enota == 3){
+ $je_odgovoril = (isset($_POST[$data[0] . '_text']) && $_POST[$data[0] . '_text'] != '');
+ $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, $data[0], ". get('anketa') . ", '', '', '', '".
+ ($je_odgovoril ? $_POST[$data[0] . '_text'] : '-1')."', ''),";
+ if($je_odgovoril)
+ Model::user_not_lurker();
+ }
+ else{
+ //linija ali poligon
+ if($enota == 2 && $input != 'marker'){
+ $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '', '', '$data[0]'),";
+ }
+ //marker
+ else{
+ //nastavi odgovor na podvprasanje
+ if(isset($_POST[$data[0] . '_text']))
+ $marker_text = $_POST[$data[0] . '_text'] != '' ? $_POST[$data[0] . '_text'] : '-1';
+ else
+ $marker_text = '-4';
+
+ $srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '$data[3]', '".
+ $marker_text."', ''),";
+ }
+ Model::user_not_lurker();
+ }
+ }
+ }
+ else {
+ //sisplet_query("INSERT INTO srv_data_map (usr_id, spr_id, loop_id, ank_id, lat, lng, address, text) "
+ // . "VALUES (" . get('usr_id') . ", '$row[id]', $loop_id, ". get('anketa') . ", '-2', '-2', '-2', '-2')");
+ //if($enota == 3)
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ //else
+ //$srv_data_map .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '-2', '-2', '-2', '-2', ''),";
+ }
+ } //HeatMap
+ elseif ($row['tip'] == 27) {
+
+ if ($_POST['visible_' . $row['id']] == 1) {
+ //za koordinate
+ foreach ($_POST['vrednost_' . $row['id']] AS $key => $val) {
+
+ $data = explode("|", $val);
+
+ $srv_data_heatmap .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '$data[1]', '$data[2]', '$data[3]', '".
+ (isset($_POST[$data[0] . '_text']) ? $_POST[$data[0] . '_text'] : '-2')."', ''),";
+ Model::user_not_lurker();
+ $empty = false;
+ }//za koordinate - konec
+
+ //za checkbox
+ foreach ($_POST['vrednostHeatmap_' . $row['id']] AS $key => $val) {
+
+ if ($val > 0) {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '$val', '".get('usr_id')."')");
+ $srv_data_vrednost .= "('$row[id]', '$val', '" . get('usr_id') . "', $loop_id),";
+ Model::user_not_lurker();
+ if (isset($_POST['textfield_' . $val]) && $_POST['textfield_' . $val] != '')
+ //sisplet_query("INSERT INTO srv_data_text (spr_id, vre_id, text, usr_id) VALUES ('$row[id]', '$val', '".$_POST['textfield_'.$val]."', '".get('usr_id')."')");
+ $srv_data_text .= "('$row[id]', '$val', '" . $_POST['textfield_' . $val] . "', '', '" . get('usr_id') . "', $loop_id),";
+ }
+ }//za checkbox - konec
+
+ // če imamo if na vprašanjij, imamo v arrayu vrednosti katere so -2
+ if (isset($_POST['cond_vrednost_' . $row['id']])) {
+ $vrednost = $_POST['cond_vrednost_' . $row['id']];
+ foreach ($vrednost AS $key => $val) {
+ if ($val > 0) {
+ //sisplet_query("INSERT INTO srv_data_vrednost".get('db_table')." (spr_id, vre_id, usr_id) VALUES ('$row[id]', '$val', '".get('usr_id')."')");
+ $srv_data_vrednost_cond .= "('$row[id]', '$val', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+ }
+ }
+ else {
+ //sisplet_query("INSERT INTO srv_data_map (usr_id, spr_id, loop_id, ank_id, lat, lng, address, text) "
+ // . "VALUES (" . get('usr_id') . ", '$row[id]', $loop_id, ". get('anketa') . ", '-2', '-2', '-2', '-2')");
+ $srv_data_heatmap .= "(" . get('usr_id') . ", '$row[id]', $loop_id, NULL, ". get('anketa') . ", '-2', '-2', '-2', '-2', ''),";
+ $srv_data_vrednost .= "('$row[id]', '-2', '" . get('usr_id') . "', $loop_id),";
+ }
+ }
+ }
+
+ } // -- while
+
+ //na koncu preverimo dodatna vprasanja pri glasovanju (spol)
+ if ($rowa['survey_type'] == 0) {
+
+ if (mysqli_num_rows($sql) > 0)
+ mysqli_data_seek($sql, 0);
+ $row = mysqli_fetch_array($sql);
+
+ $sqlG = sisplet_query("SELECT spol FROM srv_glasovanje WHERE spr_id = '$row[id]'");
+ $rowG = mysqli_fetch_array($sqlG);
+
+ $sql4 = sisplet_query("SELECT id FROM srv_spremenljivka WHERE vrstni_red='2' AND gru_id='$row[gru_id]' ");
+ $row4 = mysqli_fetch_array($sql4);
+
+ //ce je nastavljena nastavitev za vprasanje o spolu
+ if ($rowG['spol'] == 1) {
+ $spol = $_POST['submit'];
+ if ($spol == "Moški") {
+ $vrednost = 1;
+
+ $sql5 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row4[id]' AND vrstni_red='1' ");
+ $row5 = mysqli_fetch_array($sql5);
+ } elseif ($spol == "Ženska") {
+ $vrednost = 2;
+
+ $sql5 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id='$row4[id]' AND vrstni_red='2' ");
+ $row5 = mysqli_fetch_array($sql5);
+ } else
+ $vrednost = 0;
+
+ if ($vrednost > 0) {
+ sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$row4[id]', '$row5[id]', '" . get('usr_id') . "')");
+ sisplet_query("INSERT INTO srv_data_glasovanje (spr_id, usr_id, spol) VALUES ('$row[id]', '" . get('usr_id') . "', '$vrednost')");
+
+ Model::user_not_lurker();
+ } else {
+ //sisplet_query("INSERT INTO srv_data_glasovanje (spr_id, usr_id, spol) VALUES ('$row[id]', '".get('usr_id')."', '-1')");
+ }
+ }
+ }
+
+ // Za evoli teammeter moramo na prvi strani posebej shraniti department
+ if( (SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter')
+ || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter')
+ )
+ && isset($_POST['evoli_tm_department'])
+ ){
+
+ $sqlTMD = sisplet_query("SELECT * FROM srv_evoli_teammeter_data_department WHERE usr_id='".get('usr_id')."'");
+
+ if(mysqli_num_rows($sqlTMD) == 0)
+ sisplet_query("INSERT INTO srv_evoli_teammeter_data_department (department_id, usr_id) VALUES ('".$_POST['evoli_tm_department']."', '".get('usr_id')."')");
+ else
+ sisplet_query("UPDATE srv_evoli_teammeter_data_department SET department_id='".$_POST['evoli_tm_department']."' WHERE usr_id='".get('usr_id')."'");
+ }
+
+
+ save('cache_srv_data_grid', $srv_data_grid);
+ save('cache_srv_data_vrednost', $srv_data_vrednost);
+ save('cache_srv_data_text', $srv_data_text);
+ save('cache_srv_data_checkgrid', $srv_data_checkgrid);
+ save('cache_srv_data_textgrid', $srv_data_textgrid);
+ save('cache_srv_data_rating', $srv_data_rating);
+ save('cache_srv_data_vrednost_cond', $srv_data_vrednost_cond);
+ save('cache_srv_data_map', $srv_data_map);
+ save('cache_srv_data_heatmap', $srv_data_heatmap);
+
+ // ce ni preskocena stran, dodamo v bazo (pri preskoceni bomo dodal posebej in kasnej)
+ if ($preskocena == 0)
+ $this->posted_commit();
+
+ // pri preskoceni strani podatke shranimo z posted_commit(), ki se klice izven te funkcije, kjer loopamo cez strani
+ }
+
+ /**
+ * v funkciji posted() nastavimo cache spremenljivke, ki jih sedaj vse naenkrat shranimo v bazo
+ * pri preskoku strani kasneje posebej shranimo podatke v bazo (optimizacija, da se ne shranjujejo vsakic sproti v zanki)
+ *
+ */
+ public function posted_commit()
+ {
+ //sisplet_query("COMMIT");
+ # če smo samo v predogledu uporabnika ne shranjujemo
+ if (get('quick_view') == true) {
+ return false;
+ }
+
+
+ $loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
+
+ // odrezemo zadnjo vejico, ker smo jo dodajali kar povsod
+ $delete = substr(get('cache_delete'), 0, -1);
+
+ if ($delete != '') {
+ $s = sisplet_query("DELETE FROM srv_data_grid" . get('db_table') . " WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err01: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ $s = sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err02: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ $s = sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err03: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ $s = sisplet_query("DELETE FROM srv_data_checkgrid" . get('db_table') . " WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err04: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ $s = sisplet_query("DELETE FROM srv_data_textgrid" . get('db_table') . " WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err05: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ $s = sisplet_query("DELETE FROM srv_data_rating WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err06: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ $s = sisplet_query("DELETE FROM srv_data_map WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err07: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ $s = sisplet_query("DELETE FROM srv_data_heatmap WHERE spr_id IN ($delete) AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
+ if (!$s) {
+ echo 'err08: ' . mysqli_error($GLOBALS['connect_db']);
+ }
+ //$s = sisplet_query("DELETE FROM srv_data_glasovanje WHERE spr_id IN ($delete) AND usr_id='".get('usr_id')."'"); if (!$s) echo 'err07: '.mysqli_error($GLOBALS['connect_db']);
+ }
+
+ // odrezemo zadnjo vejico, ker smo jo dodajali kar povsod
+ $srv_data_grid = substr(get('cache_srv_data_grid'), 0, -1);
+ $srv_data_vrednost = substr(get('cache_srv_data_vrednost'), 0, -1);
+ $srv_data_text = substr(get('cache_srv_data_text'), 0, -1);
+ $srv_data_checkgrid = substr(get('cache_srv_data_checkgrid'), 0, -1);
+ $srv_data_textgrid = substr(get('cache_srv_data_textgrid'), 0, -1);
+ $srv_data_rating = substr(get('cache_srv_data_rating'), 0, -1);
+ $srv_data_vrednost_cond = substr(get('cache_srv_data_vrednost_cond'), 0, -1);
+ $srv_data_map = substr(get('cache_srv_data_map'), 0, -1);
+ $srv_data_heatmap = substr(get('cache_srv_data_heatmap'), 0, -1);
+
+ if ($srv_data_grid != '') {
+ $s = sisplet_query("INSERT INTO srv_data_grid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id, loop_id) VALUES $srv_data_grid");
+ if (!$s) {
+ echo 'err11: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_vrednost != '') {
+ $s = sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id, loop_id) VALUES $srv_data_vrednost");
+ if (!$s) {
+ echo 'err12: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_text != '') {
+ $s = sisplet_query("INSERT INTO srv_data_text" . get('db_table') . " (spr_id, vre_id, text, text2, usr_id, loop_id) VALUES $srv_data_text");
+ if (!$s) {
+ echo 'err13: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_checkgrid != '') {
+ $s = sisplet_query("INSERT INTO srv_data_checkgrid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id, loop_id) VALUES $srv_data_checkgrid");
+ if (!$s) {
+ echo 'err14: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_textgrid != '') {
+ $s = sisplet_query("INSERT INTO srv_data_textgrid" . get('db_table') . " (spr_id, vre_id, usr_id, grd_id, text, loop_id) VALUES $srv_data_textgrid");
+ if (!$s) {
+ echo 'err15: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_rating != '') {
+ $s = sisplet_query("INSERT INTO srv_data_rating (spr_id, vre_id, usr_id, vrstni_red, loop_id) VALUES $srv_data_rating");
+ if (!$s) {
+ echo 'err16: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_vrednost_cond != '') {
+ $s = sisplet_query("INSERT INTO srv_data_vrednost_cond (spr_id, vre_id, text, usr_id, loop_id) VALUES $srv_data_vrednost_cond");
+ if (!$s) {
+ echo 'err17: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_map != '') {
+ $s = sisplet_query("INSERT INTO srv_data_map (usr_id, spr_id, loop_id, vre_id, ank_id, lat, lng, address, text, vrstni_red) VALUES $srv_data_map");
+ if (!$s) {
+ echo 'err18: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+ if ($srv_data_heatmap != '') {
+ $s = sisplet_query("INSERT INTO srv_data_heatmap (usr_id, spr_id, loop_id, vre_id, ank_id, lat, lng, address, text, vrstni_red) VALUES $srv_data_heatmap");
+ if (!$s) {
+ echo 'err19: ' . mysqli_error($GLOBALS['connect_db']);
+ die();
+ }
+ }
+
+ // Posebej shranimo password iz cookija, ker po novem se password za dostop do ankete shrani v spremenljivko
+ // Ce imamo password ga shranimo kot odgovor
+ if (isset($_COOKIE['password_' . get('anketa')])) {
+ $password = $_COOKIE['password_' . get('anketa')];
+
+ $sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND s.skupine='2'");
+ if (get('usr_id') != null && mysqli_num_rows($sql1) > 0) {
+
+ $row1 = mysqli_fetch_array($sql1);
+
+ $sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row1[id]' AND naslov='$password'");
+ $row2 = mysqli_fetch_array($sql2);
+ $s = sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+ $data = $row2['id'];
+ $s = sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$row1[id]', '$data', '" . get('usr_id') . "')");
+ if (!$s) echo 'err6543' . mysqli_error($GLOBALS['connect_db']);
+ }
+ }
+
+ //sisplet_query("BEGIN");
+ }
+
+
+ /**
+ * shrani sistemske spremenljivke podane preko urlja v bazo
+ *
+ */
+ public static function saveSistemske()
+ {
+ global $lang;
+
+ $url_params = array();
+ $usr_id = get('usr_id');
+
+ /*
+ * UL evalvacija - sistemske so zakodirane z url_encode in base64_encode - naceloma se lahko uporabi povsod kjer se rabi kodiran url
+ * Dekodiranje tudi samoevalvacijske hierarhije
+ */
+ if (isset( $_GET['enc'] )) {
+
+ // Preberemo parametre in jih dekodiramo
+ $request_encoded = $_GET['enc'];
+ $request = base64_decode(urldecode($request_encoded));
+
+ // Parametre shranimo v nov array
+ $request_array = array();
+ parse_str($request, $request_array);
+
+ // Shranimo vse parametre
+ $url_params = array_merge($_GET, $request_array);
+
+ } else
+ $url_params = $_GET;
+
+
+ // Pri studentski evalvaciji posebej shranimo sifro studenta ce jo imamo (zaradi anonimnosti v posebno tabelo, ki jo potem pobrisemo)
+ if(Common::checkModule('evalvacija') == '1' && isset($url_params['sifstud'])){
+
+ $student = $url_params['sifstud'];
+
+ $s = sisplet_query("INSERT INTO eval_data_user (student, ank_id, usr_id) VALUES ('".$student."', '".get('anketa')."', '".get('usr_id')."')");
+ if (!$s) echo 'err9988' . mysqli_error($GLOBALS['connect_db']);
+ }
+
+
+ // preverimo ce so vrednosti kaksne sistemske spremenljivke podane v urlju in jih shranimo
+ $sql1 = sisplet_query("SELECT s.id, s.variable, s.skupine, s.tip FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='" . get('anketa') . "' AND s.gru_id=g.id AND s.sistem='1' AND (s.tip='4' OR s.tip='21' OR s.tip='1' OR s.tip='3')");
+ while ($row1 = mysqli_fetch_array($sql1)) {
+
+ if ($row1['id'] > 0 && (isset($url_params[$row1['variable']]) || $row1['skupine'] == 3)) {
+
+ if ($usr_id != null) {
+ if ($row1['tip'] == 4) {
+
+ $s = sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+ $data = $url_params[$row1['variable']];
+
+ $s = sisplet_query("INSERT INTO srv_data_text" . get('db_table') . " (spr_id, text, usr_id) VALUES ('$row1[id]', '$data', '" . get('usr_id') . "')");
+ if (!$s) echo 'err3455' . mysqli_error($GLOBALS['connect_db']);
+
+ } else if ($row1['tip'] == 21) {
+
+ $sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row1[id]' ORDER BY vrstni_red");
+ $row2 = mysqli_fetch_array($sql2);
+
+ $s = sisplet_query("DELETE FROM srv_data_text" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+ $data = $url_params[$row1['variable']];
+
+ $s = sisplet_query("INSERT INTO srv_data_text" . get('db_table') . " (spr_id, vre_id, text, usr_id) VALUES ('$row1[id]', '$row2[id]', '$data', '" . get('usr_id') . "')");
+ if (!$s) echo 'err6543' . mysqli_error($GLOBALS['connect_db']);
+
+ } else {
+
+ $s = sisplet_query("DELETE FROM srv_data_vrednost" . get('db_table') . " WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+ if (!$s) echo mysqli_error($GLOBALS['connect_db']);
+
+ $data = $url_params[$row1['variable']];
+
+ // Pri jeziku nimamo nastavljen id vrednosti ampak lang_id
+ if ($row1['skupine'] == 3) {
+ $naslov = $lang['language'];
+
+ // Noce prjet zaradi čšž-jev tko da je to se najlazje:)
+ if (strcmp($naslov, 'Sloven&#353;&#269;ina') == 0)
+ $sql3 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row1[id]' AND naslov='Slovenščina'");
+ else
+ $sql3 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row1[id]' AND naslov='" . $naslov . "'");
+
+ $row3 = mysqli_fetch_array($sql3);
+ $data = $row3['id'];
+ }
+
+ // Pri skupinah imamo lahko nastavljeno vrednost in ne id-ja
+ if ($row1['skupine'] == 1) {
+ $sql3 = sisplet_query("SELECT id FROM srv_vrednost WHERE spr_id = '$row1[id]' AND naslov='" . $data . "'");
+
+ if(mysqli_num_rows($sql3) > 0){
+ $row3 = mysqli_fetch_array($sql3);
+ $data = $row3['id'];
+ }
+ }
+
+ $s = sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$row1[id]', '$data', '" . get('usr_id') . "')");
+ if (!$s) echo 'err6543' . mysqli_error($GLOBALS['connect_db']);
+ }
+ }
+ }
+ }
+ }
+
+ public function savePostedSpecialVars($row)
+ {
+ $res = false;
+ $allowedTips = array(4, 7, 8); // text, number, datum
+ if (in_array($row['tip'], $allowedTips)) {
+ // text
+ if ($_POST['visible_' . $row['id']] == 1) {
+ if (isset($_POST['vrednost_' . $row['id'] . '_other'])) {
+ $vrednost = $_POST['vrednost_' . $row['id'] . '_other'];
+ foreach ($vrednost AS $key => $val) {
+ if ($val > 0) {
+ sisplet_query("INSERT INTO srv_data_vrednost" . get('db_table') . " (spr_id, vre_id, usr_id) VALUES ('$row[id]', '$val', '" . get('usr_id') . "')");
+ $res = true;
+ }
+ }
+ }
+ }// endif visible
+ } //endif tip
+ return $res;
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/Models/User.php b/main/survey/app/Models/User.php
new file mode 100644
index 0000000..0bc683b
--- /dev/null
+++ b/main/survey/app/Models/User.php
@@ -0,0 +1,58 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 26.02.2016
+ *****************************************/
+
+namespace App\Models;
+
+use Common;
+
+class User extends Model
+{
+
+ public static function addUserEmailToList($email)
+ {
+ # preverimo ali seznam alert lista za anketo že obstaja
+ $sql_string = "SELECT pid, respondents FROM srv_invitations_recipients_profiles WHERE uid = '0' AND from_survey = '0'";
+ $sql_query = sisplet_query($sql_string);
+ if (mysqli_num_rows($sql_query) > 0) {
+ # seznam že obstaja dodoamo nov email
+ $sql_row = mysqli_fetch_assoc($sql_query);
+ $emalis = explode("\n", $sql_row['respondents']);
+
+ if (!in_array($email, $emalis) && $sql_row['pid'] > 0) {
+ $emalis[] = $email;
+ $sql = sisplet_query("UPDATE srv_invitations_recipients_profiles SET respondents = '" . implode("\n", $emalis) . "' WHERE from_survey = '0' AND pid ='" . $sql_row['pid'] . "'");
+ }
+ } else {
+ #seznam še ne obstaja, skreiramo novega
+ # shranjujemo v nov profil
+ $sql_insert = "INSERT INTO srv_invitations_recipients_profiles (name,uid,fields,respondents,insert_time,comment,from_survey) "
+ . "VALUES ('alert lista', '0', 'email', '$email', NOW(), 'alert lista','0' )";
+ $sqlQuery = sisplet_query($sql_insert);
+ }
+ }
+
+ public static function sinhronizeInvitationEmail($email)
+ {
+ Common::getInstance()->Init(get('anketa'));
+ if (Common::getInstance()->validEmail($email)) {
+
+ # vnešen email je vlejaven preverimo ali ze imamo vabilo za tega uporabnika
+ $sqlu = sisplet_query("SELECT inv_res_id FROM srv_user WHERE id = '" . get('usr_id') . "' AND inv_res_id IS NOT NULL");
+
+ if (mysqli_num_rows($sqlu) > 0) {
+ # userj je dodan preko novih vabil zato updejtamo status še tam
+ list($inv_res_id) = mysqli_fetch_row($sqlu);
+ #updejtamo vabila
+ $sqlString = "UPDATE srv_invitations_recipients SET email = '$email' WHERE ank_id='" . get('anketa') . "' AND id='$inv_res_id'";
+ sisplet_query($sqlString);
+ sisplet_query("COMMIT");
+
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/main/survey/app/bootstrap.php b/main/survey/app/bootstrap.php
new file mode 100644
index 0000000..b7ae6cd
--- /dev/null
+++ b/main/survey/app/bootstrap.php
@@ -0,0 +1,104 @@
+<?php
+/***************************************
+ * Description: Initial vse komponenete in default
+ * Autor: Robert Šmalc
+ * Created date: 22.01.2016
+ *****************************************/
+
+namespace app;
+
+
+class Survey
+{
+ /** @var null The controller */
+ private $url_controller = null;
+
+ /** @var null The method (of the above controller), often also named "action" */
+ private $url_action = null;
+
+ /** @var array URL parameters */
+ private $url_params = array();
+
+ /**
+ * "Start" the application:
+ * Analyze the URL elements and calls the according controller/method or the fallback
+ */
+ public function __construct()
+ {
+ // create array with URL parts in $url
+ $this->splitUrl();
+
+ // check for controller: no controller given ? then load start-page
+ if (!$this->url_controller) {
+
+ require APP . 'controller/home.php';
+ $page = new Home();
+ $page->index();
+
+ } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) {
+ // here we did check for controller: does such a controller exist ?
+
+ // if so, then load this file and create this controller
+ // example: if controller would be "car", then this line would translate into: $this->car = new car();
+ require APP . 'controller/' . $this->url_controller . '.php';
+ $this->url_controller = new $this->url_controller();
+
+ // check for method: does such a method exist in the controller ?
+ if (method_exists($this->url_controller, $this->url_action)) {
+
+ if (!empty($this->url_params)) {
+ // Call the method and pass arguments to it
+ call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params);
+ } else {
+ // If no parameters are given, just call the method without parameters, like $this->home->method();
+ $this->url_controller->{$this->url_action}();
+ }
+
+ } else {
+ if (strlen($this->url_action) == 0) {
+ // no action defined: call the default index() method of a selected controller
+ $this->url_controller->index();
+ }
+ else {
+ header('location: ' . URL . 'error');
+ }
+ }
+ } else {
+ header('location: ' . URL . 'error');
+ }
+ }
+
+ /**
+ * Get and split the URL
+ */
+ private function splitUrl()
+ {
+ if (isset($_GET['url'])) {
+
+ // split URL
+ $url = trim($_GET['url'], '/');
+ $url = filter_var($url, FILTER_SANITIZE_URL);
+ $url = explode('/', $url);
+
+ // Put URL parts into according properties
+ // By the way, the syntax here is just a short form of if/else, called "Ternary Operators"
+ // @see http://davidwalsh.name/php-shorthand-if-else-ternary-operators
+ $this->url_controller = isset($url[0]) ? $url[0] : null;
+ $this->url_action = isset($url[1]) ? $url[1] : null;
+
+ // Remove controller and action from the split URL
+ unset($url[0], $url[1]);
+
+ // Rebase array keys and store the URL params
+ $this->url_params = array_values($url);
+
+ // for debugging. uncomment this if you have problems with the URL
+ //echo 'Controller: ' . $this->url_controller . '<br>';
+ //echo 'Action: ' . $this->url_action . '<br>';
+ //echo 'Parameters: ' . print_r($this->url_params, true) . '<br>';
+ }
+ }
+
+
+
+} \ No newline at end of file
diff --git a/main/survey/app/config.php b/main/survey/app/config.php
new file mode 100644
index 0000000..5605176
--- /dev/null
+++ b/main/survey/app/config.php
@@ -0,0 +1,49 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 22.01.2016
+ *****************************************/
+
+/**
+ * Nastavimo vrsta okolja ali gre za produkcijo ali development/debugingp
+ * DEV: - prikažemo vse errorje
+ * - izpis spremenljiv z ukazom d() ali ddd()
+ * - blackscreen error display
+ */
+global $site_url;
+if (in_array($site_url, [
+ 'http://localhost/',
+ 'http://1ka.dev/',
+ 'http://1ka-framework.dev/'
+])) {
+ define('ENVIRONMENT', 'dev');
+} else {
+ define('ENVIRONMENT', 'production');
+}
+
+// Error reporting
+if (/*ENVIRONMENT == 'dev' ||*/ isDebug()) {
+ error_reporting(E_ALL);
+ ini_set("display_errors", 1);
+
+ //ERROR blackscreen prikaz
+ if (class_exists('\Whoops\Run)')) {
+ $whoops = new \Whoops\Run;
+ $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
+ $whoops->register();
+ }
+
+} else {
+ error_reporting(0);
+ ini_set("display_errors", 0);
+}
+
+
+//DB connection
+define('DB_TYPE', 'mysql');
+define('DB_HOST', $mysql_server);
+define('DB_NAME', $mysql_database_name);
+define('DB_USER', $mysql_username);
+define('DB_PASS', $mysql_password);
+
diff --git a/main/survey/app/global_function.php b/main/survey/app/global_function.php
new file mode 100644
index 0000000..1ed4165
--- /dev/null
+++ b/main/survey/app/global_function.php
@@ -0,0 +1,70 @@
+<?php
+
+// funkcija, ki pridobi iz razreda VariableClass ustrezno vrednost spremenljivke
+function get($variable_get)
+{
+ return \App\Controllers\VariableClass::get($variable_get);
+}
+
+// funkcija, ki shrani v VariableClass ustrezno vrednost spremenljivke
+function save($variable, $value, $return = null)
+{
+ \App\Controllers\VariableClass::save($variable, $value);
+
+ if(!is_null($return) && $return == 1)
+ return $value;
+}
+
+// funkcija, ki shrani v VariableClass vrednost k že obstoječi spremenljivki
+function add($variable, $value, $return = null)
+{
+ \App\Controllers\VariableClass::add($variable, $value, $return);
+
+ return get($variable);
+}
+
+// Init naše razrede
+
+function Helper()
+{
+ return new \App\Controllers\HelperController();
+}
+
+function Display()
+{
+ return new \App\Controllers\DisplayController();
+}
+
+function Language()
+{
+ return new \App\Controllers\LanguageController();
+}
+
+/************************************************
+ * Vrnemo pot do datoteke z jeziki ali direkto pot ali pa preko urlja
+ ************************************************/
+function lang_path($izbrani_jezik = null, $use_site_url = null)
+{
+ global $site_path;
+ global $site_url;
+
+ if (is_null($izbrani_jezik))
+ return $site_path . 'lang/';
+
+ if (is_null($use_site_url))
+ return $site_path . 'lang/' . $izbrani_jezik . '.php';
+
+ // Vrnemo link do lang preko site urlja
+ return $site_url . 'lang/' . $izbrani_jezik . '.php';
+}
+
+function survey_path($file = null)
+{
+ global $site_path;
+ if(is_null($file))
+ return $site_path . 'main/survey/';
+
+ return $site_path . 'main/survey/'.$file;
+}
+
+
diff --git a/main/survey/app/use_classes.php b/main/survey/app/use_classes.php
new file mode 100644
index 0000000..9121124
--- /dev/null
+++ b/main/survey/app/use_classes.php
@@ -0,0 +1,59 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 09.03.2016
+ *****************************************/
+
+// Osnovni razredi
+use App\Controllers\Controller;
+use App\Controllers\AjaxController as Ajax;
+use App\Controllers\BodyController as Body;
+use App\Controllers\CheckController as Check;
+use App\Controllers\DisplayController as Display;
+use App\Controllers\FindController as Find;
+use App\Controllers\HeaderController as Header;
+use App\Controllers\HelperController as Helper;
+use App\Controllers\InitClass as Init;
+use App\Controllers\JsController as Js;
+use App\Controllers\LanguageController as Language;
+use App\Controllers\StatisticController as Statistic;
+use App\Controllers\SurveyController as Survey;
+use App\Controllers\VariableClass as Variable;
+use App\Models\Model;
+use App\Models\SaveSurvey;
+use App\Models\User;
+
+// Iz admin/survey
+use Common;
+use Cache;
+use SurveyInfo;
+use SurveySetting;
+use SurveySlideshow;
+use Mobile_Detect;
+use SurveyMissingValues;
+use AdvancedParadata;
+use Branching;
+use enkaParameters;
+
+
+
+// Vprašanja
+use App\Controllers\Vprasanja\ComputeController as Compute;
+use App\Controllers\Vprasanja\DatumController as Datum;
+use App\Controllers\Vprasanja\DoubleController as Double;
+use App\Controllers\Vprasanja\DragDropController as DragDrop;
+use App\Controllers\Vprasanja\DynamicController as Dynamic;
+use App\Controllers\Vprasanja\ImenaController as Imena;
+use App\Controllers\Vprasanja\MaxDiffController as MaxDiff;
+use App\Controllers\Vprasanja\MultigridController as Multigrid;
+use App\Controllers\Vprasanja\NumberController as Number;
+use App\Controllers\Vprasanja\OneAgainstAnotherController as OneAgainstAnother;
+use App\Controllers\Vprasanja\QuotaController as Quota;
+use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
+use App\Controllers\Vprasanja\RankingController as Ranking;
+use App\Controllers\Vprasanja\SystemVariableController as SystemVariable;
+use App\Controllers\Vprasanja\TextController as Text;
+use App\Controllers\Vprasanja\VprasanjaController as Vprasanja;
+use App\Controllers\Vprasanja\VsotaController as Vsota;
+use App\Controllers\Vprasanja\MapsController as Maps;
diff --git a/main/survey/download.php b/main/survey/download.php
new file mode 100644
index 0000000..08ddab5
--- /dev/null
+++ b/main/survey/download.php
@@ -0,0 +1,48 @@
+<?php
+
+include ('../../function.php');
+
+$code = $_GET['code'];
+$anketa = $_GET['anketa'];
+
+$sql = sisplet_query("SELECT filename FROM srv_data_upload WHERE ank_id='$anketa' AND code='$code'");
+if (mysqli_num_rows($sql) == 0) die();
+$row = mysqli_fetch_array($sql);
+
+$filename = $row['filename'];
+
+$mimetype = 'mime/type';
+
+header('Content-Type: '.$mimetype );
+header('Content-Disposition: attachment; filename="'.$filename.'"');
+
+readfile_chunked('uploads/'.$filename);
+
+
+ // Read a file and display its content chunk by chunk
+ function readfile_chunked($filename, $retbytes = TRUE) {
+ $buffer = '';
+ $cnt =0;
+ // $handle = fopen($filename, 'rb');
+ $handle = fopen($filename, 'rb');
+ if ($handle === false) {
+ return false;
+ }
+ while (!feof($handle)) {
+ $buffer = fread($handle, 1024*1024);
+ echo $buffer;
+ ob_flush();
+ flush();
+ if ($retbytes) {
+ $cnt += strlen($buffer);
+ }
+ }
+ $status = fclose($handle);
+ if ($retbytes && $status) {
+ return $cnt; // return num. bytes delivered like readfile() does.
+ }
+ return $status;
+ }
+
+
+?> \ No newline at end of file
diff --git a/main/survey/edit_anketa.php b/main/survey/edit_anketa.php
new file mode 100644
index 0000000..f57a1ed
--- /dev/null
+++ b/main/survey/edit_anketa.php
@@ -0,0 +1,29 @@
+<?php
+
+include_once('../../function.php');
+
+$anketa = $_GET['anketa'];
+$usr_id = $_GET['usr_id'];
+$preview = $_GET['preview'];
+$code = isset($_GET['code']) ? '&code='.$_GET['code'] : '';
+
+$sql1 = sisplet_query("SELECT cookie FROM srv_anketa WHERE id = '$anketa'");
+$row1 = mysqli_fetch_array($sql1);
+
+$sql = sisplet_query("SELECT cookie FROM srv_user WHERE id = '$usr_id'");
+$row = mysqli_fetch_array($sql);
+
+if ($_GET['quick_view'] == 1) {
+ $urejanje = '&quick_view=1';
+} else {
+ $urejanje = '&urejanje=1';
+}
+
+if ($row1['cookie'] == -1) {
+
+ header("Location: ".$site_url."main/survey/index.php?anketa=$anketa&survey-".$anketa."=".$row['cookie'].$urejanje.$code);
+} else {
+ setcookie('survey-'.$anketa, $row['cookie'], 0);
+ header("Location: ".$site_url."main/survey/index.php?anketa=$anketa".$urejanje.$code);
+}
+?> \ No newline at end of file
diff --git a/main/survey/embed_out.php b/main/survey/embed_out.php
new file mode 100644
index 0000000..c8bbe2f
--- /dev/null
+++ b/main/survey/embed_out.php
@@ -0,0 +1,9 @@
+<?php
+
+include_once('../../function.php');
+$anketa = $_GET['anketa'];
+$grupa = $_GET['grupa'];
+
+echo 'URI = '.$site_url.'main/survey/index.php?anketa='.$anketa.'&grupa='.$grupa;
+
+?> \ No newline at end of file
diff --git a/main/survey/image.php b/main/survey/image.php
new file mode 100644
index 0000000..0f44add
--- /dev/null
+++ b/main/survey/image.php
@@ -0,0 +1,410 @@
+<?php
+
+/*************************************************
+ ** This FILE WAS BORROWED FROM PHPBB PROJECT! **
+ ** - - - - - - - - - - - - - - - - - - - - - - **
+ ** Oroginal header follows **
+ *************************************************/
+
+/***************************************************************************
+ * usercp_confirm.php
+ * -------------------
+ * begin : Saturday, Jan 15, 2003
+ * copyright : (C) 2001 The phpBB Group
+ * email : support@phpbb.com
+ *
+ * $Id: usercp_confirm.php,v 1.1.2.1 2004/11/18 17:49:45 acydburn Exp $
+ *
+ ***************************************************************************/
+
+/***************************************************************************
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ ***************************************************************************/
+
+ include('../../function.php');
+
+// Define available charset
+$chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
+
+$ank_id = (int)$_GET['ank_id'];
+$spr_id = (int)$_GET['spr_id'];
+$usr_id = (int)$_GET['usr_id'];
+$code = $_GET['code'];
+
+$sql = sisplet_query("SELECT text FROM srv_captcha WHERE ank_id='$ank_id' AND spr_id='$spr_id' AND usr_id = '$usr_id' AND code='$code'");
+$row = mysqli_fetch_array($sql);
+
+$code = $row['text'];
+
+// If we can we will generate a single filtered png else we will have to simply
+// output six seperate original pngs ... first way is preferable!
+if (@extension_loaded('zlib'))
+{
+ $_png = define_filtered_pngs();
+
+ $total_width = 300;
+ $total_height = 50;
+ $img_height = 40;
+ $img_width = 0;
+ $l = 0;
+
+ list($usec, $sec) = explode(' ', microtime());
+ mt_srand($sec * $usec);
+
+ $char_widths = array();
+ for ($i = 0; $i < strlen($code); $i++)
+ {
+ $char = $code{$i};
+
+ $width = mt_rand(0, 4);
+ $char_widths[] = $width;
+ $img_width += $_png[$char]['width'] - $width;
+ }
+
+ $offset_x = mt_rand(0, $total_width - $img_width);
+ $offset_y = mt_rand(0, $total_height - $img_height);
+
+ $image = '';
+ $hold_chars = array();
+ for ($i = 0; $i < $total_height; $i++)
+ {
+ $image .= chr(0);
+
+ if ($i > $offset_y && $i < $offset_y + $img_height)
+ {
+ $j = 0;
+
+ for ($k = 0; $k < $offset_x; $k++)
+ {
+ $image .= chr(mt_rand(140, 255));
+ }
+
+ for ($k = 0; $k < strlen($code); $k++)
+ {
+ $char = $code{$k};
+
+ if (empty($hold_chars[$char]))
+ {
+ $hold_chars[$char] = explode("\n", chunk_split(base64_decode($_png[$char]['data']), $_png[$char]['width'] + 1, "\n"));
+ }
+ $image .= randomise(substr($hold_chars[$char][$l], 1), $char_widths[$j]);
+ $j++;
+ }
+
+ for ($k = $offset_x + $img_width; $k < $total_width; $k++)
+ {
+ $image .= chr(mt_rand(140, 255));
+ }
+
+ $l++;
+ }
+ else
+ {
+ for ($k = 0; $k < $total_width; $k++)
+ {
+ $image .= chr(mt_rand(140, 255));
+ }
+ }
+
+ }
+ unset($hold);
+
+ $image = create_png(gzcompress($image), $total_width, $total_height);
+
+ // Output image
+ header('Content-Type: image/png');
+ header('Cache-control: no-cache, no-store');
+ echo $image;
+
+ unset($image);
+ unset($_png);
+ exit;
+
+}
+else
+{
+ if (!empty($HTTP_GET_VARS['c']))
+ {
+ $_png = define_raw_pngs();
+
+ $char = substr($code, intval($HTTP_GET_VARS['c']) - 1, 1);
+ header('Content-Type: image/png');
+ header('Cache-control: no-cache, no-store');
+ echo base64_decode($_png[$char]);
+
+ unset($_png);
+ exit;
+ }
+}
+
+exit;
+
+// This is designed to randomise the pixels of the image data within
+// certain limits so as to keep it readable. It also varies the image
+// width a little
+function randomise($scanline, $width)
+{
+ $new_line = '';
+ $start = floor($width/2);
+ $end = strlen($scanline) - ceil($width/2);
+
+ for ($i = $start; $i < $end; $i++)
+ {
+ $pixel = ord($scanline{$i});
+
+ if ($pixel < 190)
+ {
+ $new_line .= chr(mt_rand(0, 205));
+ }
+ else if ($pixel > 190)
+ {
+ $new_line .= chr(mt_rand(145, 255));
+ }
+ else
+ {
+ $new_line .= $scanline{$i};
+ }
+ }
+
+ return $new_line;
+}
+
+// This creates a chunk of the given type, with the given data
+// of the given length adding the relevant crc
+function png_chunk($length, $type, $data)
+{
+ $raw = $type;
+ $raw .= $data;
+ $crc = crc32($raw);
+ $raw .= pack('C4', $crc >> 24, $crc >> 16, $crc >> 8, $crc);
+
+ return pack('C4', $length >> 24, $length >> 16, $length >> 8, $length) . $raw;
+}
+
+// Creates greyscale 8bit png - The PNG spec can be found at
+// http://www.libpng.org/pub/png/spec/PNG-Contents.html we use
+// png because it's a fully recognised open standard and supported
+// by practically all modern browsers and OSs
+function create_png($gzimage, $width, $height)
+{
+ // SIG
+ $image = pack('C8', 137, 80, 78, 71, 13, 10, 26, 10);
+ // IHDR
+ $raw = pack('C4', $width >> 24, $width >> 16, $width >> 8, $width);
+ $raw .= pack('C4', $height >> 24, $height >> 16, $height >> 8, $height);
+ $raw .= pack('C5', 8, 0, 0, 0, 0);
+ $image .= png_chunk(13, 'IHDR', $raw);
+ // IDAT
+ $image .= png_chunk(strlen($gzimage), 'IDAT', $gzimage);
+ // IEND
+ $image .= png_chunk(0, 'IEND', '');
+
+ return $image;
+}
+
+// Each 'data' element is base64_encoded uncompressed IDAT
+// png image data
+function define_filtered_pngs()
+{
+ $_png = array(
+ '0' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A///////////////////olFAkBAAAGDyA4P///M31/////////////wD////////////////0dAgAAAAAAAAAAAAEcPipFGHn////////////AP//////////////6DAAAAAAAAAAAAAAAAAALSEAN+T///////////8A//////////////xAAAAAAAAAAAAAAAAAAAAAACPA/////////////wD/////////////oAAAAAAAAAAAAAAAAAAAAAAAev//////////////AP////////////8oAAAAAAAAPNj/zDAAAAAAAABD//////////////8A////////////1AAAAAAAABjw////5BAAAAAAAADo/////////////wD///////////+QAAAAAAAAbP//////QgAAAAAAAKj/////////////AP///////////1wAAAAAAACs/////8AXAAAAAAAAcP////////////8A////////////OAAAAAAAAND////dNwAAAAAAAABI/////////////wD///////////8gAAAAAAAA4P//7koACwAAAAAAACT/////////////AP///////////wgAAAAAAAD///VqAwaPAAAAAAAAEP////////////8A////////////AAAAAAAAAP/8kQYDavUAAAAAAAAA/////////////wD///////////8AAAAAAAAA/6kNAEru/wAAAAAAAAD/////////////AP///////////wAAAAAAAADAIwA33f//AAAAAAAAAP////////////8A////////////FAAAAAAAADYAI8D///8AAAAAAAAQ/////////////wD///////////8kAAAAAAAAAA2p////5AAAAAAAACD/////////////AP///////////0gAAAAAAAAFkfz////UAAAAAAAAQP////////////8A////////////cAAAAAAAAET1/////7AAAAAAAABo/////////////wD///////////+oAAAAAAAAXfX/////sAAAAAAAAGj/////////////AAAAALgAAAAAAAAwAAAAAAAAAAAAAAD////////////oAAAAAAAACOT////oEAAAAAAAAOD/////////////AP////////////8+AAAAAAAAKMz/zDQAAAAAAAA0//////////////8A////////////7jgAAAAAAAAAAAAAAAAAAAAAAKT//////////////wD///////////VqAwIAAAAAAAAAAAAAAAAAAAA8////////////////AP//////////rQcDaVEAAAAAAAAAAAAAAAAAKOj///////////////8A///////////nblnu/IAIAAAAAAAAAAAAAFzw/////////////////wD////////////79////+iITCAAAAAgSITg////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////w==',
+ 'width' => 40
+ ),
+ '1' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////8BAAAAAAAP//////////////////AP////////////////////////9sAAAAAAAA//////////////////8A////////////////////////pAAAAAAAAAD//////////////////wD//////////////////////6wEAAAAAAAAAP//////////////////AP////////////////////h4AAAAAAAAAAAA//////////////////8A//////////////////ygJAAAAAAAAAAAAAD//////////////////wD//////////////9x8HAAAAAAAAAAAAAAAAP//////////////////AP//////////////AAAAAAAAAAAAAAAAAAAA//////////////////8A//////////////8AAAAAAAAAAAAAAAAAAAD//////////////////wD//////////////wAAAAAAAAR4AAAAAAAAAP//////////////////AP//////////////AAAAAAA4zP8AAAAAAAAA//////////////////8A//////////////8AAAA4sP///wAAAAAAAAD//////////////////wD//////////////yR80P//////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '2' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP/////////////////okFAkCAAABCBIfNT///////////////////8A///////////////8hAgAAAAAAAAAAAAAAFTo/////////////////wD//////////////1QAAAAAAAAAAAAAAAAAACjo////////////////AP////////////+MAAAAAAAAAAAAAAAAAAAAADj///////////////8A////////////9BAAAAAAAAAAAAAAAAAAAAAAALD//////////////wD///////////+gAAAAAAAAAHjs+KwMAAAAAAAAVP//////////////AP///////////1gAAAAAAABM/////6QAAAAAAAAU//////////////8A////////////KAAAAAAAALj/////+AAAAAAAAAD//////////////wD///////////+MfGBMOCAI8P/////wAAAAAAAACP//////////////AP///////////////////////////5wAAAAAAAAw//////////////8A///////////////////////////oFAAAAAAAAHz//////////////wD/////////////////////////6CgAAAAAAAAE3P//////////////AP///////////////////////9ggAAAAAAAAAHT///////////////8A//////////////////////+0DAAAAAAAAAA8+P///////////////wD/////////////////////gAAAAAAAAAAAKOj/////////////////AP//////////////////9FAAAAAAAAAAADzw//////////////////8A/////////////////+g4AAAAAAAAAABk/P///////////////////wD////////////////oKAAAAAAAAAAMqP//////////////////////AP//////////////6CgAAAAAAAAAMNz///////////////////////8A//////////////g4AAAAAAAAAFT0/////////////////////////wD/////////////bAAAAAAAAABU/P//////////////////////////AP///////////8wAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A////////////SAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////9AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////xAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '3' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD////////////////8sGg0FAAAACA4cLz8////////////////////AP//////////////rBgAAAAAAAAAAAAAACTA//////////////////8A/////////////3QAAAAAAAAAAAAAAAAAAASs/////////////////wD///////////+YAAAAAAAAAAAAAAAAAAAAAAjc////////////////AP//////////6AwAAAAAAAAAAAAAAAAAAAAAAGT///////////////8A//////////94AAAAAAAABJDw/8g4AAAAAAAAHP///////////////wD//////////yAAAAAAAACE/////9gAAAAAAAAA////////////////AP///////////NSwiGQ4FOT//////AAAAAAAABD///////////////8A//////////////////////////+YAAAAAAAAVP///////////////wD//////////////////////P/ggAQAAAAAAATM////////////////AP////////////////////9gAAAAAAAAAAAElP////////////////8A/////////////////////0AAAAAAAAAAHLj//////////////////wD/////////////////////OAAAAAAAAAAwkPj/////////////////AP////////////////////8gAAAAAAAAAAAAINj///////////////8A/////////////////////xAAAAAAAAAAAAAAIPD//////////////wD/////////////////////uOz/4HgEAAAAAAAAhP//////////////AP///////////////////////////3wAAAAAAAAw//////////////8A////////////////////////////6AAAAAAAAAj//////////////wD/////////////////////////////AAAAAAAAAP//////////////AP//////////tJh8YEQoDNz//////+AAAAAAAAAY//////////////8A//////////88AAAAAAAAaP//////dAAAAAAAAEz//////////////wD//////////6QAAAAAAAAAdOD/5HQAAAAAAAAApP//////////////AP///////////CgAAAAAAAAAAAAAAAAAAAAAACD4//////////////8A////////////yAQAAAAAAAAAAAAAAAAAAAAEuP///////////////wD/////////////rAQAAAAAAAAAAAAAAAAABJD/////////////////AP//////////////zDQAAAAAAAAAAAAAACTA//////////////////8A/////////////////8BwOCAAAAAUNGi0/P///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '4' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////////////////nAAAAAAAAAD///////////////8A/////////////////////////8AEAAAAAAAAAP///////////////wD////////////////////////gGAAAAAAAAAAA////////////////AP//////////////////////9DAAAAAAAAAAAAD///////////////8A//////////////////////9UAAAAAAAAAAAAAP///////////////wD/////////////////////hAAAAAAAAAAAAAAA////////////////AP///////////////////7QAAAAAAAAAAAAAAAD///////////////8A///////////////////UDAAAAAAUAAAAAAAAAP///////////////wD/////////////////7CQAAAAABMAAAAAAAAAA////////////////AP////////////////xEAAAAAACU/wAAAAAAAAD///////////////8A////////////////cAAAAAAAZP//AAAAAAAAAP///////////////wD//////////////6AAAAAAADz8//8AAAAAAAAA////////////////AP/////////////IBAAAAAAc6P///wAAAAAAAAD///////////////8A////////////5BgAAAAADMz/////AAAAAAAAAP///////////////wD///////////g0AAAAAACk//////8AAAAAAAAA////////////////AP//////////XAAAAAAAfP///////wAAAAAAAAD///////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP///////////////////////////wAAAAAAAAD///////////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '5' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////8AAAAAAAAAAAAAAAAAAAAAAA//////////////8A///////////////MAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////////6wAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////////iAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////////9kAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////////0QAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////////IAAAAAAAYP////////////////////////////8A//////////////wAAAAAAAB8/////////////////////////////wD/////////////3AAAAAAAAIj/////////////////////////////AP////////////+4AAAAAAAAoLRYHAAEKGTE//////////////////8A/////////////5QAAAAAAAAQAAAAAAAAAABY9P///////////////wD/////////////dAAAAAAAAAAAAAAAAAAAAAA89P//////////////AP////////////9QAAAAAAAAAAAAAAAAAAAAAABg//////////////8A/////////////zAAAAAAAAAAAAAAAAAAAAAAAADQ/////////////wD/////////////IAAAAAAAAGjY/+h4BAAAAAAAAGz/////////////AP//////////////9NS0lHSc//////90AAAAAAAALP////////////8A/////////////////////////////9QAAAAAAAAE/////////////wD//////////////////////////////wAAAAAAAAD/////////////AP/////////////////////////////8AAAAAAAAEP////////////8A////////////pIRwWEAgDOD//////8wAAAAAAAA8/////////////wD///////////9EAAAAAAAAaP//////ZAAAAAAAAHz/////////////AP///////////6QAAAAAAAAAaOD/4GQAAAAAAAAE4P////////////8A/////////////CQAAAAAAAAAAAAAAAAAAAAAAGD//////////////wD/////////////yAQAAAAAAAAAAAAAAAAAAAAc7P//////////////AP//////////////rAwAAAAAAAAAAAAAAAAAGNj///////////////8A////////////////0EAAAAAAAAAAAAAAAFTo/////////////////wD//////////////////8h4QCAAAAAcQHzU////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '6' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////////////+0ZCwMAAAUNGjI////////////////////AP/////////////////EMAAAAAAAAAAAAABM6P////////////////8A////////////////lAQAAAAAAAAAAAAAAAAo6P///////////////wD//////////////6wAAAAAAAAAAAAAAAAAAABI////////////////AP/////////////oEAAAAAAAAAAAAAAAAAAAAACw//////////////8A/////////////3AAAAAAAAAoxP/YPAAAAAAAAEj//////////////wD////////////4EAAAAAAACOD////YDCBAVGiAoP//////////////AP///////////7gAAAAAAABY//////////////////////////////8A////////////eAAAAAAAAJT//////////////////////////////wD///////////9MAAAAAAAAvP/IXBgABCx03P//////////////////AP///////////ygAAAAAAADcdAAAAAAAAAAEiP////////////////8A////////////FAAAAAAAAFAAAAAAAAAAAAAAcP///////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAlP//////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAQ8P////////////8A////////////AAAAAAAAAABAyP/kZAAAAAAAAACQ/////////////wD///////////8MAAAAAAAALPj/////WAAAAAAAAET/////////////AP///////////yQAAAAAAACY///////MAAAAAAAAFP////////////8A////////////SAAAAAAAAMD///////wAAAAAAAAA/////////////wD///////////9wAAAAAAAAvP///////wAAAAAAAAD/////////////AP///////////7QAAAAAAACI///////UAAAAAAAAJP////////////8A////////////+AwAAAAAACDw/////2wAAAAAAABY/////////////wD/////////////cAAAAAAAADC8/Ox4AAAAAAAAAKj/////////////AP/////////////oEAAAAAAAAAAAAAAAAAAAAAAk/P////////////8A//////////////+oAAAAAAAAAAAAAAAAAAAABLj//////////////wD///////////////+QAAAAAAAAAAAAAAAAAACQ////////////////AP////////////////+0JAAAAAAAAAAAAAAkuP////////////////8A///////////////////8sGg0FAAADCxgqPz//////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '7' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAABP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAy4/////////////wD//////////////////////////+QUAAAAAAAEuP//////////////AP/////////////////////////8QAAAAAAAAKT///////////////8A/////////////////////////4wAAAAAAAB0/////////////////wD////////////////////////cCAAAAAAANPz/////////////////AP///////////////////////0QAAAAAAATY//////////////////8A//////////////////////+0AAAAAAAAeP///////////////////wD//////////////////////CQAAAAAABTw////////////////////AP////////////////////+gAAAAAAAAkP////////////////////8A/////////////////////ywAAAAAABDw/////////////////////wD///////////////////+4AAAAAAAAbP//////////////////////AP///////////////////1wAAAAAAADQ//////////////////////8A///////////////////4DAAAAAAAMP///////////////////////wD//////////////////7QAAAAAAAB8////////////////////////AP//////////////////aAAAAAAAAMj///////////////////////8A//////////////////8oAAAAAAAM/P///////////////////////wD/////////////////8AAAAAAAAET/////////////////////////AP////////////////+0AAAAAAAAcP////////////////////////8A/////////////////4wAAAAAAACY/////////////////////////wD/////////////////WAAAAAAAAMD/////////////////////////AP////////////////80AAAAAAAA4P////////////////////////8A/////////////////xAAAAAAAAD4/////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '8' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD////////////////////IdDQUAAAEIEiA1P//////////////////AP/////////////////gRAAAAAAAAAAAAAAAROD///////////////8A////////////////0BgAAAAAAAAAAAAAAAAAEMj//////////////wD///////////////AcAAAAAAAAAAAAAAAAAAAAHPD/////////////AP//////////////hAAAAAAAAAAAAAAAAAAAAAAAhP////////////8A//////////////8sAAAAAAAAKMz/zCgAAAAAAAAs/////////////wD//////////////wAAAAAAAADM////zAAAAAAAAAD/////////////AP//////////////BAAAAAAAAP//////AAAAAAAABP////////////8A//////////////8sAAAAAAAAzP///9QAAAAAAAAw/////////////wD//////////////3wAAAAAAAAoyP/YNAAAAAAAAIT/////////////AP//////////////7BgAAAAAAAAAAAAAAAAAAAAc8P////////////8A////////////////xBgAAAAAAAAAAAAAAAAAGNj//////////////wD/////////////////tAQAAAAAAAAAAAAAAACo////////////////AP///////////////HAAAAAAAAAAAAAAAAAAAAB8//////////////8A//////////////9gAAAAAAAAAAAAAAAAAAAAAAB8/////////////wD/////////////wAAAAAAAAABk4P/UWAAAAAAAAATQ////////////AP////////////9UAAAAAAAAaP//////XAAAAAAAAGT///////////8A/////////////xgAAAAAAADg///////cAAAAAAAAJP///////////wD/////////////AAAAAAAAAP////////8AAAAAAAAA////////////AP////////////8AAAAAAAAA4P//////3AAAAAAAAAT///////////8A/////////////ygAAAAAAABg//////9cAAAAAAAALP///////////wD/////////////ZAAAAAAAAABY1P/cXAAAAAAAAABw////////////AP/////////////QAAAAAAAAAAAAAAAAAAAAAAAABNz///////////8A//////////////9gAAAAAAAAAAAAAAAAAAAAAAB0/////////////wD///////////////Q8AAAAAAAAAAAAAAAAAAAAUPz/////////////AP////////////////x4CAAAAAAAAAAAAAAAEIT8//////////////8A///////////////////smFQwGAAAABg0ZKT0/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ '9' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////////////ysYCwMAAAUNGiw/P//////////////////AP////////////////+4JAAAAAAAAAAAAAAkuP////////////////8A////////////////lAQAAAAAAAAAAAAAAAAAkP///////////////wD//////////////8AEAAAAAAAAAAAAAAAAAAAAqP//////////////AP/////////////8JAAAAAAAAAAAAAAAAAAAAAAQ7P////////////8A/////////////6wAAAAAAAAAfOz8vCwAAAAAAABw/////////////wD/////////////WAAAAAAAAHD/////7BgAAAAAAAz4////////////AP////////////8kAAAAAAAA1P//////hAAAAAAAALT///////////8A/////////////wAAAAAAAAD///////+4AAAAAAAAcP///////////wD/////////////AAAAAAAAAPz//////8AAAAAAAABI////////////AP////////////8UAAAAAAAAzP//////lAAAAAAAACT///////////8A/////////////0QAAAAAAABY//////gsAAAAAAAADP///////////wD/////////////kAAAAAAAAABw5P/IPAAAAAAAAAAA////////////AP/////////////wEAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A//////////////+UAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD///////////////9wAAAAAAAAAAAAAFAAAAAAAAAU////////////AP////////////////+IBAAAAAAAAABw3AAAAAAAACj///////////8A///////////////////cdCwEABhcxP+8AAAAAAAATP///////////wD//////////////////////////////5AAAAAAAAB4////////////AP//////////////////////////////UAAAAAAAALj///////////8A//////////////+kgGxUQCAM2P///+AIAAAAAAAQ+P///////////wD//////////////0gAAAAAAAA42P/EKAAAAAAAAHD/////////////AP//////////////sAAAAAAAAAAAAAAAAAAAAAAQ6P////////////8A////////////////TAAAAAAAAAAAAAAAAAAAAKz//////////////wD////////////////oKAAAAAAAAAAAAAAAAASU////////////////AP/////////////////sUAAAAAAAAAAAAAAwxP////////////////8A////////////////////yHA0FAAADCxktP///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'A' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////////////////+QAAAAAAAAAAAAAAOT/////////////////AP//////////////////kAAAAAAAAAAAAAAAkP////////////////8A//////////////////88AAAAAAAAAAAAAAA8/////////////////wD/////////////////5AAAAAAAAAAAAAAAAADk////////////////AP////////////////+QAAAAAAAAAAAAAAAAAJD///////////////8A/////////////////zwAAAAAAAAAAAAAAAAAPP///////////////wD////////////////kAAAAAAAAAAgAAAAAAAAA5P//////////////AP///////////////5AAAAAAAAAAgAAAAAAAAACQ//////////////8A////////////////PAAAAAAAAAz8HAAAAAAAADz//////////////wD//////////////+QAAAAAAAAAWP9kAAAAAAAAANz/////////////AP//////////////kAAAAAAAAACk/7wAAAAAAAAAhP////////////8A//////////////88AAAAAAAABOz//BQAAAAAAAAw/////////////wD/////////////4AAAAAAAAAA8////ZAAAAAAAAADc////////////AP////////////+EAAAAAAAAAIj///+8AAAAAAAAAIT///////////8A/////////////zAAAAAAAAAA2P////wQAAAAAAAAMP///////////wD////////////cAAAAAAAAACT//////1wAAAAAAAAA3P//////////AP///////////4QAAAAAAAAAAAAAAAAAAAAAAAAAAACE//////////8A////////////MAAAAAAAAAAAAAAAAAAAAAAAAAAAADD//////////wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANz/////////AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhP////////8A//////////8wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAw/////////wD/////////3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADc////////AP////////+EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIT///////8A/////////zAAAAAAAAAAhP///////////2QAAAAAAAAAMP///////wD////////cAAAAAAAAAADM////////////vAAAAAAAAAAA3P//////AP///////4QAAAAAAAAAHP/////////////4DAAAAAAAAACE//////8A////////MAAAAAAAAABk//////////////9cAAAAAAAAADD//////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'B' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAEDh83P///////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAEhP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAeP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAABY////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAABT///////////8A//////////8AAAAAAAAAAP/////4zEwAAAAAAAAAAP///////////wD//////////wAAAAAAAAAA////////7AAAAAAAAAAQ////////////AP//////////AAAAAAAAAAD////////sAAAAAAAAAEj///////////8A//////////8AAAAAAAAAAP/////4zEQAAAAAAAAAtP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAFz/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAiA/P////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAIjPj//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAGKz/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAJT///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAABNz//////////wD//////////wAAAAAAAAAA///////sqCAAAAAAAAAAbP//////////AP//////////AAAAAAAAAAD/////////yAAAAAAAAAAs//////////8A//////////8AAAAAAAAAAP//////////AAAAAAAAAAT//////////wD//////////wAAAAAAAAAA/////////7wAAAAAAAAAAP//////////AP//////////AAAAAAAAAAD//////+ikGAAAAAAAAAAY//////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFT//////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsP//////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAADj///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAc6P///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAATOj/////////////AP//////////AAAAAAAAAAAAAAAAAAAEIEBkkNj///////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'C' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////////5JRULBAAAAgkTIDQ//////////////////8A////////////////1FAAAAAAAAAAAAAAAABAyP///////////////wD//////////////4gEAAAAAAAAAAAAAAAAAAAElP//////////////AP////////////9wAAAAAAAAAAAAAAAAAAAAAAAAlP////////////8A////////////kAAAAAAAAAAAAAAAAAAAAAAAAAAEyP///////////wD//////////9wIAAAAAAAAAAAAAAAAAAAAAAAAAAAw////////////AP//////////WAAAAAAAAAAAWMz/8JwQAAAAAAAAAACw//////////8A/////////+wEAAAAAAAAAID//////9QMAAAAAAAAAET//////////wD/////////nAAAAAAAAAAo/P///////3wAAAAABDBspP//////////AP////////9gAAAAAAAAAIz/////////3BxQjMT0//////////////8A/////////zQAAAAAAAAAzP///////////////////////////////wD/////////GAAAAAAAAADo////////////////////////////////AP////////8AAAAAAAAAAP////////////////////////////////8A/////////wAAAAAAAAAA/////////////////////////////////wD/////////AAAAAAAAAAD/////////////////////////////////AP////////8cAAAAAAAAAOj///////////////////////////////8A/////////zgAAAAAAAAA0P/////////kIGio7P///////////////wD/////////bAAAAAAAAACg/////////5wAAAAAMHS49P//////////AP////////+oAAAAAAAAAEz/////////PAAAAAAAAAAc//////////8A//////////QIAAAAAAAAALz//////6QAAAAAAAAAAGT//////////wD//////////3AAAAAAAAAADIzo/+SEBAAAAAAAAAAAyP//////////AP//////////7BAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A////////////rAAAAAAAAAAAAAAAAAAAAAAAAAAE0P///////////wD/////////////fAAAAAAAAAAAAAAAAAAAAAAAAJz/////////////AP//////////////iAQAAAAAAAAAAAAAAAAAAASY//////////////8A////////////////yEAAAAAAAAAAAAAAAAA8yP///////////////wD//////////////////9yIUCwQAAAAIEB4yP//////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'D' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////////8AAAAAAAAAAAAAAAAADChQkOT/////////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAABGjw//////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAACDY/////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAABjk////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAKj//////////wD///////////8AAAAAAAAAAP///+isSAAAAAAAAAAANP//////////AP///////////wAAAAAAAAAA////////hAAAAAAAAAAA2P////////8A////////////AAAAAAAAAAD/////////MAAAAAAAAACQ/////////wD///////////8AAAAAAAAAAP////////+MAAAAAAAAAFj/////////AP///////////wAAAAAAAAAA/////////8gAAAAAAAAAMP////////8A////////////AAAAAAAAAAD/////////5AAAAAAAAAAY/////////wD///////////8AAAAAAAAAAP//////////AAAAAAAAAAD/////////AP///////////wAAAAAAAAAA//////////8AAAAAAAAAAP////////8A////////////AAAAAAAAAAD//////////wAAAAAAAAAA/////////wD///////////8AAAAAAAAAAP/////////wAAAAAAAAABD/////////AP///////////wAAAAAAAAAA/////////9QAAAAAAAAAJP////////8A////////////AAAAAAAAAAD/////////qAAAAAAAAABI/////////wD///////////8AAAAAAAAAAP////////9QAAAAAAAAAHj/////////AP///////////wAAAAAAAAAA////////uAAAAAAAAAAAvP////////8A////////////AAAAAAAAAAD////w0HwEAAAAAAAAACT8/////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAADz8//////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAY6P///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAKNz/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAACHT0//////////////8A////////////AAAAAAAAAAAAAAAAABg4bKj0/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'E' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAD///////////////////////////////8A//////////8AAAAAAAAAAP///////////////////////////////wD//////////wAAAAAAAAAA////////////////////////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'F' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'G' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////////////////MB8TCgQAAAACCA4YJzs////////////////AP///////////////JQcAAAAAAAAAAAAAAAAAAhw8P////////////8A/////////////9gwAAAAAAAAAAAAAAAAAAAAAAAk2P///////////wD////////////EDAAAAAAAAAAAAAAAAAAAAAAAAAAc7P//////////AP//////////2AwAAAAAAAAAAAAAAAAAAAAAAAAAAABY//////////8A//////////wwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ/////////wD/////////kAAAAAAAAAAAEHzQ/P/gmCAAAAAAAAAAAFz/////////AP////////wcAAAAAAAAACjg////////8CwAAAAAAAAgWP////////8A////////vAAAAAAAAAAI2P//////////yBRAcJjI8P///////////wD///////94AAAAAAAAAGD/////////////////////////////////AP///////0AAAAAAAAAAsP////////////////////////////////8A////////IAAAAAAAAADc/////////////////////////////////wD///////8AAAAAAAAAAP///////wAAAAAAAAAAAAAAAAD/////////AP///////wAAAAAAAAAA////////AAAAAAAAAAAAAAAAAP////////8A////////AAAAAAAAAAD///////8AAAAAAAAAAAAAAAAA/////////wD///////8gAAAAAAAAAOD//////wAAAAAAAAAAAAAAAAD/////////AP///////0AAAAAAAAAAtP//////AAAAAAAAAAAAAAAAAP////////8A////////cAAAAAAAAABw//////8AAAAAAAAAAAAAAAAA/////////wD///////+8AAAAAAAAABDs////////////AAAAAAAAAAD/////////AP////////wYAAAAAAAAADz0//////////AAAAAAAAAAAP////////8A/////////5AAAAAAAAAAACCY4P//3KhcCAAAAAAAAAAA/////////wD/////////+CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////AP//////////xAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIP////////8A////////////rAQAAAAAAAAAAAAAAAAAAAAAAAAAAGTw/////////wD/////////////vBQAAAAAAAAAAAAAAAAAAAAAADjI////////////AP//////////////8HAQAAAAAAAAAAAAAAAAAEiw//////////////8A//////////////////iwcEAgBAAABCA4aKDk/////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'H' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'I' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAP///////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAA////////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAD///////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'J' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAD//////////////wD///////////////////////////8AAAAAAAAAAP//////////////AP///////////////////////////wAAAAAAAAAA//////////////8A////////////////////////////AAAAAAAAAAj//////////////wD//////////+zMrIxwUDAQ//////wAAAAAAAAAIP//////////////AP//////////DAAAAAAAAADo////2AAAAAAAAAA0//////////////8A//////////8wAAAAAAAAAKj///+YAAAAAAAAAFj//////////////wD//////////2gAAAAAAAAAIND/yBgAAAAAAAAAkP//////////////AP//////////vAAAAAAAAAAAAAAAAAAAAAAAAADc//////////////8A////////////MAAAAAAAAAAAAAAAAAAAAAAAUP///////////////wD////////////EBAAAAAAAAAAAAAAAAAAAABjk////////////////AP////////////+sBAAAAAAAAAAAAAAAAAAY2P////////////////8A///////////////EMAAAAAAAAAAAAAAAVOj//////////////////wD/////////////////vHBAIAAAABg8fNT/////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'K' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////8AAAAAAAAAAP//////////wAQAAAAAAAAAAABw////////AP///////wAAAAAAAAAA/////////9AMAAAAAAAAAAAAcP////////8A////////AAAAAAAAAAD////////cGAAAAAAAAAAAAHD//////////wD///////8AAAAAAAAAAP//////6CgAAAAAAAAAAABs////////////AP///////wAAAAAAAAAA//////Q0AAAAAAAAAAAAVPz///////////8A////////AAAAAAAAAAD////8RAAAAAAAAAAAAFT8/////////////wD///////8AAAAAAAAAAP///1gAAAAAAAAAAABU/P//////////////AP///////wAAAAAAAAAA//9wAAAAAAAAAAAASPz///////////////8A////////AAAAAAAAAAD/jAAAAAAAAAAAADz0/////////////////wD///////8AAAAAAAAAAKQAAAAAAAAAAAA89P//////////////////AP///////wAAAAAAAAAABAAAAAAAAAAAFPT///////////////////8A////////AAAAAAAAAAAAAAAAAAAAAAAApP///////////////////wD///////8AAAAAAAAAAAAAAAAAAAAAAAAU8P//////////////////AP///////wAAAAAAAAAAAAAAAAAAAAAAAABk//////////////////8A////////AAAAAAAAAAAAAAAAAAAAAAAAAADE/////////////////wD///////8AAAAAAAAAAAAAAAAoEAAAAAAAACz8////////////////AP///////wAAAAAAAAAAAAAAGNiAAAAAAAAAAIj///////////////8A////////AAAAAAAAAAAAABjY//gYAAAAAAAACOD//////////////wD///////8AAAAAAAAAAAAY2P///5wAAAAAAAAASP//////////////AP///////wAAAAAAAAAAGNj//////CgAAAAAAAAAqP////////////8A////////AAAAAAAAAADI////////sAAAAAAAAAAc8P///////////wD///////8AAAAAAAAAAP//////////QAAAAAAAAABs////////////AP///////wAAAAAAAAAA///////////IAAAAAAAAAATI//////////8A////////AAAAAAAAAAD///////////9YAAAAAAAAADD8/////////wD///////8AAAAAAAAAAP///////////9wEAAAAAAAAAJD/////////AP///////wAAAAAAAAAA/////////////3AAAAAAAAAADOT///////8A////////AAAAAAAAAAD/////////////7BAAAAAAAAAAUP///////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'L' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAD/////////////////////////////AP////////////8AAAAAAAAAAP////////////////////////////8A/////////////wAAAAAAAAAA/////////////////////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'M' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////8AAAAAAAAAAAAAAHz//////3wAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAAAAAATP//////UAAAAAAAAAAAAAAA////////AP//////AAAAAAAAAAAAAAAc//////8cAAAAAAAAAAAAAAD///////8A//////8AAAAAAAAAAAAAAADw////8AAAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAAAAAAALz////AAAAAAAAAAAAAAAAA////////AP//////AAAAAAAAAAAAAAAAkP///5AAAAAAAAAAAAAAAAD///////8A//////8AAAAAAAAAAAAAAABc////ZAAAAAAAAAAAAAAAAP///////wD//////wAAAAAAAAAoAAAAADD///8wAAAAACQAAAAAAAAA////////AP//////AAAAAAAAAFwAAAAABPz//AgAAAAAXAAAAAAAAAD///////8A//////8AAAAAAAAAkAAAAAAA0P/UAAAAAACQAAAAAAAAAP///////wD//////wAAAAAAAADMAAAAAACg/6gAAAAAAMQAAAAAAAAA////////AP//////AAAAAAAAAPgEAAAAAHD/dAAAAAAE+AAAAAAAAAD///////8A//////8AAAAAAAAA/zQAAAAAQP9IAAAAADD/AAAAAAAAAP///////wD//////wAAAAAAAAD/bAAAAAAQ/xQAAAAAaP8AAAAAAAAA////////AP//////AAAAAAAAAP+gAAAAAADQAAAAAACc/wAAAAAAAAD///////8A//////8AAAAAAAAA/9QAAAAAAGgAAAAAAND/AAAAAAAAAP///////wD//////wAAAAAAAAD//wwAAAAAFAAAAAAM/P8AAAAAAAAA////////AP//////AAAAAAAAAP//RAAAAAAAAAAAADz//wAAAAAAAAD///////8A//////8AAAAAAAAA//94AAAAAAAAAAAAcP//AAAAAAAAAP///////wD//////wAAAAAAAAD//7AAAAAAAAAAAACo//8AAAAAAAAA////////AP//////AAAAAAAAAP//5AAAAAAAAAAAANz//wAAAAAAAAD///////8A//////8AAAAAAAAA////HAAAAAAAAAAQ////AAAAAAAAAP///////wD//////wAAAAAAAAD///9QAAAAAAAAAEz///8AAAAAAAAA////////AP//////AAAAAAAAAP///4gAAAAAAAAAfP///wAAAAAAAAD///////8A//////8AAAAAAAAA////vAAAAAAAAACw////AAAAAAAAAP///////wD//////wAAAAAAAAD////wAAAAAAAAAOz///8AAAAAAAAA////////AP//////AAAAAAAAAP////8sAAAAAAAc/////wAAAAAAAAD///////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'N' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////AAAAAAAAALD/////////////AAAAAAAAAP//////////AP////////8AAAAAAAAAFOj///////////8AAAAAAAAA//////////8A/////////wAAAAAAAAAASP///////////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAkP//////////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAI1P////////8AAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAw+P///////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAABw////////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAC8//////8AAAAAAAAA//////////8A/////////wAAAAAAAAAAAAAAABzs/////wAAAAAAAAD//////////wD/////////AAAAAAAAAAAAAAAAAFD/////AAAAAAAAAP//////////AP////////8AAAAAAAAAAAAAAAAAAJz///8AAAAAAAAA//////////8A/////////wAAAAAAAAAUAAAAAAAADNz//wAAAAAAAAD//////////wD/////////AAAAAAAAALQAAAAAAAAANPz/AAAAAAAAAP//////////AP////////8AAAAAAAAA/2wAAAAAAAAAfP8AAAAAAAAA//////////8A/////////wAAAAAAAAD/+CwAAAAAAAAExAAAAAAAAAD//////////wD/////////AAAAAAAAAP//0AQAAAAAAAAgAAAAAAAAAP//////////AP////////8AAAAAAAAA////jAAAAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD/////RAAAAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP/////kFAAAAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAA//////+sAAAAAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD///////9kAAAAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP////////QkAAAAAAAAAAAAAP//////////AP////////8AAAAAAAAA/////////8wEAAAAAAAAAAAA//////////8A/////////wAAAAAAAAD//////////4QAAAAAAAAAAAD//////////wD/////////AAAAAAAAAP///////////DwAAAAAAAAAAP//////////AP////////8AAAAAAAAA////////////4BAAAAAAAAAA//////////8A/////////wAAAAAAAAD/////////////qAAAAAAAAAD//////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'O' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A///////////////////0qGw4HAAAABw4aKT0/////////////////wD////////////////wcAwAAAAAAAAAAAAAAAho6P//////////////AP//////////////uBQAAAAAAAAAAAAAAAAAAAAMoP////////////8A/////////////6AEAAAAAAAAAAAAAAAAAAAAAAAAkP///////////wD///////////+4BAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP//////////8BQAAAAAAAAAAAAAAAAAAAAAAAAAAAAM5P////////8A//////////9wAAAAAAAAAAAsrPD/7KQsAAAAAAAAAABg/////////wD/////////+BAAAAAAAAAAUPj///////hQAAAAAAAAAAjs////////AP////////+sAAAAAAAAABDw//////////AYAAAAAAAAAKD///////8A/////////2wAAAAAAAAAdP///////////3wAAAAAAAAAYP///////wD/////////OAAAAAAAAAC4////////////xAAAAAAAAAAw////////AP////////8cAAAAAAAAAOD////////////oAAAAAAAAABT///////8A/////////wAAAAAAAAAA//////////////8AAAAAAAAAAP///////wD/////////AAAAAAAAAAD//////////////wAAAAAAAAAA////////AP////////8AAAAAAAAAAP/////////////8AAAAAAAAAAD///////8A/////////xwAAAAAAAAA5P///////////+AAAAAAAAAAHP///////wD/////////NAAAAAAAAAC8////////////uAAAAAAAAAA4////////AP////////9oAAAAAAAAAHj///////////98AAAAAAAAAGT///////8A/////////6gAAAAAAAAAGPD/////////+BgAAAAAAAAApP///////wD/////////9AwAAAAAAAAAUPz///////xcAAAAAAAAAAjs////////AP//////////cAAAAAAAAAAALKjs//CwOAAAAAAAAAAAYP////////8A///////////wFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzk/////////wD///////////+4BAAAAAAAAAAAAAAAAAAAAAAAAAAAoP//////////AP////////////+QAAAAAAAAAAAAAAAAAAAAAAAAAJD///////////8A//////////////+sEAAAAAAAAAAAAAAAAAAAAAyg/////////////wD////////////////oZAgAAAAAAAAAAAAAAARg4P//////////////AP//////////////////9KhsOCAAAAAUMFyc7P////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'P' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////////wAAAAAAAAAAAAAAAAAACCxguP////////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAOOD//////////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAGOD/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAARP////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAABo////////////AP///////////wAAAAAAAAAA////6JwMAAAAAAAAADD///////////8A////////////AAAAAAAAAAD//////6AAAAAAAAAADP///////////wD///////////8AAAAAAAAAAP//////9AAAAAAAAAAA////////////AP///////////wAAAAAAAAAA///////0AAAAAAAAAAD///////////8A////////////AAAAAAAAAAD//////5gAAAAAAAAAHP///////////wD///////////8AAAAAAAAAAP///9iICAAAAAAAAABI////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAJD///////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAI6P///////////wD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAIT/////////////AP///////////wAAAAAAAAAAAAAAAAAAAAAAAABU/P////////////8A////////////AAAAAAAAAAAAAAAAAAAAAAAIhPz//////////////wD///////////8AAAAAAAAAAAAAAAAABCRMkOz/////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP///////////wAAAAAAAAAA//////////////////////////////8A////////////AAAAAAAAAAD//////////////////////////////wD///////////8AAAAAAAAAAP//////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'Q' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////SoaDQcAAAAHDhoqPT///////////////////8A//////////////BwDAAAAAAAAAAAAAAACHDo/////////////////wD///////////+4FAAAAAAAAAAAAAAAAAAAABCo////////////////AP//////////nAQAAAAAAAAAAAAAAAAAAAAAAACQ//////////////8A/////////7gEAAAAAAAAAAAAAAAAAAAAAAAAAACg/////////////wD////////wFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzo////////////AP///////3AAAAAAAAAAACyo8P/sqCwAAAAAAAAAAGT///////////8A///////4EAAAAAAAAABM+P///////FQAAAAAAAAACPT//////////wD//////7AAAAAAAAAAFPD/////////9BgAAAAAAAAApP//////////AP//////bAAAAAAAAAB4////////////fAAAAAAAAABk//////////8A//////84AAAAAAAAALz///////////+8AAAAAAAAADT//////////wD//////xwAAAAAAAAA6P///////////+QAAAAAAAAAHP//////////AP//////AAAAAAAAAAD//////////////wAAAAAAAAAA//////////8A//////8AAAAAAAAAAP//////////////AAAAAAAAAAD//////////wD//////wAAAAAAAAAA/P////////////8AAAAAAAAAAP//////////AP//////GAAAAAAAAADg////////////4AAAAAAAAAAc//////////8A//////84AAAAAAAAALT////MJHTo//+8AAAAAAAAADT//////////wD//////2wAAAAAAAAAdP///2AAABCg/3wAAAAAAAAAZP//////////AP//////rAAAAAAAAAAY9P/sCAAAAABMGAAAAAAAAACk//////////8A///////4EAAAAAAAAABU/P+0OAAAAAAAAAAAAAAACPT//////////wD///////94AAAAAAAAAAA4sPD/gAAAAAAAAAAAAABk////////////AP////////AcAAAAAAAAAAAAAAAAAAAAAAAAAAAADOT///////////8A/////////7wEAAAAAAAAAAAAAAAAAAAAAAAAAACQ/////////////wD//////////6wEAAAAAAAAAAAAAAAAAAAAAAAAABSs////////////AP///////////7gUAAAAAAAAAAAAAAAAAAAAAAAAAABAwP////////8A//////////////BwDAAAAAAAAAAAAAAABAgAAAAAAAA8/////////wD////////////////0qGg0GAAAABgwXJjkxBgAAAAAALD/////////AP//////////////////////////////////5DQAAAAk/P////////8A////////////////////////////////////+GwAAJD//////////wD//////////////////////////////////////8A49P//////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'R' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////wAAAAAAAAAAAAAAAAAAAAQgOGSk+P///////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAcuP//////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAEsP////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ6P///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB8////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAADD///////////8A/////////wAAAAAAAAAA///////svDgAAAAAAAAACP///////////wD/////////AAAAAAAAAAD/////////7AAAAAAAAAAA////////////AP////////8AAAAAAAAAAP/////////cAAAAAAAAABD///////////8A/////////wAAAAAAAAAA//////DQoCQAAAAAAAAAQP///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACU////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAIPj///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAzU/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAA02P//////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAxctPz///////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAEDY/////////////////wD/////////AAAAAAAAAAD/9LAsAAAAAAAAAAzc////////////////AP////////8AAAAAAAAAAP///+wkAAAAAAAAADD8//////////////8A/////////wAAAAAAAAAA/////8QAAAAAAAAAAJD//////////////wD/////////AAAAAAAAAAD//////1QAAAAAAAAAFPD/////////////AP////////8AAAAAAAAAAP//////3AQAAAAAAAAAgP////////////8A/////////wAAAAAAAAAA////////aAAAAAAAAAAM6P///////////wD/////////AAAAAAAAAAD////////oCAAAAAAAAABs////////////AP////////8AAAAAAAAAAP////////+AAAAAAAAAAATc//////////8A/////////wAAAAAAAAAA//////////AUAAAAAAAAAFj//////////wD/////////AAAAAAAAAAD//////////5AAAAAAAAAAAND/////////AP////////8AAAAAAAAAAP//////////+CQAAAAAAAAAQP////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'S' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP/////////////////8vHBEIAgAAAQgQHC8/P////////////////8A////////////////pCQAAAAAAAAAAAAAAAAcoP///////////////wD//////////////FwAAAAAAAAAAAAAAAAAAAAAXP//////////////AP////////////9oAAAAAAAAAAAAAAAAAAAAAAAAhP////////////8A////////////zAAAAAAAAAAAAAAAAAAAAAAAAAAI6P///////////wD///////////9cAAAAAAAAAAAAAAAAAAAAAAAAAACA////////////AP///////////xgAAAAAAAAAUOD/8KwkAAAAAAAAADj///////////8A////////////AAAAAAAAAAD0/////8wABCAgICxASP///////////wD///////////8MAAAAAAAAAMz/////////////////////////////AP///////////0AAAAAAAAAACFiQxPT///////////////////////8A////////////oAAAAAAAAAAAAAAAADBwtPT//////////////////wD////////////8QAAAAAAAAAAAAAAAAAAACFTA////////////////AP/////////////oOAAAAAAAAAAAAAAAAAAAAABM6P////////////8A///////////////4fAgAAAAAAAAAAAAAAAAAAAAY2P///////////wD/////////////////7IwwAAAAAAAAAAAAAAAAAAAo+P//////////AP/////////////////////koGw0BAAAAAAAAAAAAACU//////////8A///////////////////////////4uFgAAAAAAAAAADz//////////wD//////////2BgSEA0IBwA6P///////5QAAAAAAAAADP//////////AP//////////JAAAAAAAAACc/////////AAAAAAAAAAA//////////8A//////////9YAAAAAAAAACDo///////AAAAAAAAAABT//////////wD//////////6QAAAAAAAAAACCk7P/snBQAAAAAAAAAUP//////////AP//////////+BAAAAAAAAAAAAAAAAAAAAAAAAAAAACs//////////8A////////////kAAAAAAAAAAAAAAAAAAAAAAAAAAAOP///////////wD////////////8RAAAAAAAAAAAAAAAAAAAAAAAABjc////////////AP/////////////0PAAAAAAAAAAAAAAAAAAAAAAg2P////////////8A///////////////8hBQAAAAAAAAAAAAAAAAMdPT//////////////wD/////////////////+LRwSCAMAAAAHDhoqPT/////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'T' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD///////////////////8AAAAAAAAAAP//////////////////////AP///////////////////wAAAAAAAAAA//////////////////////8A////////////////////AAAAAAAAAAD//////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'U' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////AAAAAAAAAAD///////////8AAAAAAAAAAP//////////AP////////8AAAAAAAAAAP///////////wAAAAAAAAAA//////////8A/////////wAAAAAAAAAA////////////AAAAAAAAAAD//////////wD/////////JAAAAAAAAADk/////////+gAAAAAAAAAHP//////////AP////////9MAAAAAAAAAJz/////////nAAAAAAAAABE//////////8A/////////4gAAAAAAAAAHOj//////+ggAAAAAAAAAHz//////////wD/////////0AAAAAAAAAAAIJzs/+ykIAAAAAAAAAAA0P//////////AP//////////QAAAAAAAAAAAAAAAAAAAAAAAAAAAAED///////////8A///////////IBAAAAAAAAAAAAAAAAAAAAAAAAAAE0P///////////wD///////////+YAAAAAAAAAAAAAAAAAAAAAAAAAJj/////////////AP////////////+UBAAAAAAAAAAAAAAAAAAAAASU//////////////8A///////////////IPAAAAAAAAAAAAAAAAAAwyP///////////////wD/////////////////0IxYOCAIAAAEIEiAyP//////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'V' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD//////zAAAAAAAAAAYP//////////////ZAAAAAAAAAAw////////AP//////kAAAAAAAAAAU/P////////////8UAAAAAAAAAJD///////8A///////oBAAAAAAAAADE////////////xAAAAAAAAAAE7P///////wD///////9MAAAAAAAAAHD///////////94AAAAAAAAAEz/////////AP///////6gAAAAAAAAAJP///////////yQAAAAAAAAArP////////8A////////+BAAAAAAAAAA1P/////////YAAAAAAAAABT4/////////wD/////////aAAAAAAAAACE/////////4QAAAAAAAAAbP//////////AP/////////EAAAAAAAAADT/////////OAAAAAAAAADM//////////8A//////////8kAAAAAAAAAOT//////+QAAAAAAAAAKP///////////wD//////////4QAAAAAAAAAmP//////nAAAAAAAAACI////////////AP//////////5AAAAAAAAABE//////9EAAAAAAAABOT///////////8A////////////QAAAAAAAAAT0////9AgAAAAAAABI/////////////wD///////////+gAAAAAAAAAKT///+kAAAAAAAAAKj/////////////AP////////////QIAAAAAAAAXP///1wAAAAAAAAM+P////////////8A/////////////1wAAAAAAAAM+P/8DAAAAAAAAGT//////////////wD/////////////vAAAAAAAAAC8/7wAAAAAAAAAxP//////////////AP//////////////HAAAAAAAAGj/aAAAAAAAACT///////////////8A//////////////94AAAAAAAAHP8cAAAAAAAAhP///////////////wD//////////////9gAAAAAAAAAkAAAAAAAAADk////////////////AP///////////////zgAAAAAAAAQAAAAAAAAQP////////////////8A////////////////lAAAAAAAAAAAAAAAAACg/////////////////wD////////////////sCAAAAAAAAAAAAAAADPT/////////////////AP////////////////9QAAAAAAAAAAAAAABg//////////////////8A/////////////////7AAAAAAAAAAAAAAAMD//////////////////wD//////////////////BQAAAAAAAAAAAAc////////////////////AP//////////////////cAAAAAAAAAAAAHz///////////////////8A///////////////////MAAAAAAAAAAAA3P///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'W' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//8cAAAAAAAAALz/////4AAAAAAAAAAA6P////+8AAAAAAAAABz//wD//1QAAAAAAAAAjP////+gAAAAAAAAAACo/////4wAAAAAAAAAUP//AP//jAAAAAAAAABU/////2AAAAAAAAAAAGj/////VAAAAAAAAACM//8A///EAAAAAAAAACT/////IAAAAAAAAAAAKP////8kAAAAAAAAAMT//wD///gEAAAAAAAAAPD//+AAAAAAAAAAAAAA6P//8AAAAAAAAAAE9P//AP///zAAAAAAAAAAvP//oAAAAAAAAAAAAACo//+8AAAAAAAAADD///8A////bAAAAAAAAACM//9gAAAAAAAAAAAAAGT//4wAAAAAAAAAaP///wD///+kAAAAAAAAAFT//yAAAAAAAAAAAAAAIP//VAAAAAAAAACc////AP///9gAAAAAAAAAJP/gAAAAAAAAAAAAAAAA4P8kAAAAAAAAANT///8A/////xAAAAAAAAAA8KAAAAAAAAAAAAAAAACg8AAAAAAAAAAQ/////wD/////TAAAAAAAAAC8YAAAAAAAAAAAAAAAAGC8AAAAAAAAAET/////AP////+AAAAAAAAAAIwgAAAAAAAAAAAAAAAAIIwAAAAAAAAAfP////8A/////7gAAAAAAAAANAAAAAAAACwwAAAAAAAANAAAAAAAAACw/////wD/////8AAAAAAAAAAAAAAAAAAAdHgAAAAAAAAAAAAAAAAAAOz/////AP//////KAAAAAAAAAAAAAAAAAC4vAAAAAAAAAAAAAAAAAAg//////8A//////9gAAAAAAAAAAAAAAAACPj4CAAAAAAAAAAAAAAAAFj//////wD//////5QAAAAAAAAAAAAAAABE//9IAAAAAAAAAAAAAAAAkP//////AP//////0AAAAAAAAAAAAAAAAIj//4wAAAAAAAAAAAAAAADI//////8A///////8DAAAAAAAAAAAAAAAzP//1AAAAAAAAAAAAAAABPj//////wD///////88AAAAAAAAAAAAABT/////GAAAAAAAAAAAAAA0////////AP///////3QAAAAAAAAAAAAAWP////9gAAAAAAAAAAAAAHD///////8A////////sAAAAAAAAAAAAACg/////6QAAAAAAAAAAAAApP///////wD////////kAAAAAAAAAAAAAOT/////6AAAAAAAAAAAAADc////////AP////////8cAAAAAAAAAAAo////////MAAAAAAAAAAAEP////////8A/////////1QAAAAAAAAAAHD///////94AAAAAAAAAABM/////////wD/////////jAAAAAAAAAAAtP///////7wAAAAAAAAAAID/////////AP/////////EAAAAAAAAAAT0////////+AgAAAAAAAAAuP////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'X' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD///////9UAAAAAAAAAKz///////////+sAAAAAAAAAFD/////////AP///////+QQAAAAAAAAFOT/////////8BwAAAAAAAAM5P////////8A/////////5gAAAAAAAAATP////////9kAAAAAAAAAJD//////////wD//////////0AAAAAAAAAAoP//////wAAAAAAAAAA0/P//////////AP//////////2AgAAAAAAAAQ4P////gkAAAAAAAABMz///////////8A////////////iAAAAAAAAABA////dAAAAAAAAABw/////////////wD////////////8MAAAAAAAAACU/9AEAAAAAAAAHPD/////////////AP/////////////IBAAAAAAAAAzYMAAAAAAAAACs//////////////8A//////////////90AAAAAAAAABAAAAAAAAAATP///////////////wD///////////////QgAAAAAAAAAAAAAAAAAAzg////////////////AP///////////////7wAAAAAAAAAAAAAAAAAjP////////////////8A/////////////////2AAAAAAAAAAAAAAADD8/////////////////wD/////////////////7BQAAAAAAAAAAAAEyP//////////////////AP/////////////////gDAAAAAAAAAAAAAjY//////////////////8A/////////////////0AAAAAAAAAAAAAAADj8/////////////////wD///////////////+UAAAAAAAAAAAAAAAAAJD/////////////////AP//////////////4AwAAAAAAAAAAAAAAAAADOD///////////////8A//////////////9AAAAAAAAAAAAAAAAAAAAAQP///////////////wD/////////////nAAAAAAAAAAAWAAAAAAAAAAAlP//////////////AP///////////+QQAAAAAAAAAGD/YAAAAAAAAAAM4P////////////8A////////////TAAAAAAAAAAs9P/0LAAAAAAAAABM/////////////wD//////////6AAAAAAAAAADNT////UDAAAAAAAAACg////////////AP/////////kEAAAAAAAAACg//////+gAAAAAAAAABDk//////////8A/////////0wAAAAAAAAAYP////////9gAAAAAAAAAEz//////////wD///////+oAAAAAAAAACz0//////////QsAAAAAAAAAKT/////////AP//////7BQAAAAAAAAM1P///////////9QMAAAAAAAAFOz///////8A//////9UAAAAAAAAAKD//////////////6AAAAAAAAAAVP///////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'Y' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP///////1QAAAAAAAAAAGj//////////2gAAAAAAAAAAFT///////8A////////5BAAAAAAAAAAAMT////////EAAAAAAAAAAAQ5P///////wD/////////mAAAAAAAAAAAKPj/////+CgAAAAAAAAAAJj/////////AP//////////PAAAAAAAAAAAgP////+AAAAAAAAAAAA8//////////8A///////////YCAAAAAAAAAAE2P//2AQAAAAAAAAACNj//////////wD///////////+AAAAAAAAAAAA4//84AAAAAAAAAACA////////////AP////////////woAAAAAAAAAACUlAAAAAAAAAAAKPz///////////8A/////////////8gAAAAAAAAAABAQAAAAAAAAAADI/////////////wD//////////////2wAAAAAAAAAAAAAAAAAAAAAbP//////////////AP//////////////8BwAAAAAAAAAAAAAAAAAABzw//////////////8A////////////////tAAAAAAAAAAAAAAAAAAAtP///////////////wD/////////////////VAAAAAAAAAAAAAAAAFT/////////////////AP/////////////////oEAAAAAAAAAAAAAAQ6P////////////////8A//////////////////+cAAAAAAAAAAAAAJz//////////////////wD///////////////////9AAAAAAAAAAABA////////////////////AP///////////////////9gAAAAAAAAAANj///////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////8AAAAAAAAAAP////////////////////8A/////////////////////wAAAAAAAAAA/////////////////////wD/////////////////////AAAAAAAAAAD/////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ 'Z' => array(
+ 'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAQ//////////////8A/////////////////////////1AAAAAAAAAABLz//////////////wD///////////////////////98AAAAAAAAAACY////////////////AP//////////////////////pAAAAAAAAAAAaP////////////////8A/////////////////////8QIAAAAAAAAAET8/////////////////wD////////////////////gGAAAAAAAAAAo9P//////////////////AP//////////////////9CwAAAAAAAAAFNz///////////////////8A//////////////////xMAAAAAAAAAATA/////////////////////wD/////////////////eAAAAAAAAAAAnP//////////////////////AP///////////////5wAAAAAAAAAAHT///////////////////////8A///////////////ABAAAAAAAAABM/P///////////////////////wD/////////////3BQAAAAAAAAALPT/////////////////////////AP////////////QoAAAAAAAAABjg//////////////////////////8A///////////8SAAAAAAAAAAExP///////////////////////////wD//////////2wAAAAAAAAAAKD/////////////////////////////AP////////+YAAAAAAAAAAB8//////////////////////////////8A/////////wQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////wD/////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////AP////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
+ 'width' => 40
+ ),
+ );
+
+ return $_png;
+}
+
+// These define base64_encoded raw png image data used
+// when we cannot generate our own single png image
+function define_raw_pngs()
+{
+ $_png = array(
+ '0' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QKCNGXKO6AAAAB3RJTUUH0wUOEDQ6EUG1VwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAXNJREFUeNpj/M9AHGAiUt2wVvhyaqAqKyOjpG3jQwaGv+e+IUn9RwJfSjjg4iwFP1aKJD6HyyErfGGAYrquIoP5E2wK/zigu0v5wH9sChdgeKDqP1aFGhBZmxv/z0Dd4IxV4RWIpMQHIPuJAITzAqEQETx7IFQIP5CQNoJwDmALxzMQCuyjg1chnBPYwtECwr8AZN41h0p6YHOjAkTuwf//77wYuCEcFWwKOWA2fM1iZuuHcASwKYQ55c9ENuasrxgRjKlwJS+D17v/hBUeUGYwv/sfn0IRiJQZJIbxuFEFagjvSlDUQNgK2GIGqpC1JRhIfoAqxBYz0DRhn8IMJO+giKEqhMaMJBeI3AHhIKdkRPqG8DlAifqFADyasKRHO6h1Z/6fMYEwTbCmx3cWGCl8CTaFwBhGz+M2/7EpXMvOnBmIok7jBVaFz/Mi3/1pQORrhpgPyOr+M8IL0j9/gKpeLjhy5QEwoDVsYuRR3cE4IktcAJNx8cJaZBeQAAAAAElFTkSuQmCC',
+ '1' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QMi//xxVKAAAAB3RJTUUH0wUOEDYLcqnX7wAAAAlwSFlzAAALEgAACxIB0t1+/AAAAHpJREFUeNpj/M9AHGAiUh1WhR8FGUGAsMKaD9iM/I8BlmCVwVS4hoUohT8qcNiFyv2zQIWBCIV3amRwu54RKcDRAgQ1KigIcJYK7CqR3QsCFmf+Y8qgeQakbANMAz6FKjUXECbj8zWa76nm61GFw1UhI10KqVGFNFQIADdK9Zj7PsV9AAAAAElFTkSuQmCC',
+ '2' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QMwPUBEjoAAAAB3RJTUUH0wUOEDUqFe2UcgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAQxJREFUeNpj/M9AHGAiUt2owkGrkAWF93LFgStPfjCwyGiYRGijqfyPAH9aOJAkQl78RwbICkNQjdB4gUNhD7qzLLAr/CKA4YENSAoRvl7zAUJXvPmxhgfCXILVMxEQvg+IDVUhgtVqDYjkDhD7B2aQIMIx5cOTN29evLAAsaEKObBajQzmQOQMcIQjHLwQgSisIaDwBdS5LHfwK7yhAHVVyX+8CrdAA5HB5gdehQ3Yoxpd4ZcAmDqbD//xKISEIjhU//zHoxDmXQaeFRhOZ8CmzuDOf3wKf8DsDfnyH6/CHJi6P//xKjyDJethVehBpMI7DPgVwrPCCgb8AK5wDwGFcNMF8EkCASOx1QcAGUxu1untnFIAAAAASUVORK5CYII=',
+ '3' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QMxBQugk2AAAAB3RJTUUH0wUOEDU3duv4qwAAAAlwSFlzAAALEgAACxIB0t1+/AAAATdJREFUeNpj/M9AHGAiUt0IVciCzPm7ZceZB28YGBQkLHwcmNFU/keANRJI4ioH/qMAJIUlaHatwaFwBrqrOO5gVfiCB8P9KVgVVkAtnPDh/wkLCFsGq0IFiGQLiH0D06P/GWHJ7O+NOzfuXLlzQRrEhgSawHscwYPurxAcwQMBf/4/aIAYyHIGr8IEeDhO+Y9XoQNUncwOVHGMRPEDSovc+IkzrpGDCQgUbuC1WgBhhsIHfAp3vPn/oIIFKfRxKQSDGohCA4IKX0DTD7YoRAWMUJ9iyQpbn4DBBWUQ5yFEDDnFw622gXAzwBxoYvfB5sYlUI0lD/4/gWWKJdgU/tHAcKjCD6y+PsGCpo4FJbaRgmcNqkqWCThTzxkTJHXo+Ro1HA9uOPHiATDlKJj4eKCVFIzDqWgGAK7GW/haPS+zAAAAAElFTkSuQmCC',
+ '4' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QMyqWttCEAAAAB3RJTUUH0wUOEDUxn4hdngAAAAlwSFlzAAALEgAACxIB0t1+/AAAAKBJREFUeNpj/M9AHGAiUh2FCucyQgCK4H9McIAFixwWhQ8kGIhS+MWAgTiFIQzEKWxhIE7hFgbiFF7hASkQIajwjQpInuUAIYV/XMDyU/4TUlgAlk75T0jhArCszR9CCk+AY07mxX8CCp+AY47nzH8CCn+YgOWW/CekMAYsVfMfl0JGmCBq4kNEDp2zAn0UMmItABjRvDykPTO43DgyFQIANP6pTFLWAdoAAAAASUVORK5CYII=',
+ '5' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QMzPy3XhEAAAAB3RJTUUH0wUOEDUk8lW5dQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAQpJREFUeNpj/M9AHGAiUt2oQuIVfmREBzgU3iHWxAfEKiTaRFpZnfAfAbAr/AsxUYagiVCbeQgqhPpFYmukLCOrZupRNJUIB02BCAjAZCK+/Ed2LoJZgm6bzRfsCgMw3JWAXaEBpg8uIGSRPPMBQmXc+P+iggXCnoOQZUQK1K8PgEAjGcQs7QGL6FzG5mtkcAUiyYIQYcRRUkDTLEIWR1b4ixamQMPhrKUP3rx48eDNFXmwdyFiOthixgXqaTAnBcKpwRaOS6A6Mx78fwBVx/IAm8I/KsTGzAkWNHUyb7Ar/L8GNSlK3MCRev7/v+CApC7kBUoUoAX4yQ0nHjwAWqpiE6GNFgNDoAwHAKC2Q2lMNcCmAAAAAElFTkSuQmCC',
+ '6' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QNAObRd4vAAAAB3RJTUUH0wUOEDUc2lcB6wAAAAlwSFlzAAALEgAACxIB0t1+/AAAATtJREFUeNpj/M9AHGAiUh2Gwq2puryMjKKmmSfRVf5HBkcMEBI+L1CkUBROYUE2QuMFLoVr0CzzwKHwhQC6szZgV1gAtfHI/xs2mEYywsPxp8QHEMVxQ56B4aaJiIKIiIRCPDZf74DwI/5jB4hwPAChbAgG+BWoExlOxkoysuqW3sUV4BoQ/p0SqARLB44AF4HIByDMKMCuEIu7phCrUOADNl/DgMOJ/09SIMwPC7B5hgfC1/kB4kRAOC7YrFaByM0Ac85AOCLYrFaBhSMIQNPlG2wBDg3HP2CSGU/MuEAoiKVXUWxB9cwPiG8UwEGSg5FCMNOjwZ4/byqgpqwgMoWr/MGeZ1agqWPZgSNz/Z+AqnDCf1wK/29B8qbKDhQpRtTE8HfLjjMP3jDwKJh4hKCGJSPNC6lRhTRWCABWpdoxd/bZ4QAAAABJRU5ErkJggg==',
+ '7' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QNA18/fMoAAAAB3RJTUUH0wUOEDUVo4u5TwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAM9JREFUeNpj/M9AHGAiUt2oQnorZIGzGLFJIyJ40HqGhUiFPFuQ/YUFPBGBmLcDSQybwj8OEDOW/CegsAeiruQ/AYV3OMDqTP4QUugCceCN/wQUQn1a8Z+Awj8qYHUiHwgpXAAxcMJ/Qgp1wOoEPhBSuANiYM5/QgpjIAovEFL4gweszgAz0NASxZ4vYMqHYDKDBiIWhWhWa0CS1x9CVn+8AaYsmAlZfQRC6RDMChADGTQIKjxDrMI7EEoBi0JGlMJe8AOY+sFOSCEeQHQBAABCZ7xyT9fJhwAAAABJRU5ErkJggg==',
+ '8' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QNBeBnwpSAAAAB3RJTUUH0wUOEDUOKe5wowAAAAlwSFlzAAALEgAACxIB0t1+/AAAATVJREFUeNpj/M9AHGAiUt1AKmRB459cc+DBGwYWGQ2LEG1Umf/I4IELkozLA2QpFIUXJFDMEDiBQ+EHGTR3yHzArrAFwwct2BXqQGQ1zvw/owFh6mBXCDXmDJB5BsOrjEhxzfoHIgkiGCGB9xtrgEPtOwvEV6FWY4+ZAAgVc5LhZgKEGYI9wN+gBiPu4Pl/BFWlxA1cMfN/C0rUr8AVhX8K0KyuwaEwASNmarAqPACVTXnw/0oENBFewKYQGhYZYE4MVBM2hVAvQ1LhHQhHBVsUMjIgYhCdhy3PPASTd6GOxBYz0KhOQHajDjY3pkC1Rlz5fweqjqEAm8ILGK5gYLlDZICXYI+ZLzZo6gL+4EgUfyo4kJQJtCCpQ8kKQPB2zZ47L14AU5iMgUMAN7IM43AqHwdQIQAhMPz6Gz5V/wAAAABJRU5ErkJggg==',
+ '9' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QNCQ+T2tEAAAAB3RJTUUH0wUOEDUHUDLIBwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAUZJREFUeNpj/M9AHGAiUh26wr9rE3V5GRlFTTM3/kVT+R8Z7FBBSKjsQJFCUTiFBcWMCbgUHmBBs20FdoV/VNDUMQi8wapwDVS65s2fPToQZgFWhRFIkm8kwGyeH9gUQm2+Aua0QDhb4LJI4XgHQmmDSRMIZw+emIEENAeEcwObQhEIdQHiABRbUGPGBSIQAWL/gHqbB5tnJkC1Fjz5f8IGwxwkhR8EsCQarFE4hViF/wsQCgKgHsSu8H8HLFkUQL2rgUPh/zslOiwMEjFH/kND2geXQvQgqMAWhSjgAIRygAswIuXCpXfevHjz4M0ZdQaGhxo/wAnyBTuWmPnvARGxuPH/iAa+9Ph/A7r9Ai+wK/zvg6ZwzX8cCl9oICtjmfIfl8L/bwIQ6gyO/Met8P//EwUmwHTJo5OyBU2CkdaF1KhCWisEAM/sJxmZkdWnAAAAAElFTkSuQmCC',
+ 'A' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QFwy1U7TfAAAAB3RJTUUH0wUOEC0ZKCZtPQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAO1JREFUeNrt1LERwiAUBuAHZ2GRwsIypQMwQEZwgBQpM4QDZBSLFI7gCA5gQWGRdA5gkTuMSh48eMTUnq96wH98B+QiDCwruTD3D76qF676ueAp0Y9lSBXeSkFWaLAje3T+kkzK4SgpBzZw8pqxJWcdOJuRsyGPbWDk0tS20zw9SXsobdfytJVXdzNsP61i6Zt3K7Ht0UeUgbPdjsrOXMd+2IS2C2qb271HVWi7YANcNXFQsUEVBTXwNdl46jYRxPl52dnwRUZbhkLSDmS8DnxFRWiULxg8UxvobefuRR8ZQYDKtffVVcQWv/RrfgJC4bd0upw4MQAAAABJRU5ErkJggg==',
+ 'B' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGAusrz2zAAAAB3RJTUUH0wUOEC01Gv4B3gAAAAlwSFlzAAALEgAACxIB0t1+/AAAANJJREFUeNpj/M9AHGAiUh0tFTKiAUHL2rsoKv9DARZDWFr+IwA+hQwMFcQqZDhCrMIIYhWK4FYIYv8444PuV+wK//9/A+UJwBUSCHAL3OEIsdoFyttCpGdiiAtHjoY/RCnk6PlBbBRKrCE6CqcQq5DlDs5whIT3CgUI788EvOEIBCegXB2YPCNMBSNMISqf5TeUjysK90LpP/itfrFEAhZCMHkWdKMYUbk2MAah7BqD02pUYEFkgMu8IE6hD0IdpmegwSejoKLjoY7syaFU7A0HhQA2e4cJytImvAAAAABJRU5ErkJggg==',
+ 'C' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGBbPqVFqAAAAB3RJTUUH0wUOEC4BEGemqAAAAAlwSFlzAAALEgAACxIB0t1+/AAAASlJREFUeNpj/M9AHGAiUt2owkGrkAWV+3TDgRtPPjBwyGiYBOijSv1HAlcCkGUcTiDLISvsQDOeZQp2hQWYDpuCTeEEbD44ganwDgc2vxpgKoyAyUWc+f9hjgCMtwFd4RuYRxog/ueBcl3QFc6BSmj8gfBrwE40yFmCrjABqrAH5mSZgJ4jX7AEjwlU4Zn/OAAsrp9AaRlccc0IzdeMsBilOPWQrBDmtpfEKnwBpZ8qZq58i6IS6vscKHcBcgQYlOz4gh6OK6AKfaB8G5hN6Aq/wBLPHjB3CczCFIzUA0u2PD0v/j9pgaf1ExgK3wgwYAEOWFL4GizqWC5gyzM1mArnEJkLZ2DPhf//n3BAVmeDkq8ZUZPL3TUn7gBLCgYFBYsAcxQZRmKrDwABNsv9SJSDwwAAAABJRU5ErkJggg==',
+ 'D' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGC1+orhOAAAAB3RJTUUH0wUOEC4yr7fHvgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAM9JREFUeNpj/M9AHGAiUt1AKmSBsxiRhXlkNBxCpFFU/ocBTDMyPvxHADwKGRgUbhCpkEHiCZEKGRyIVciwArdCIPPFGg8YzwSvQiBogXFvEFD43wDKnQDl44yZGCh9glAU2sCsJqRQBkq/gMUw3G2wuP6PnU/H9PgRSgsQUvgESosQUngFSqsQUrgCSsNiCFcU7oBx9+CL6w8XamB5SeUPkelxAZEJ1+YPcQolXhCXFTTuEJULOUq+IOVrFgasQELBxMaHG1mEcTiVjwOoEADAIkCnGpmJKgAAAABJRU5ErkJggg==',
+ 'E' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGDeDwEE0AAAAB3RJTUUH0wUOEC8CkHXGUwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAD5JREFUeNpj/M9AHGAiUt2owkGrkAXGYMQqjUgJQ8EzpPsa05+D140oMYTk4KEQ4MMqZqgUhcM1czESW30AABfqB1XDnLzcAAAAAElFTkSuQmCC',
+ 'F' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGQe8AkDZAAAAB3RJTUUH0wUOEC8JB6cf2wAAAAlwSFlzAAALEgAACxIB0t1+/AAAADlJREFUeNpj/M9AHGAiUt3wUsiCYDJikUYE3lDwDDm+xvTp4HUjIoaQXTsUAnxYxcyoQryAcUSWuAAW/gZTg/yEMAAAAABJRU5ErkJggg==',
+ 'G' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGRFI1vWIAAAAB3RJTUUH0wUOEC8QY8y3GwAAAAlwSFlzAAALEgAACxIB0t1+/AAAASZJREFUeNpj/M9AHGAiUt0IVciCwvt7ZM+FOy8+MDBwSEho2AQII8v9R4A/U2RQtHEUfEBIIim8YYBhn8oNLAqP8GBxmcwbDIU3sKljYIhAV/jHgAE7uICmcAJMQqDmwp//D2YowPgxqAr/wPyr8QAi8EEHwleIQFW4BxYicG+eEHEomHECET5QhRVQhQn/cQFoFJ6AKgwgFNcPoFwdnAoZIXmGERahKDwkIdqlR1j4PiRW4RVCCmExvQenQrSYEXiDiAoUBfC4loAK23yBSnzArhCRehRmAJPFnRUxHDgU/lDA7zZECj/Cgl2dAkaeWYNVZcoHDIX/94hgKLM4gS27/v9QIICizGMDkiQjSon7c8eBCw+e/GFgkZEwsHCRRpZiHE5FMwCa2YE+WcAOUwAAAABJRU5ErkJggg==',
+ 'H' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGRw2Z4k1AAAAB3RJTUUH0wUOEC8agxleBQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAD1JREFUeNpj/M9AHGAiUt2oQvyABUozQml4+KMLDAXPDAWFLGh8RlwKh4JnaB88GOlxELhxVCFewDgEynAAN2sFVHAvevkAAAAASUVORK5CYII=',
+ 'I' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGSlg1E0WAAAAB3RJTUUH0wUOEC86uHd+zQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAD5JREFUeNpj/M9AHGAiUt1AKmRBMBkxJJE9OhQ8Q32FjGhxDQsjjCQwFDwzqnCwKkRKZqO5EBMwDqcSl2iFAMMeB0s/kLo2AAAAAElFTkSuQmCC',
+ 'J' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QGywiiNsbAAAAB3RJTUUH0wUOEDAFw0tdbgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAKdJREFUeNpj/M9AHGAiUh3xClmwijJCaSR3Ud/qUYWjCklTyIHEhifctw8ePHgCxO+B7L9QMQlsChW+QOiX4gwMd6BiItisVoHSB6AYWQwM/kNBBszkC/9PwKyc8B8B4Ar3YPHMHWwK/xtgqAv4j1XhEfScK/EEu8L/a1BVStz4j0Ph/yPItoe8QFH3nxGlkNq75cKDB0DDVBwitNEcwjhwpdmoQrwAAN6ioiFapgUdAAAAAElFTkSuQmCC',
+ 'K' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHAEoFhGpAAAAB3RJTUUH0wUOEDANzZDVXAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAPZJREFUeNpj/M9AHGAiUt2owgFSyAgFMOGDrDARxkKo0H8wYEDh/b/AAzepACqEVeEdCQx1WBW+0ICry/mPR+EXE7i6kD94FP5xwaYOi8IIrOowFRbA1Xkgq8NQ2ANXZ/PlPx6FS3CpQ1fIAmOIoKn7jxbXf2CMNxvQIxvVRAQQ+YDXaiSQQqxChiOEFGoIQGidP/gVStxogLI68CqUuPH/BzSVcTzAoxCo7v//ObBIxK0QrO7/H1iCXIFT4QkIFxbaMh9wKYQJO0D5OYQUnoDF/QkCCuHJ1+APAYV3YOloAgGF8JTO84SAwjfQiGQIgPAZqV4rAACnKSarzdlc4gAAAABJRU5ErkJggg==',
+ 'L' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHA64qQw4AAAAB3RJTUUH0wUOEDAXMPIsJgAAAAlwSFlzAAALEgAACxIB0t1+/AAAADlJREFUeNpj/M9AHGAiUt2QUMiCYDJCaezhMBQ8M6pwVCEdFLJgCjEisRH5Zyh4hvoKGUdkQUq0QgARaARRV9jUFQAAAABJRU5ErkJggg==',
+ 'M' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHBhMfblpAAAAB3RJTUUH0wUOEDAqaJpgNwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAPNJREFUeNrdlK0OgzAUhS8bCQYxMYmcmEAgEAgejQfZQyG2pAIxOYlATkAu691o2tvSYia2iv7lyzn3NG0jhG1tt5H7Aggom7ZuaKPhBFqKV+pFWDGjjcxStEAYXuvBkrKtoVX+gdRiK9i6sxjgeVGUMJzWwZLACaZOTqoAOAronmrlBuvPkQsIgHn8BqnE2AMmhaaYJ57jqTRFMwsDyW249XaJLhAujizm7UFM5XCUXTqiTvBLQYWRc7H3WWt+3NmlyGbOGh9q/45mjQxUb+CA6A2jSqu5MweX0ooQWLJxLYx6fz0GwmBOsww5GP3At/dX4Ayb7qpFI9y5ygAAAABJRU5ErkJggg==',
+ 'N' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHC6DxyzwAAAAB3RJTUUH0wUOEDAye/b4YQAAAAlwSFlzAAALEgAACxIB0t1+/AAAALRJREFUeNpj/M9AHGAiUt0IV8gIARsRMlAROP8/BEB5Ii/+/0cVgXNRhRk8iFXIMIFYhRxXiFTIYPCDSIUMBcQqZNhDrEKZN0QqZAggViHDHIIKRSAUzx1CCrdAaZM/BBT+z4Eyaggp/KEDYbAcIaDw/wUWCEuBkML/PagBgFvhfxdiFT4RIVLh/zXEKvyfQqzCLypEKvx/hoVIhf9biFX4x4ZIhf8fCBCp8P8KNBHG4VQ0AwDEOyeZhO5p1AAAAABJRU5ErkJggg==',
+ 'O' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHQExDSDoAAAAB3RJTUUH0wUOEDA4myMRfwAAAAlwSFlzAAALEgAACxIB0t1+/AAAATtJREFUeNpj/M9AHGAiUt3wUsiCyv265ciZJ08YGGRkDGwCuFGk/iOBDwU8SDIcGS+Q5JAV7hBBs45nAVaFC1gwXTYBi8IdWNQxMCzAUPhBBJs6Bp4n6AoLYFI6az78f7NEB8ZNQFP4QwAqEfADwg+A+f0NqsI1UHGBDzCnSKC6EhYzB6B0Cj+UwZ+CKgNTeAZKu8C94QGlL6DGjAyU+wAeXC+gIiIQLiM0KzDC9CFCBlWICsnsL3aFMDc+hcs8QZWBKYSF2g24whvYFZpA6T1whUegNCwyoYGxAmYyLGZ+wOxYghqFX2BpO+APmP8nBspHj2uk1LPizf8PGyxgXPTUQ3x6JDqF//8/AYs6bHkGmCYF0O3FnguBCSaFA0kZS8IDJDlG1IIUVFK8eABMWzI6DgHCyDKMI7LEBQCD5YgI9wbKGgAAAABJRU5ErkJggg==',
+ 'P' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHQvR2Mn2AAAAB3RJTUUH0wUOEDEDMzPJGgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAKVJREFUeNpj/M9AHGAiUh05ChlRAKdu4k5Ulf9hANMQiwf/EQCfQgaJB0QqZHAhViHDEbg0AV8vwRM8QN0v5vBAOSfw+BrMWQDl8MClGeEKGGEKQcRXHmQemTGD1RMy+N14o4MDyvGAS7NgGMaIzPHAYyIy4HhBZMy0EBmFIX+IUsjRgqQOi2fAgEVBwyVGGEUEQw2O3EbLzDWSFDIOhtJsVCEWAAC/Yt2X+2PYcgAAAABJRU5ErkJggg==',
+ 'Q' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHRxSC0wxAAAAB3RJTUUH0wUOEDEKSu9xvgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAW1JREFUeNpj/M9AHGAiUt2QUMiCzPm65cCZF08YGGRkDBx8uNFU/oeDDwU8SOIcBS/+IwOEwh0iaEYIrMCqcA4LprsmYFG4A4s6BoYFGAo/iGBTx8DzAl1hAUxKZ8WH/29W6MC4KWgKfwhAJXx+gPl/QmB+/4KqcANUXOQDVPiLBFRkCUwhJGb2wGzihzK4U6CMA6hReAbKc4F7wwFKX0CNGRkoB+HJJ1ARGZgAIziFM8J0IUIGXYjMZPaXkEJYYDyBiz+EuRFVoQKUdwWIz6qWvmRguAMVkUBVaIIUalPu9GgshIefAWrwrIHp//L/DQc4KjFiBi2uQ/7832KB5AX0uP5fAZOx2PDhfwNCIXrq+f9BhgEb4HmCkcL3YE3hSHkBnmfWYFMpsoaYXAgGDgcwFKLlaxYOCG2DqRCYrldkmIACUMIgZsaTI5Cg3IBNISp4AoovlT+EFf7/kYPkb3wK//8/YAGPGcYhUIYDAHBC9Yak1w7iAAAAAElFTkSuQmCC',
+ 'R' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHSkEuIgSAAAAB3RJTUUH0wUOEDEUsOBM3QAAAAlwSFlzAAALEgAACxIB0t1+/AAAAOZJREFUeNpj/M9AHGAiUh0NFLJAaUY0YRkJHYcQdmSh/xCAzRCZHf8RAJ9CBpYNRCpkEHgBV4jfMx+mEOVGIDDAaTWY82aPBZTLgV8hUCkaH6cbP8B8gxHgyODjgwstMDfiVIgWQyFE+lrhB3EBznOFuJgxuUFMXPPEbPmDpA53FH55osKMIoAe4F826MDMvPMfj9WgWFGBBeIf/Ar/H4FxJhBQ+B8WzCIfCCi8A4uvBgIK/2fA/POCgMIXHFBuDqH02ABLM3cIKPwgAuVHEFD4fwJM4AIBhT9goe4AFWAcAsXesFIIAEvJyZHTCSiTAAAAAElFTkSuQmCC',
+ 'S' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHTRnvuTLAAAAB3RJTUUH0wUOEDEbIF9RTAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAVZJREFUeNpj/M9AHGAiUt2oQvyABYX398CWK3de/GBgkVEw8HFgRpH7jwSWqCDLyCxAlkNS+CcG3boY7AozMB3Wgk3hGSw+4HgBl0b4egIWhT9mYPGMBFQg4MH/D2tgvrKASzPC0yMjlP7CDSTOmrDIMDDwiHBsxzSRBypw5j9WgFDoAPNAxIQjX/ApXIDsC4OCLV9wKfzjwIACOEIO4IiZFxbooePzAqvC/z9qONBUStzAqvD//zc9BqgqNX5gVwgETxbkmCClvSk4FYLdsCMCptAGI2YSGV78+PLmz5MX4mDu1ByIMM9n9JiBxe4caGChy8MZMMsUIEFyAMoVwVC4BGaEwpI3/9/MEYGlJQyFPwQYsIE1mL7GlnCR0iNSXLtgqpO4gy1mvtigq1NAxCBKgP9pEUFWxlOCnNIYUYrmn3v23Ljx5gsw88sYOPhwI0sxDoEyHAABtSc836a1EQAAAABJRU5ErkJggg==',
+ 'T' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHgUdTbcyAAAAB3RJTUUH0wUOEDEgkVS4aAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADdJREFUeNpj/M9AHGAiUt0IVcgCpRlxyMODeSh4hmiFjGipB+Z7jEQ1FDwzqnBU4WBSyDicimYAb/AFTaJpyH8AAAAASUVORK5CYII=',
+ 'U' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHhEHl2NPAAAAB3RJTUUH0wUOEDEon48wWgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAKlJREFUeNpj/M9AHGAiUh3xClmgNCOUhrsEXYD6Vo8qHFVIuUIVKP0USr+E0jLoCjWg9A4ovQVNHJjUIaADZsILMPeFApRfA5X/D1N4AaZRYc6b/2+WwNQxXEBX+N8Bqxcc/mMoPMGCRR3LBUyF/2dgUTjjPxaF/6egm8ky5T9Whf9P2KCoMziBJPefEaWQurjnzIMXL34wsMhoWHiYo2hjHLjSbFQhXgAAKzejCLAOcVMAAAAASUVORK5CYII=',
+ 'V' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHh/gL05IAAAAB3RJTUUH0wUOEDEuduyVbwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAVNJREFUeNpj/M9AHGAiUt2owoFRaMgIAYlIMqlQMUMo/z8ITIByRP78hwMRqNgECBei8AULVPQIXN0RqAjLGwgfYrW4B1R4DdzmLVDaQxjZ6v8roDwVuIkqMK3/ka3+/0MAKn4FKn4D5uof/5GtZmCPgEpsQHNDBDsDitVwt5tA+RZQ/pn/qFYj3PQEzHsC5WnA3QyPmQQU3+5AE0VYDTfDBcxzgQbik/8YVv93gMp9AbK/cEAD8T+m1TBb/oD8veEHhs0IE2GmxADZMRAmz4//WKxGkv3DA2Gm/MeqcA/Ujj1w1hHsCv/LQKQz/megRzyawgqIvAxMRwsuhbCEAEvGT3AphEUwNCU5IEv9R8lcUH9/wAxE5HAEgjccSBI8X3CbKOyBxAnhxm3i/w1IEgdQZFA98/+PCFydDKo6VKsZmGPQ0wgOq/+fgYvfQTORkeq1AgCIAvD7+THsDgAAAABJRU5ErkJggg==',
+ 'W' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QFhZRKnzkAAAAB3RJTUUH0wUOEDIR66frkQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAXNJREFUeNrtlK1ywkAUhZdMZsJMKyIqKhAIBAKBiEBEVCDyCJV9iIo+Do9QGRERgUBEVCAqKhAIREVERURnTvfn3t27xSA6g+kOQ/ZkP/aec5NlBHXZSC7k/sE/AhUwoVkDPQ58/2RUQ2IC6B1XpN7MV8tg62/pUdjSDO7OwR2J0pbekpqZYlMG50bNSGwBDQ4pyV5YtCZ7mqZf1mO2IN2Jynba0XRx49pThjQCbEKWFfVRpIlBzlK4PuLdpxEWlTr4LHvYMEDOaTYS3HCW3DAJt8mmaSXYchZbOfEzkyYGZRbrEbX8qe7GMpLqFeyxV9F4fon1pwcxjxbqJpJTBPBJLoyHYSz1I3xq78aOMssepHZZHFjKhbX9/AZd6e9bsdABeyHTQXiE2PLO6PugCwiP/r1QVLYSlpXwKE1Wno7b7jY+hoWj0aegPyA9+jPrzgqwZJ0j8hhMVtElmDoD19FFPAvamc+sOXBm+KdYEzC63p/9D7Tr72kj/8qjAAAAAElFTkSuQmCC',
+ 'X' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHi/G9n7kAAAAB3RJTUUH0wUOEDIXAsROpAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAT9JREFUeNpj/M9AHGAiUt3IVhjKCAFr4RJroSKBMIH/YPBEAMITeQLh//8gAxHggQlAFf6fAdXnA+WnQPkT/qMp/O8AlVkA5h2A8kz+YCi8wQGREngA5PxQgXBYzvzHUPi/A2qIA5BdAmUX/Mei8I8BVHbK/wssEJbMB2wK/5+ASvPcgGlZ8x+rQriFAmghgKHwiwJKXPA8wKXw/x4UhT3/cSr8n4CkzuAPHoVvRODqWE6gyPxHTT1ffiAUCjCgAhRtDkgSFnisnoJixAScCh/wEBk8DmiucsChcA5MQQSMMQWrQlgiZ0iAByey5QiFPlBZnS//v+hgxjZc4QKYKVeAnCswby3AUAi3eAGKNoEn6Ap94A5EjXUfNIUrEA6EALgzl6AohCUGsAMhAOZMkTfICkMw3I5wZgiEyzicimYAFRFkVwgDfJ0AAAAASUVORK5CYII=',
+ 'Y' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHjkyIsu1AAAAB3RJTUUH0wUOEDIkvRQvsgAAAAlwSFlzAAALEgAACxIB0t1+/AAAANJJREFUeNrt1L0NgzAQBWAcUVB6AAZgBAoKhmAICoZgCAoKxmAECkbwABSUlBRILwF8duwYhFJEihJ37+6T5T9g8K6N20X3FdDDNjKKOeTIqZLtWcKBU73bCx1lPhgQNTWieY1zRLmGCZFQp1xTSSmBDUUgW754BF+GQLxAPUkMxMb0FlzUsqpKLXhxQPRqo+oIerggCvuMC7jhFJounA4gWhO2OIL6Jp/uzglHrh0fTyAaDRucQaTkUpxDQVBYDWZ/hYze6bsv/A8/DNlP/kgvwzuer4kCMGPZDgAAAABJRU5ErkJggg==',
+ 'Z' => 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAAAAACpleexAAAAFXRFWHRDcmVhdGlvbiBUaW1lAAfTBQ4QHwfqWOdfAAAAB3RJTUUH0wUOEDIrLasyIwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAL5JREFUeNrl1C0OwkAQBWCWQIJEVPQIFT0GAlHBMRBIBKIHqahAIDlERY9R0UOs3ORh5qVLunmp5GfUZvczbzKzDqtltV7ofgtueHCp16h33xBGwn0KYqoTO/J868Csaj418e0cPujOkLDfmTsECcfcXOGhoC/NZQMUDBUDd5DwxiAtJGzprpCw48xVQcIhM1d6KOgLc/kIBcORgXtIeGGQOyRs6Oq0g7P92YbkRE7bRZhcwhh+6nLF5f7yx30B8Z7FgxzMWtEAAAAASUVORK5CYII=',
+ );
+
+ return $_png;
+}
+
+?> \ No newline at end of file
diff --git a/main/survey/index.php b/main/survey/index.php
new file mode 100644
index 0000000..8c1769b
--- /dev/null
+++ b/main/survey/index.php
@@ -0,0 +1,41 @@
+<?php
+
+// pod do /main/survey/ - kot ROOT direktorij
+define('MAIN', __DIR__ . DIRECTORY_SEPARATOR);
+
+//direktorij app
+define('APP', MAIN . 'app' . DIRECTORY_SEPARATOR);
+
+
+require_once('../../function.php');
+
+// Register composer autoload
+require_once('../../vendor/autoload.php');
+
+
+// Nastavitve, kjer določamo PHP debuging/error
+require APP . 'config.php';
+new App\Controllers\Controller();
+
+// Definicija vseh spremenljiv, ki jih uporabljamo med razredi
+new App\Controllers\VariableClass();
+require_once(APP.'global_function.php');
+
+
+// Začasno vpisemo, ker View še ni posebej
+ob_start();
+
+header('Cache-Control: no-cache');
+header('Pragma: no-cache');
+
+echo '<!DOCTYPE html><html class="no_js">';
+
+// začetek aplikacije
+new \App\Controllers\SurveyController();
+
+echo '</body>';
+echo '</html>';
+
+ob_flush();
+
+?>
diff --git a/main/survey/js/ChartJS/Chart.bundle.js b/main/survey/js/ChartJS/Chart.bundle.js
new file mode 100644
index 0000000..9268e16
--- /dev/null
+++ b/main/survey/js/ChartJS/Chart.bundle.js
@@ -0,0 +1,18608 @@
+/*!
+ * Chart.js
+ * http://chartjs.org/
+ * Version: 2.7.1
+ *
+ * Copyright 2017 Nick Downie
+ * Released under the MIT license
+ * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
+ */
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Chart = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+/* MIT license */
+var colorNames = require(5);
+
+module.exports = {
+ getRgba: getRgba,
+ getHsla: getHsla,
+ getRgb: getRgb,
+ getHsl: getHsl,
+ getHwb: getHwb,
+ getAlpha: getAlpha,
+
+ hexString: hexString,
+ rgbString: rgbString,
+ rgbaString: rgbaString,
+ percentString: percentString,
+ percentaString: percentaString,
+ hslString: hslString,
+ hslaString: hslaString,
+ hwbString: hwbString,
+ keyword: keyword
+}
+
+function getRgba(string) {
+ if (!string) {
+ return;
+ }
+ var abbr = /^#([a-fA-F0-9]{3})$/i,
+ hex = /^#([a-fA-F0-9]{6})$/i,
+ rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i,
+ per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i,
+ keyword = /(\w+)/;
+
+ var rgb = [0, 0, 0],
+ a = 1,
+ match = string.match(abbr);
+ if (match) {
+ match = match[1];
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = parseInt(match[i] + match[i], 16);
+ }
+ }
+ else if (match = string.match(hex)) {
+ match = match[1];
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = parseInt(match.slice(i * 2, i * 2 + 2), 16);
+ }
+ }
+ else if (match = string.match(rgba)) {
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = parseInt(match[i + 1]);
+ }
+ a = parseFloat(match[4]);
+ }
+ else if (match = string.match(per)) {
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
+ }
+ a = parseFloat(match[4]);
+ }
+ else if (match = string.match(keyword)) {
+ if (match[1] == "transparent") {
+ return [0, 0, 0, 0];
+ }
+ rgb = colorNames[match[1]];
+ if (!rgb) {
+ return;
+ }
+ }
+
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = scale(rgb[i], 0, 255);
+ }
+ if (!a && a != 0) {
+ a = 1;
+ }
+ else {
+ a = scale(a, 0, 1);
+ }
+ rgb[3] = a;
+ return rgb;
+}
+
+function getHsla(string) {
+ if (!string) {
+ return;
+ }
+ var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
+ var match = string.match(hsl);
+ if (match) {
+ var alpha = parseFloat(match[4]);
+ var h = scale(parseInt(match[1]), 0, 360),
+ s = scale(parseFloat(match[2]), 0, 100),
+ l = scale(parseFloat(match[3]), 0, 100),
+ a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
+ return [h, s, l, a];
+ }
+}
+
+function getHwb(string) {
+ if (!string) {
+ return;
+ }
+ var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
+ var match = string.match(hwb);
+ if (match) {
+ var alpha = parseFloat(match[4]);
+ var h = scale(parseInt(match[1]), 0, 360),
+ w = scale(parseFloat(match[2]), 0, 100),
+ b = scale(parseFloat(match[3]), 0, 100),
+ a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
+ return [h, w, b, a];
+ }
+}
+
+function getRgb(string) {
+ var rgba = getRgba(string);
+ return rgba && rgba.slice(0, 3);
+}
+
+function getHsl(string) {
+ var hsla = getHsla(string);
+ return hsla && hsla.slice(0, 3);
+}
+
+function getAlpha(string) {
+ var vals = getRgba(string);
+ if (vals) {
+ return vals[3];
+ }
+ else if (vals = getHsla(string)) {
+ return vals[3];
+ }
+ else if (vals = getHwb(string)) {
+ return vals[3];
+ }
+}
+
+// generators
+function hexString(rgb) {
+ return "#" + hexDouble(rgb[0]) + hexDouble(rgb[1])
+ + hexDouble(rgb[2]);
+}
+
+function rgbString(rgba, alpha) {
+ if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
+ return rgbaString(rgba, alpha);
+ }
+ return "rgb(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2] + ")";
+}
+
+function rgbaString(rgba, alpha) {
+ if (alpha === undefined) {
+ alpha = (rgba[3] !== undefined ? rgba[3] : 1);
+ }
+ return "rgba(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2]
+ + ", " + alpha + ")";
+}
+
+function percentString(rgba, alpha) {
+ if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
+ return percentaString(rgba, alpha);
+ }
+ var r = Math.round(rgba[0]/255 * 100),
+ g = Math.round(rgba[1]/255 * 100),
+ b = Math.round(rgba[2]/255 * 100);
+
+ return "rgb(" + r + "%, " + g + "%, " + b + "%)";
+}
+
+function percentaString(rgba, alpha) {
+ var r = Math.round(rgba[0]/255 * 100),
+ g = Math.round(rgba[1]/255 * 100),
+ b = Math.round(rgba[2]/255 * 100);
+ return "rgba(" + r + "%, " + g + "%, " + b + "%, " + (alpha || rgba[3] || 1) + ")";
+}
+
+function hslString(hsla, alpha) {
+ if (alpha < 1 || (hsla[3] && hsla[3] < 1)) {
+ return hslaString(hsla, alpha);
+ }
+ return "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)";
+}
+
+function hslaString(hsla, alpha) {
+ if (alpha === undefined) {
+ alpha = (hsla[3] !== undefined ? hsla[3] : 1);
+ }
+ return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, "
+ + alpha + ")";
+}
+
+// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
+// (hwb have alpha optional & 1 is default value)
+function hwbString(hwb, alpha) {
+ if (alpha === undefined) {
+ alpha = (hwb[3] !== undefined ? hwb[3] : 1);
+ }
+ return "hwb(" + hwb[0] + ", " + hwb[1] + "%, " + hwb[2] + "%"
+ + (alpha !== undefined && alpha !== 1 ? ", " + alpha : "") + ")";
+}
+
+function keyword(rgb) {
+ return reverseNames[rgb.slice(0, 3)];
+}
+
+// helpers
+function scale(num, min, max) {
+ return Math.min(Math.max(min, num), max);
+}
+
+function hexDouble(num) {
+ var str = num.toString(16).toUpperCase();
+ return (str.length < 2) ? "0" + str : str;
+}
+
+
+//create a list of reverse color names
+var reverseNames = {};
+for (var name in colorNames) {
+ reverseNames[colorNames[name]] = name;
+}
+
+},{"5":5}],2:[function(require,module,exports){
+/* MIT license */
+var convert = require(4);
+var string = require(1);
+
+var Color = function (obj) {
+ if (obj instanceof Color) {
+ return obj;
+ }
+ if (!(this instanceof Color)) {
+ return new Color(obj);
+ }
+
+ this.valid = false;
+ this.values = {
+ rgb: [0, 0, 0],
+ hsl: [0, 0, 0],
+ hsv: [0, 0, 0],
+ hwb: [0, 0, 0],
+ cmyk: [0, 0, 0, 0],
+ alpha: 1
+ };
+
+ // parse Color() argument
+ var vals;
+ if (typeof obj === 'string') {
+ vals = string.getRgba(obj);
+ if (vals) {
+ this.setValues('rgb', vals);
+ } else if (vals = string.getHsla(obj)) {
+ this.setValues('hsl', vals);
+ } else if (vals = string.getHwb(obj)) {
+ this.setValues('hwb', vals);
+ }
+ } else if (typeof obj === 'object') {
+ vals = obj;
+ if (vals.r !== undefined || vals.red !== undefined) {
+ this.setValues('rgb', vals);
+ } else if (vals.l !== undefined || vals.lightness !== undefined) {
+ this.setValues('hsl', vals);
+ } else if (vals.v !== undefined || vals.value !== undefined) {
+ this.setValues('hsv', vals);
+ } else if (vals.w !== undefined || vals.whiteness !== undefined) {
+ this.setValues('hwb', vals);
+ } else if (vals.c !== undefined || vals.cyan !== undefined) {
+ this.setValues('cmyk', vals);
+ }
+ }
+};
+
+Color.prototype = {
+ isValid: function () {
+ return this.valid;
+ },
+ rgb: function () {
+ return this.setSpace('rgb', arguments);
+ },
+ hsl: function () {
+ return this.setSpace('hsl', arguments);
+ },
+ hsv: function () {
+ return this.setSpace('hsv', arguments);
+ },
+ hwb: function () {
+ return this.setSpace('hwb', arguments);
+ },
+ cmyk: function () {
+ return this.setSpace('cmyk', arguments);
+ },
+
+ rgbArray: function () {
+ return this.values.rgb;
+ },
+ hslArray: function () {
+ return this.values.hsl;
+ },
+ hsvArray: function () {
+ return this.values.hsv;
+ },
+ hwbArray: function () {
+ var values = this.values;
+ if (values.alpha !== 1) {
+ return values.hwb.concat([values.alpha]);
+ }
+ return values.hwb;
+ },
+ cmykArray: function () {
+ return this.values.cmyk;
+ },
+ rgbaArray: function () {
+ var values = this.values;
+ return values.rgb.concat([values.alpha]);
+ },
+ hslaArray: function () {
+ var values = this.values;
+ return values.hsl.concat([values.alpha]);
+ },
+ alpha: function (val) {
+ if (val === undefined) {
+ return this.values.alpha;
+ }
+ this.setValues('alpha', val);
+ return this;
+ },
+
+ red: function (val) {
+ return this.setChannel('rgb', 0, val);
+ },
+ green: function (val) {
+ return this.setChannel('rgb', 1, val);
+ },
+ blue: function (val) {
+ return this.setChannel('rgb', 2, val);
+ },
+ hue: function (val) {
+ if (val) {
+ val %= 360;
+ val = val < 0 ? 360 + val : val;
+ }
+ return this.setChannel('hsl', 0, val);
+ },
+ saturation: function (val) {
+ return this.setChannel('hsl', 1, val);
+ },
+ lightness: function (val) {
+ return this.setChannel('hsl', 2, val);
+ },
+ saturationv: function (val) {
+ return this.setChannel('hsv', 1, val);
+ },
+ whiteness: function (val) {
+ return this.setChannel('hwb', 1, val);
+ },
+ blackness: function (val) {
+ return this.setChannel('hwb', 2, val);
+ },
+ value: function (val) {
+ return this.setChannel('hsv', 2, val);
+ },
+ cyan: function (val) {
+ return this.setChannel('cmyk', 0, val);
+ },
+ magenta: function (val) {
+ return this.setChannel('cmyk', 1, val);
+ },
+ yellow: function (val) {
+ return this.setChannel('cmyk', 2, val);
+ },
+ black: function (val) {
+ return this.setChannel('cmyk', 3, val);
+ },
+
+ hexString: function () {
+ return string.hexString(this.values.rgb);
+ },
+ rgbString: function () {
+ return string.rgbString(this.values.rgb, this.values.alpha);
+ },
+ rgbaString: function () {
+ return string.rgbaString(this.values.rgb, this.values.alpha);
+ },
+ percentString: function () {
+ return string.percentString(this.values.rgb, this.values.alpha);
+ },
+ hslString: function () {
+ return string.hslString(this.values.hsl, this.values.alpha);
+ },
+ hslaString: function () {
+ return string.hslaString(this.values.hsl, this.values.alpha);
+ },
+ hwbString: function () {
+ return string.hwbString(this.values.hwb, this.values.alpha);
+ },
+ keyword: function () {
+ return string.keyword(this.values.rgb, this.values.alpha);
+ },
+
+ rgbNumber: function () {
+ var rgb = this.values.rgb;
+ return (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
+ },
+
+ luminosity: function () {
+ // http://www.w3.org/TR/WCAG20/#relativeluminancedef
+ var rgb = this.values.rgb;
+ var lum = [];
+ for (var i = 0; i < rgb.length; i++) {
+ var chan = rgb[i] / 255;
+ lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
+ }
+ return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
+ },
+
+ contrast: function (color2) {
+ // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
+ var lum1 = this.luminosity();
+ var lum2 = color2.luminosity();
+ if (lum1 > lum2) {
+ return (lum1 + 0.05) / (lum2 + 0.05);
+ }
+ return (lum2 + 0.05) / (lum1 + 0.05);
+ },
+
+ level: function (color2) {
+ var contrastRatio = this.contrast(color2);
+ if (contrastRatio >= 7.1) {
+ return 'AAA';
+ }
+
+ return (contrastRatio >= 4.5) ? 'AA' : '';
+ },
+
+ dark: function () {
+ // YIQ equation from http://24ways.org/2010/calculating-color-contrast
+ var rgb = this.values.rgb;
+ var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
+ return yiq < 128;
+ },
+
+ light: function () {
+ return !this.dark();
+ },
+
+ negate: function () {
+ var rgb = [];
+ for (var i = 0; i < 3; i++) {
+ rgb[i] = 255 - this.values.rgb[i];
+ }
+ this.setValues('rgb', rgb);
+ return this;
+ },
+
+ lighten: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[2] += hsl[2] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ darken: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[2] -= hsl[2] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ saturate: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[1] += hsl[1] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ desaturate: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[1] -= hsl[1] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ whiten: function (ratio) {
+ var hwb = this.values.hwb;
+ hwb[1] += hwb[1] * ratio;
+ this.setValues('hwb', hwb);
+ return this;
+ },
+
+ blacken: function (ratio) {
+ var hwb = this.values.hwb;
+ hwb[2] += hwb[2] * ratio;
+ this.setValues('hwb', hwb);
+ return this;
+ },
+
+ greyscale: function () {
+ var rgb = this.values.rgb;
+ // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
+ var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
+ this.setValues('rgb', [val, val, val]);
+ return this;
+ },
+
+ clearer: function (ratio) {
+ var alpha = this.values.alpha;
+ this.setValues('alpha', alpha - (alpha * ratio));
+ return this;
+ },
+
+ opaquer: function (ratio) {
+ var alpha = this.values.alpha;
+ this.setValues('alpha', alpha + (alpha * ratio));
+ return this;
+ },
+
+ rotate: function (degrees) {
+ var hsl = this.values.hsl;
+ var hue = (hsl[0] + degrees) % 360;
+ hsl[0] = hue < 0 ? 360 + hue : hue;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ /**
+ * Ported from sass implementation in C
+ * https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
+ */
+ mix: function (mixinColor, weight) {
+ var color1 = this;
+ var color2 = mixinColor;
+ var p = weight === undefined ? 0.5 : weight;
+
+ var w = 2 * p - 1;
+ var a = color1.alpha() - color2.alpha();
+
+ var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
+ var w2 = 1 - w1;
+
+ return this
+ .rgb(
+ w1 * color1.red() + w2 * color2.red(),
+ w1 * color1.green() + w2 * color2.green(),
+ w1 * color1.blue() + w2 * color2.blue()
+ )
+ .alpha(color1.alpha() * p + color2.alpha() * (1 - p));
+ },
+
+ toJSON: function () {
+ return this.rgb();
+ },
+
+ clone: function () {
+ // NOTE(SB): using node-clone creates a dependency to Buffer when using browserify,
+ // making the final build way to big to embed in Chart.js. So let's do it manually,
+ // assuming that values to clone are 1 dimension arrays containing only numbers,
+ // except 'alpha' which is a number.
+ var result = new Color();
+ var source = this.values;
+ var target = result.values;
+ var value, type;
+
+ for (var prop in source) {
+ if (source.hasOwnProperty(prop)) {
+ value = source[prop];
+ type = ({}).toString.call(value);
+ if (type === '[object Array]') {
+ target[prop] = value.slice(0);
+ } else if (type === '[object Number]') {
+ target[prop] = value;
+ } else {
+ console.error('unexpected color value:', value);
+ }
+ }
+ }
+
+ return result;
+ }
+};
+
+Color.prototype.spaces = {
+ rgb: ['red', 'green', 'blue'],
+ hsl: ['hue', 'saturation', 'lightness'],
+ hsv: ['hue', 'saturation', 'value'],
+ hwb: ['hue', 'whiteness', 'blackness'],
+ cmyk: ['cyan', 'magenta', 'yellow', 'black']
+};
+
+Color.prototype.maxes = {
+ rgb: [255, 255, 255],
+ hsl: [360, 100, 100],
+ hsv: [360, 100, 100],
+ hwb: [360, 100, 100],
+ cmyk: [100, 100, 100, 100]
+};
+
+Color.prototype.getValues = function (space) {
+ var values = this.values;
+ var vals = {};
+
+ for (var i = 0; i < space.length; i++) {
+ vals[space.charAt(i)] = values[space][i];
+ }
+
+ if (values.alpha !== 1) {
+ vals.a = values.alpha;
+ }
+
+ // {r: 255, g: 255, b: 255, a: 0.4}
+ return vals;
+};
+
+Color.prototype.setValues = function (space, vals) {
+ var values = this.values;
+ var spaces = this.spaces;
+ var maxes = this.maxes;
+ var alpha = 1;
+ var i;
+
+ this.valid = true;
+
+ if (space === 'alpha') {
+ alpha = vals;
+ } else if (vals.length) {
+ // [10, 10, 10]
+ values[space] = vals.slice(0, space.length);
+ alpha = vals[space.length];
+ } else if (vals[space.charAt(0)] !== undefined) {
+ // {r: 10, g: 10, b: 10}
+ for (i = 0; i < space.length; i++) {
+ values[space][i] = vals[space.charAt(i)];
+ }
+
+ alpha = vals.a;
+ } else if (vals[spaces[space][0]] !== undefined) {
+ // {red: 10, green: 10, blue: 10}
+ var chans = spaces[space];
+
+ for (i = 0; i < space.length; i++) {
+ values[space][i] = vals[chans[i]];
+ }
+
+ alpha = vals.alpha;
+ }
+
+ values.alpha = Math.max(0, Math.min(1, (alpha === undefined ? values.alpha : alpha)));
+
+ if (space === 'alpha') {
+ return false;
+ }
+
+ var capped;
+
+ // cap values of the space prior converting all values
+ for (i = 0; i < space.length; i++) {
+ capped = Math.max(0, Math.min(maxes[space][i], values[space][i]));
+ values[space][i] = Math.round(capped);
+ }
+
+ // convert to all the other color spaces
+ for (var sname in spaces) {
+ if (sname !== space) {
+ values[sname] = convert[space][sname](values[space]);
+ }
+ }
+
+ return true;
+};
+
+Color.prototype.setSpace = function (space, args) {
+ var vals = args[0];
+
+ if (vals === undefined) {
+ // color.rgb()
+ return this.getValues(space);
+ }
+
+ // color.rgb(10, 10, 10)
+ if (typeof vals === 'number') {
+ vals = Array.prototype.slice.call(args);
+ }
+
+ this.setValues(space, vals);
+ return this;
+};
+
+Color.prototype.setChannel = function (space, index, val) {
+ var svalues = this.values[space];
+ if (val === undefined) {
+ // color.red()
+ return svalues[index];
+ } else if (val === svalues[index]) {
+ // color.red(color.red())
+ return this;
+ }
+
+ // color.red(100)
+ svalues[index] = val;
+ this.setValues(space, svalues);
+
+ return this;
+};
+
+if (typeof window !== 'undefined') {
+ window.Color = Color;
+}
+
+module.exports = Color;
+
+},{"1":1,"4":4}],3:[function(require,module,exports){
+/* MIT license */
+
+module.exports = {
+ rgb2hsl: rgb2hsl,
+ rgb2hsv: rgb2hsv,
+ rgb2hwb: rgb2hwb,
+ rgb2cmyk: rgb2cmyk,
+ rgb2keyword: rgb2keyword,
+ rgb2xyz: rgb2xyz,
+ rgb2lab: rgb2lab,
+ rgb2lch: rgb2lch,
+
+ hsl2rgb: hsl2rgb,
+ hsl2hsv: hsl2hsv,
+ hsl2hwb: hsl2hwb,
+ hsl2cmyk: hsl2cmyk,
+ hsl2keyword: hsl2keyword,
+
+ hsv2rgb: hsv2rgb,
+ hsv2hsl: hsv2hsl,
+ hsv2hwb: hsv2hwb,
+ hsv2cmyk: hsv2cmyk,
+ hsv2keyword: hsv2keyword,
+
+ hwb2rgb: hwb2rgb,
+ hwb2hsl: hwb2hsl,
+ hwb2hsv: hwb2hsv,
+ hwb2cmyk: hwb2cmyk,
+ hwb2keyword: hwb2keyword,
+
+ cmyk2rgb: cmyk2rgb,
+ cmyk2hsl: cmyk2hsl,
+ cmyk2hsv: cmyk2hsv,
+ cmyk2hwb: cmyk2hwb,
+ cmyk2keyword: cmyk2keyword,
+
+ keyword2rgb: keyword2rgb,
+ keyword2hsl: keyword2hsl,
+ keyword2hsv: keyword2hsv,
+ keyword2hwb: keyword2hwb,
+ keyword2cmyk: keyword2cmyk,
+ keyword2lab: keyword2lab,
+ keyword2xyz: keyword2xyz,
+
+ xyz2rgb: xyz2rgb,
+ xyz2lab: xyz2lab,
+ xyz2lch: xyz2lch,
+
+ lab2xyz: lab2xyz,
+ lab2rgb: lab2rgb,
+ lab2lch: lab2lch,
+
+ lch2lab: lch2lab,
+ lch2xyz: lch2xyz,
+ lch2rgb: lch2rgb
+}
+
+
+function rgb2hsl(rgb) {
+ var r = rgb[0]/255,
+ g = rgb[1]/255,
+ b = rgb[2]/255,
+ min = Math.min(r, g, b),
+ max = Math.max(r, g, b),
+ delta = max - min,
+ h, s, l;
+
+ if (max == min)
+ h = 0;
+ else if (r == max)
+ h = (g - b) / delta;
+ else if (g == max)
+ h = 2 + (b - r) / delta;
+ else if (b == max)
+ h = 4 + (r - g)/ delta;
+
+ h = Math.min(h * 60, 360);
+
+ if (h < 0)
+ h += 360;
+
+ l = (min + max) / 2;
+
+ if (max == min)
+ s = 0;
+ else if (l <= 0.5)
+ s = delta / (max + min);
+ else
+ s = delta / (2 - max - min);
+
+ return [h, s * 100, l * 100];
+}
+
+function rgb2hsv(rgb) {
+ var r = rgb[0],
+ g = rgb[1],
+ b = rgb[2],
+ min = Math.min(r, g, b),
+ max = Math.max(r, g, b),
+ delta = max - min,
+ h, s, v;
+
+ if (max == 0)
+ s = 0;
+ else
+ s = (delta/max * 1000)/10;
+
+ if (max == min)
+ h = 0;
+ else if (r == max)
+ h = (g - b) / delta;
+ else if (g == max)
+ h = 2 + (b - r) / delta;
+ else if (b == max)
+ h = 4 + (r - g) / delta;
+
+ h = Math.min(h * 60, 360);
+
+ if (h < 0)
+ h += 360;
+
+ v = ((max / 255) * 1000) / 10;
+
+ return [h, s, v];
+}
+
+function rgb2hwb(rgb) {
+ var r = rgb[0],
+ g = rgb[1],
+ b = rgb[2],
+ h = rgb2hsl(rgb)[0],
+ w = 1/255 * Math.min(r, Math.min(g, b)),
+ b = 1 - 1/255 * Math.max(r, Math.max(g, b));
+
+ return [h, w * 100, b * 100];
+}
+
+function rgb2cmyk(rgb) {
+ var r = rgb[0] / 255,
+ g = rgb[1] / 255,
+ b = rgb[2] / 255,
+ c, m, y, k;
+
+ k = Math.min(1 - r, 1 - g, 1 - b);
+ c = (1 - r - k) / (1 - k) || 0;
+ m = (1 - g - k) / (1 - k) || 0;
+ y = (1 - b - k) / (1 - k) || 0;
+ return [c * 100, m * 100, y * 100, k * 100];
+}
+
+function rgb2keyword(rgb) {
+ return reverseKeywords[JSON.stringify(rgb)];
+}
+
+function rgb2xyz(rgb) {
+ var r = rgb[0] / 255,
+ g = rgb[1] / 255,
+ b = rgb[2] / 255;
+
+ // assume sRGB
+ r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
+ g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
+ b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
+
+ var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
+ var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
+ var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
+
+ return [x * 100, y *100, z * 100];
+}
+
+function rgb2lab(rgb) {
+ var xyz = rgb2xyz(rgb),
+ x = xyz[0],
+ y = xyz[1],
+ z = xyz[2],
+ l, a, b;
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
+
+ l = (116 * y) - 16;
+ a = 500 * (x - y);
+ b = 200 * (y - z);
+
+ return [l, a, b];
+}
+
+function rgb2lch(args) {
+ return lab2lch(rgb2lab(args));
+}
+
+function hsl2rgb(hsl) {
+ var h = hsl[0] / 360,
+ s = hsl[1] / 100,
+ l = hsl[2] / 100,
+ t1, t2, t3, rgb, val;
+
+ if (s == 0) {
+ val = l * 255;
+ return [val, val, val];
+ }
+
+ if (l < 0.5)
+ t2 = l * (1 + s);
+ else
+ t2 = l + s - l * s;
+ t1 = 2 * l - t2;
+
+ rgb = [0, 0, 0];
+ for (var i = 0; i < 3; i++) {
+ t3 = h + 1 / 3 * - (i - 1);
+ t3 < 0 && t3++;
+ t3 > 1 && t3--;
+
+ if (6 * t3 < 1)
+ val = t1 + (t2 - t1) * 6 * t3;
+ else if (2 * t3 < 1)
+ val = t2;
+ else if (3 * t3 < 2)
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
+ else
+ val = t1;
+
+ rgb[i] = val * 255;
+ }
+
+ return rgb;
+}
+
+function hsl2hsv(hsl) {
+ var h = hsl[0],
+ s = hsl[1] / 100,
+ l = hsl[2] / 100,
+ sv, v;
+
+ if(l === 0) {
+ // no need to do calc on black
+ // also avoids divide by 0 error
+ return [0, 0, 0];
+ }
+
+ l *= 2;
+ s *= (l <= 1) ? l : 2 - l;
+ v = (l + s) / 2;
+ sv = (2 * s) / (l + s);
+ return [h, sv * 100, v * 100];
+}
+
+function hsl2hwb(args) {
+ return rgb2hwb(hsl2rgb(args));
+}
+
+function hsl2cmyk(args) {
+ return rgb2cmyk(hsl2rgb(args));
+}
+
+function hsl2keyword(args) {
+ return rgb2keyword(hsl2rgb(args));
+}
+
+
+function hsv2rgb(hsv) {
+ var h = hsv[0] / 60,
+ s = hsv[1] / 100,
+ v = hsv[2] / 100,
+ hi = Math.floor(h) % 6;
+
+ var f = h - Math.floor(h),
+ p = 255 * v * (1 - s),
+ q = 255 * v * (1 - (s * f)),
+ t = 255 * v * (1 - (s * (1 - f))),
+ v = 255 * v;
+
+ switch(hi) {
+ case 0:
+ return [v, t, p];
+ case 1:
+ return [q, v, p];
+ case 2:
+ return [p, v, t];
+ case 3:
+ return [p, q, v];
+ case 4:
+ return [t, p, v];
+ case 5:
+ return [v, p, q];
+ }
+}
+
+function hsv2hsl(hsv) {
+ var h = hsv[0],
+ s = hsv[1] / 100,
+ v = hsv[2] / 100,
+ sl, l;
+
+ l = (2 - s) * v;
+ sl = s * v;
+ sl /= (l <= 1) ? l : 2 - l;
+ sl = sl || 0;
+ l /= 2;
+ return [h, sl * 100, l * 100];
+}
+
+function hsv2hwb(args) {
+ return rgb2hwb(hsv2rgb(args))
+}
+
+function hsv2cmyk(args) {
+ return rgb2cmyk(hsv2rgb(args));
+}
+
+function hsv2keyword(args) {
+ return rgb2keyword(hsv2rgb(args));
+}
+
+// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
+function hwb2rgb(hwb) {
+ var h = hwb[0] / 360,
+ wh = hwb[1] / 100,
+ bl = hwb[2] / 100,
+ ratio = wh + bl,
+ i, v, f, n;
+
+ // wh + bl cant be > 1
+ if (ratio > 1) {
+ wh /= ratio;
+ bl /= ratio;
+ }
+
+ i = Math.floor(6 * h);
+ v = 1 - bl;
+ f = 6 * h - i;
+ if ((i & 0x01) != 0) {
+ f = 1 - f;
+ }
+ n = wh + f * (v - wh); // linear interpolation
+
+ switch (i) {
+ default:
+ case 6:
+ case 0: r = v; g = n; b = wh; break;
+ case 1: r = n; g = v; b = wh; break;
+ case 2: r = wh; g = v; b = n; break;
+ case 3: r = wh; g = n; b = v; break;
+ case 4: r = n; g = wh; b = v; break;
+ case 5: r = v; g = wh; b = n; break;
+ }
+
+ return [r * 255, g * 255, b * 255];
+}
+
+function hwb2hsl(args) {
+ return rgb2hsl(hwb2rgb(args));
+}
+
+function hwb2hsv(args) {
+ return rgb2hsv(hwb2rgb(args));
+}
+
+function hwb2cmyk(args) {
+ return rgb2cmyk(hwb2rgb(args));
+}
+
+function hwb2keyword(args) {
+ return rgb2keyword(hwb2rgb(args));
+}
+
+function cmyk2rgb(cmyk) {
+ var c = cmyk[0] / 100,
+ m = cmyk[1] / 100,
+ y = cmyk[2] / 100,
+ k = cmyk[3] / 100,
+ r, g, b;
+
+ r = 1 - Math.min(1, c * (1 - k) + k);
+ g = 1 - Math.min(1, m * (1 - k) + k);
+ b = 1 - Math.min(1, y * (1 - k) + k);
+ return [r * 255, g * 255, b * 255];
+}
+
+function cmyk2hsl(args) {
+ return rgb2hsl(cmyk2rgb(args));
+}
+
+function cmyk2hsv(args) {
+ return rgb2hsv(cmyk2rgb(args));
+}
+
+function cmyk2hwb(args) {
+ return rgb2hwb(cmyk2rgb(args));
+}
+
+function cmyk2keyword(args) {
+ return rgb2keyword(cmyk2rgb(args));
+}
+
+
+function xyz2rgb(xyz) {
+ var x = xyz[0] / 100,
+ y = xyz[1] / 100,
+ z = xyz[2] / 100,
+ r, g, b;
+
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
+
+ // assume sRGB
+ r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
+ : r = (r * 12.92);
+
+ g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
+ : g = (g * 12.92);
+
+ b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
+ : b = (b * 12.92);
+
+ r = Math.min(Math.max(0, r), 1);
+ g = Math.min(Math.max(0, g), 1);
+ b = Math.min(Math.max(0, b), 1);
+
+ return [r * 255, g * 255, b * 255];
+}
+
+function xyz2lab(xyz) {
+ var x = xyz[0],
+ y = xyz[1],
+ z = xyz[2],
+ l, a, b;
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
+
+ l = (116 * y) - 16;
+ a = 500 * (x - y);
+ b = 200 * (y - z);
+
+ return [l, a, b];
+}
+
+function xyz2lch(args) {
+ return lab2lch(xyz2lab(args));
+}
+
+function lab2xyz(lab) {
+ var l = lab[0],
+ a = lab[1],
+ b = lab[2],
+ x, y, z, y2;
+
+ if (l <= 8) {
+ y = (l * 100) / 903.3;
+ y2 = (7.787 * (y / 100)) + (16 / 116);
+ } else {
+ y = 100 * Math.pow((l + 16) / 116, 3);
+ y2 = Math.pow(y / 100, 1/3);
+ }
+
+ x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3);
+
+ z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3);
+
+ return [x, y, z];
+}
+
+function lab2lch(lab) {
+ var l = lab[0],
+ a = lab[1],
+ b = lab[2],
+ hr, h, c;
+
+ hr = Math.atan2(b, a);
+ h = hr * 360 / 2 / Math.PI;
+ if (h < 0) {
+ h += 360;
+ }
+ c = Math.sqrt(a * a + b * b);
+ return [l, c, h];
+}
+
+function lab2rgb(args) {
+ return xyz2rgb(lab2xyz(args));
+}
+
+function lch2lab(lch) {
+ var l = lch[0],
+ c = lch[1],
+ h = lch[2],
+ a, b, hr;
+
+ hr = h / 360 * 2 * Math.PI;
+ a = c * Math.cos(hr);
+ b = c * Math.sin(hr);
+ return [l, a, b];
+}
+
+function lch2xyz(args) {
+ return lab2xyz(lch2lab(args));
+}
+
+function lch2rgb(args) {
+ return lab2rgb(lch2lab(args));
+}
+
+function keyword2rgb(keyword) {
+ return cssKeywords[keyword];
+}
+
+function keyword2hsl(args) {
+ return rgb2hsl(keyword2rgb(args));
+}
+
+function keyword2hsv(args) {
+ return rgb2hsv(keyword2rgb(args));
+}
+
+function keyword2hwb(args) {
+ return rgb2hwb(keyword2rgb(args));
+}
+
+function keyword2cmyk(args) {
+ return rgb2cmyk(keyword2rgb(args));
+}
+
+function keyword2lab(args) {
+ return rgb2lab(keyword2rgb(args));
+}
+
+function keyword2xyz(args) {
+ return rgb2xyz(keyword2rgb(args));
+}
+
+var cssKeywords = {
+ aliceblue: [240,248,255],
+ antiquewhite: [250,235,215],
+ aqua: [0,255,255],
+ aquamarine: [127,255,212],
+ azure: [240,255,255],
+ beige: [245,245,220],
+ bisque: [255,228,196],
+ black: [0,0,0],
+ blanchedalmond: [255,235,205],
+ blue: [0,0,255],
+ blueviolet: [138,43,226],
+ brown: [165,42,42],
+ burlywood: [222,184,135],
+ cadetblue: [95,158,160],
+ chartreuse: [127,255,0],
+ chocolate: [210,105,30],
+ coral: [255,127,80],
+ cornflowerblue: [100,149,237],
+ cornsilk: [255,248,220],
+ crimson: [220,20,60],
+ cyan: [0,255,255],
+ darkblue: [0,0,139],
+ darkcyan: [0,139,139],
+ darkgoldenrod: [184,134,11],
+ darkgray: [169,169,169],
+ darkgreen: [0,100,0],
+ darkgrey: [169,169,169],
+ darkkhaki: [189,183,107],
+ darkmagenta: [139,0,139],
+ darkolivegreen: [85,107,47],
+ darkorange: [255,140,0],
+ darkorchid: [153,50,204],
+ darkred: [139,0,0],
+ darksalmon: [233,150,122],
+ darkseagreen: [143,188,143],
+ darkslateblue: [72,61,139],
+ darkslategray: [47,79,79],
+ darkslategrey: [47,79,79],
+ darkturquoise: [0,206,209],
+ darkviolet: [148,0,211],
+ deeppink: [255,20,147],
+ deepskyblue: [0,191,255],
+ dimgray: [105,105,105],
+ dimgrey: [105,105,105],
+ dodgerblue: [30,144,255],
+ firebrick: [178,34,34],
+ floralwhite: [255,250,240],
+ forestgreen: [34,139,34],
+ fuchsia: [255,0,255],
+ gainsboro: [220,220,220],
+ ghostwhite: [248,248,255],
+ gold: [255,215,0],
+ goldenrod: [218,165,32],
+ gray: [128,128,128],
+ green: [0,128,0],
+ greenyellow: [173,255,47],
+ grey: [128,128,128],
+ honeydew: [240,255,240],
+ hotpink: [255,105,180],
+ indianred: [205,92,92],
+ indigo: [75,0,130],
+ ivory: [255,255,240],
+ khaki: [240,230,140],
+ lavender: [230,230,250],
+ lavenderblush: [255,240,245],
+ lawngreen: [124,252,0],
+ lemonchiffon: [255,250,205],
+ lightblue: [173,216,230],
+ lightcoral: [240,128,128],
+ lightcyan: [224,255,255],
+ lightgoldenrodyellow: [250,250,210],
+ lightgray: [211,211,211],
+ lightgreen: [144,238,144],
+ lightgrey: [211,211,211],
+ lightpink: [255,182,193],
+ lightsalmon: [255,160,122],
+ lightseagreen: [32,178,170],
+ lightskyblue: [135,206,250],
+ lightslategray: [119,136,153],
+ lightslategrey: [119,136,153],
+ lightsteelblue: [176,196,222],
+ lightyellow: [255,255,224],
+ lime: [0,255,0],
+ limegreen: [50,205,50],
+ linen: [250,240,230],
+ magenta: [255,0,255],
+ maroon: [128,0,0],
+ mediumaquamarine: [102,205,170],
+ mediumblue: [0,0,205],
+ mediumorchid: [186,85,211],
+ mediumpurple: [147,112,219],
+ mediumseagreen: [60,179,113],
+ mediumslateblue: [123,104,238],
+ mediumspringgreen: [0,250,154],
+ mediumturquoise: [72,209,204],
+ mediumvioletred: [199,21,133],
+ midnightblue: [25,25,112],
+ mintcream: [245,255,250],
+ mistyrose: [255,228,225],
+ moccasin: [255,228,181],
+ navajowhite: [255,222,173],
+ navy: [0,0,128],
+ oldlace: [253,245,230],
+ olive: [128,128,0],
+ olivedrab: [107,142,35],
+ orange: [255,165,0],
+ orangered: [255,69,0],
+ orchid: [218,112,214],
+ palegoldenrod: [238,232,170],
+ palegreen: [152,251,152],
+ paleturquoise: [175,238,238],
+ palevioletred: [219,112,147],
+ papayawhip: [255,239,213],
+ peachpuff: [255,218,185],
+ peru: [205,133,63],
+ pink: [255,192,203],
+ plum: [221,160,221],
+ powderblue: [176,224,230],
+ purple: [128,0,128],
+ rebeccapurple: [102, 51, 153],
+ red: [255,0,0],
+ rosybrown: [188,143,143],
+ royalblue: [65,105,225],
+ saddlebrown: [139,69,19],
+ salmon: [250,128,114],
+ sandybrown: [244,164,96],
+ seagreen: [46,139,87],
+ seashell: [255,245,238],
+ sienna: [160,82,45],
+ silver: [192,192,192],
+ skyblue: [135,206,235],
+ slateblue: [106,90,205],
+ slategray: [112,128,144],
+ slategrey: [112,128,144],
+ snow: [255,250,250],
+ springgreen: [0,255,127],
+ steelblue: [70,130,180],
+ tan: [210,180,140],
+ teal: [0,128,128],
+ thistle: [216,191,216],
+ tomato: [255,99,71],
+ turquoise: [64,224,208],
+ violet: [238,130,238],
+ wheat: [245,222,179],
+ white: [255,255,255],
+ whitesmoke: [245,245,245],
+ yellow: [255,255,0],
+ yellowgreen: [154,205,50]
+};
+
+var reverseKeywords = {};
+for (var key in cssKeywords) {
+ reverseKeywords[JSON.stringify(cssKeywords[key])] = key;
+}
+
+},{}],4:[function(require,module,exports){
+var conversions = require(3);
+
+var convert = function() {
+ return new Converter();
+}
+
+for (var func in conversions) {
+ // export Raw versions
+ convert[func + "Raw"] = (function(func) {
+ // accept array or plain args
+ return function(arg) {
+ if (typeof arg == "number")
+ arg = Array.prototype.slice.call(arguments);
+ return conversions[func](arg);
+ }
+ })(func);
+
+ var pair = /(\w+)2(\w+)/.exec(func),
+ from = pair[1],
+ to = pair[2];
+
+ // export rgb2hsl and ["rgb"]["hsl"]
+ convert[from] = convert[from] || {};
+
+ convert[from][to] = convert[func] = (function(func) {
+ return function(arg) {
+ if (typeof arg == "number")
+ arg = Array.prototype.slice.call(arguments);
+
+ var val = conversions[func](arg);
+ if (typeof val == "string" || val === undefined)
+ return val; // keyword
+
+ for (var i = 0; i < val.length; i++)
+ val[i] = Math.round(val[i]);
+ return val;
+ }
+ })(func);
+}
+
+
+/* Converter does lazy conversion and caching */
+var Converter = function() {
+ this.convs = {};
+};
+
+/* Either get the values for a space or
+ set the values for a space, depending on args */
+Converter.prototype.routeSpace = function(space, args) {
+ var values = args[0];
+ if (values === undefined) {
+ // color.rgb()
+ return this.getValues(space);
+ }
+ // color.rgb(10, 10, 10)
+ if (typeof values == "number") {
+ values = Array.prototype.slice.call(args);
+ }
+
+ return this.setValues(space, values);
+};
+
+/* Set the values for a space, invalidating cache */
+Converter.prototype.setValues = function(space, values) {
+ this.space = space;
+ this.convs = {};
+ this.convs[space] = values;
+ return this;
+};
+
+/* Get the values for a space. If there's already
+ a conversion for the space, fetch it, otherwise
+ compute it */
+Converter.prototype.getValues = function(space) {
+ var vals = this.convs[space];
+ if (!vals) {
+ var fspace = this.space,
+ from = this.convs[fspace];
+ vals = convert[fspace][space](from);
+
+ this.convs[space] = vals;
+ }
+ return vals;
+};
+
+["rgb", "hsl", "hsv", "cmyk", "keyword"].forEach(function(space) {
+ Converter.prototype[space] = function(vals) {
+ return this.routeSpace(space, arguments);
+ }
+});
+
+module.exports = convert;
+},{"3":3}],5:[function(require,module,exports){
+'use strict'
+
+module.exports = {
+ "aliceblue": [240, 248, 255],
+ "antiquewhite": [250, 235, 215],
+ "aqua": [0, 255, 255],
+ "aquamarine": [127, 255, 212],
+ "azure": [240, 255, 255],
+ "beige": [245, 245, 220],
+ "bisque": [255, 228, 196],
+ "black": [0, 0, 0],
+ "blanchedalmond": [255, 235, 205],
+ "blue": [0, 0, 255],
+ "blueviolet": [138, 43, 226],
+ "brown": [165, 42, 42],
+ "burlywood": [222, 184, 135],
+ "cadetblue": [95, 158, 160],
+ "chartreuse": [127, 255, 0],
+ "chocolate": [210, 105, 30],
+ "coral": [255, 127, 80],
+ "cornflowerblue": [100, 149, 237],
+ "cornsilk": [255, 248, 220],
+ "crimson": [220, 20, 60],
+ "cyan": [0, 255, 255],
+ "darkblue": [0, 0, 139],
+ "darkcyan": [0, 139, 139],
+ "darkgoldenrod": [184, 134, 11],
+ "darkgray": [169, 169, 169],
+ "darkgreen": [0, 100, 0],
+ "darkgrey": [169, 169, 169],
+ "darkkhaki": [189, 183, 107],
+ "darkmagenta": [139, 0, 139],
+ "darkolivegreen": [85, 107, 47],
+ "darkorange": [255, 140, 0],
+ "darkorchid": [153, 50, 204],
+ "darkred": [139, 0, 0],
+ "darksalmon": [233, 150, 122],
+ "darkseagreen": [143, 188, 143],
+ "darkslateblue": [72, 61, 139],
+ "darkslategray": [47, 79, 79],
+ "darkslategrey": [47, 79, 79],
+ "darkturquoise": [0, 206, 209],
+ "darkviolet": [148, 0, 211],
+ "deeppink": [255, 20, 147],
+ "deepskyblue": [0, 191, 255],
+ "dimgray": [105, 105, 105],
+ "dimgrey": [105, 105, 105],
+ "dodgerblue": [30, 144, 255],
+ "firebrick": [178, 34, 34],
+ "floralwhite": [255, 250, 240],
+ "forestgreen": [34, 139, 34],
+ "fuchsia": [255, 0, 255],
+ "gainsboro": [220, 220, 220],
+ "ghostwhite": [248, 248, 255],
+ "gold": [255, 215, 0],
+ "goldenrod": [218, 165, 32],
+ "gray": [128, 128, 128],
+ "green": [0, 128, 0],
+ "greenyellow": [173, 255, 47],
+ "grey": [128, 128, 128],
+ "honeydew": [240, 255, 240],
+ "hotpink": [255, 105, 180],
+ "indianred": [205, 92, 92],
+ "indigo": [75, 0, 130],
+ "ivory": [255, 255, 240],
+ "khaki": [240, 230, 140],
+ "lavender": [230, 230, 250],
+ "lavenderblush": [255, 240, 245],
+ "lawngreen": [124, 252, 0],
+ "lemonchiffon": [255, 250, 205],
+ "lightblue": [173, 216, 230],
+ "lightcoral": [240, 128, 128],
+ "lightcyan": [224, 255, 255],
+ "lightgoldenrodyellow": [250, 250, 210],
+ "lightgray": [211, 211, 211],
+ "lightgreen": [144, 238, 144],
+ "lightgrey": [211, 211, 211],
+ "lightpink": [255, 182, 193],
+ "lightsalmon": [255, 160, 122],
+ "lightseagreen": [32, 178, 170],
+ "lightskyblue": [135, 206, 250],
+ "lightslategray": [119, 136, 153],
+ "lightslategrey": [119, 136, 153],
+ "lightsteelblue": [176, 196, 222],
+ "lightyellow": [255, 255, 224],
+ "lime": [0, 255, 0],
+ "limegreen": [50, 205, 50],
+ "linen": [250, 240, 230],
+ "magenta": [255, 0, 255],
+ "maroon": [128, 0, 0],
+ "mediumaquamarine": [102, 205, 170],
+ "mediumblue": [0, 0, 205],
+ "mediumorchid": [186, 85, 211],
+ "mediumpurple": [147, 112, 219],
+ "mediumseagreen": [60, 179, 113],
+ "mediumslateblue": [123, 104, 238],
+ "mediumspringgreen": [0, 250, 154],
+ "mediumturquoise": [72, 209, 204],
+ "mediumvioletred": [199, 21, 133],
+ "midnightblue": [25, 25, 112],
+ "mintcream": [245, 255, 250],
+ "mistyrose": [255, 228, 225],
+ "moccasin": [255, 228, 181],
+ "navajowhite": [255, 222, 173],
+ "navy": [0, 0, 128],
+ "oldlace": [253, 245, 230],
+ "olive": [128, 128, 0],
+ "olivedrab": [107, 142, 35],
+ "orange": [255, 165, 0],
+ "orangered": [255, 69, 0],
+ "orchid": [218, 112, 214],
+ "palegoldenrod": [238, 232, 170],
+ "palegreen": [152, 251, 152],
+ "paleturquoise": [175, 238, 238],
+ "palevioletred": [219, 112, 147],
+ "papayawhip": [255, 239, 213],
+ "peachpuff": [255, 218, 185],
+ "peru": [205, 133, 63],
+ "pink": [255, 192, 203],
+ "plum": [221, 160, 221],
+ "powderblue": [176, 224, 230],
+ "purple": [128, 0, 128],
+ "rebeccapurple": [102, 51, 153],
+ "red": [255, 0, 0],
+ "rosybrown": [188, 143, 143],
+ "royalblue": [65, 105, 225],
+ "saddlebrown": [139, 69, 19],
+ "salmon": [250, 128, 114],
+ "sandybrown": [244, 164, 96],
+ "seagreen": [46, 139, 87],
+ "seashell": [255, 245, 238],
+ "sienna": [160, 82, 45],
+ "silver": [192, 192, 192],
+ "skyblue": [135, 206, 235],
+ "slateblue": [106, 90, 205],
+ "slategray": [112, 128, 144],
+ "slategrey": [112, 128, 144],
+ "snow": [255, 250, 250],
+ "springgreen": [0, 255, 127],
+ "steelblue": [70, 130, 180],
+ "tan": [210, 180, 140],
+ "teal": [0, 128, 128],
+ "thistle": [216, 191, 216],
+ "tomato": [255, 99, 71],
+ "turquoise": [64, 224, 208],
+ "violet": [238, 130, 238],
+ "wheat": [245, 222, 179],
+ "white": [255, 255, 255],
+ "whitesmoke": [245, 245, 245],
+ "yellow": [255, 255, 0],
+ "yellowgreen": [154, 205, 50]
+};
+
+},{}],6:[function(require,module,exports){
+//! moment.js
+//! version : 2.18.1
+//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
+//! license : MIT
+//! momentjs.com
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ global.moment = factory()
+}(this, (function () { 'use strict';
+
+var hookCallback;
+
+function hooks () {
+ return hookCallback.apply(null, arguments);
+}
+
+// This is done to register the method called with moment()
+// without creating circular dependencies.
+function setHookCallback (callback) {
+ hookCallback = callback;
+}
+
+function isArray(input) {
+ return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
+}
+
+function isObject(input) {
+ // IE8 will treat undefined and null as object if it wasn't for
+ // input != null
+ return input != null && Object.prototype.toString.call(input) === '[object Object]';
+}
+
+function isObjectEmpty(obj) {
+ var k;
+ for (k in obj) {
+ // even if its not own property I'd still call it non-empty
+ return false;
+ }
+ return true;
+}
+
+function isUndefined(input) {
+ return input === void 0;
+}
+
+function isNumber(input) {
+ return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
+}
+
+function isDate(input) {
+ return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
+}
+
+function map(arr, fn) {
+ var res = [], i;
+ for (i = 0; i < arr.length; ++i) {
+ res.push(fn(arr[i], i));
+ }
+ return res;
+}
+
+function hasOwnProp(a, b) {
+ return Object.prototype.hasOwnProperty.call(a, b);
+}
+
+function extend(a, b) {
+ for (var i in b) {
+ if (hasOwnProp(b, i)) {
+ a[i] = b[i];
+ }
+ }
+
+ if (hasOwnProp(b, 'toString')) {
+ a.toString = b.toString;
+ }
+
+ if (hasOwnProp(b, 'valueOf')) {
+ a.valueOf = b.valueOf;
+ }
+
+ return a;
+}
+
+function createUTC (input, format, locale, strict) {
+ return createLocalOrUTC(input, format, locale, strict, true).utc();
+}
+
+function defaultParsingFlags() {
+ // We need to deep clone this object.
+ return {
+ empty : false,
+ unusedTokens : [],
+ unusedInput : [],
+ overflow : -2,
+ charsLeftOver : 0,
+ nullInput : false,
+ invalidMonth : null,
+ invalidFormat : false,
+ userInvalidated : false,
+ iso : false,
+ parsedDateParts : [],
+ meridiem : null,
+ rfc2822 : false,
+ weekdayMismatch : false
+ };
+}
+
+function getParsingFlags(m) {
+ if (m._pf == null) {
+ m._pf = defaultParsingFlags();
+ }
+ return m._pf;
+}
+
+var some;
+if (Array.prototype.some) {
+ some = Array.prototype.some;
+} else {
+ some = function (fun) {
+ var t = Object(this);
+ var len = t.length >>> 0;
+
+ for (var i = 0; i < len; i++) {
+ if (i in t && fun.call(this, t[i], i, t)) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+}
+
+var some$1 = some;
+
+function isValid(m) {
+ if (m._isValid == null) {
+ var flags = getParsingFlags(m);
+ var parsedParts = some$1.call(flags.parsedDateParts, function (i) {
+ return i != null;
+ });
+ var isNowValid = !isNaN(m._d.getTime()) &&
+ flags.overflow < 0 &&
+ !flags.empty &&
+ !flags.invalidMonth &&
+ !flags.invalidWeekday &&
+ !flags.nullInput &&
+ !flags.invalidFormat &&
+ !flags.userInvalidated &&
+ (!flags.meridiem || (flags.meridiem && parsedParts));
+
+ if (m._strict) {
+ isNowValid = isNowValid &&
+ flags.charsLeftOver === 0 &&
+ flags.unusedTokens.length === 0 &&
+ flags.bigHour === undefined;
+ }
+
+ if (Object.isFrozen == null || !Object.isFrozen(m)) {
+ m._isValid = isNowValid;
+ }
+ else {
+ return isNowValid;
+ }
+ }
+ return m._isValid;
+}
+
+function createInvalid (flags) {
+ var m = createUTC(NaN);
+ if (flags != null) {
+ extend(getParsingFlags(m), flags);
+ }
+ else {
+ getParsingFlags(m).userInvalidated = true;
+ }
+
+ return m;
+}
+
+// Plugins that add properties should also add the key here (null value),
+// so we can properly clone ourselves.
+var momentProperties = hooks.momentProperties = [];
+
+function copyConfig(to, from) {
+ var i, prop, val;
+
+ if (!isUndefined(from._isAMomentObject)) {
+ to._isAMomentObject = from._isAMomentObject;
+ }
+ if (!isUndefined(from._i)) {
+ to._i = from._i;
+ }
+ if (!isUndefined(from._f)) {
+ to._f = from._f;
+ }
+ if (!isUndefined(from._l)) {
+ to._l = from._l;
+ }
+ if (!isUndefined(from._strict)) {
+ to._strict = from._strict;
+ }
+ if (!isUndefined(from._tzm)) {
+ to._tzm = from._tzm;
+ }
+ if (!isUndefined(from._isUTC)) {
+ to._isUTC = from._isUTC;
+ }
+ if (!isUndefined(from._offset)) {
+ to._offset = from._offset;
+ }
+ if (!isUndefined(from._pf)) {
+ to._pf = getParsingFlags(from);
+ }
+ if (!isUndefined(from._locale)) {
+ to._locale = from._locale;
+ }
+
+ if (momentProperties.length > 0) {
+ for (i = 0; i < momentProperties.length; i++) {
+ prop = momentProperties[i];
+ val = from[prop];
+ if (!isUndefined(val)) {
+ to[prop] = val;
+ }
+ }
+ }
+
+ return to;
+}
+
+var updateInProgress = false;
+
+// Moment prototype object
+function Moment(config) {
+ copyConfig(this, config);
+ this._d = new Date(config._d != null ? config._d.getTime() : NaN);
+ if (!this.isValid()) {
+ this._d = new Date(NaN);
+ }
+ // Prevent infinite loop in case updateOffset creates new moment
+ // objects.
+ if (updateInProgress === false) {
+ updateInProgress = true;
+ hooks.updateOffset(this);
+ updateInProgress = false;
+ }
+}
+
+function isMoment (obj) {
+ return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
+}
+
+function absFloor (number) {
+ if (number < 0) {
+ // -0 -> 0
+ return Math.ceil(number) || 0;
+ } else {
+ return Math.floor(number);
+ }
+}
+
+function toInt(argumentForCoercion) {
+ var coercedNumber = +argumentForCoercion,
+ value = 0;
+
+ if (coercedNumber !== 0 && isFinite(coercedNumber)) {
+ value = absFloor(coercedNumber);
+ }
+
+ return value;
+}
+
+// compare two arrays, return the number of differences
+function compareArrays(array1, array2, dontConvert) {
+ var len = Math.min(array1.length, array2.length),
+ lengthDiff = Math.abs(array1.length - array2.length),
+ diffs = 0,
+ i;
+ for (i = 0; i < len; i++) {
+ if ((dontConvert && array1[i] !== array2[i]) ||
+ (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
+ diffs++;
+ }
+ }
+ return diffs + lengthDiff;
+}
+
+function warn(msg) {
+ if (hooks.suppressDeprecationWarnings === false &&
+ (typeof console !== 'undefined') && console.warn) {
+ console.warn('Deprecation warning: ' + msg);
+ }
+}
+
+function deprecate(msg, fn) {
+ var firstTime = true;
+
+ return extend(function () {
+ if (hooks.deprecationHandler != null) {
+ hooks.deprecationHandler(null, msg);
+ }
+ if (firstTime) {
+ var args = [];
+ var arg;
+ for (var i = 0; i < arguments.length; i++) {
+ arg = '';
+ if (typeof arguments[i] === 'object') {
+ arg += '\n[' + i + '] ';
+ for (var key in arguments[0]) {
+ arg += key + ': ' + arguments[0][key] + ', ';
+ }
+ arg = arg.slice(0, -2); // Remove trailing comma and space
+ } else {
+ arg = arguments[i];
+ }
+ args.push(arg);
+ }
+ warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
+ firstTime = false;
+ }
+ return fn.apply(this, arguments);
+ }, fn);
+}
+
+var deprecations = {};
+
+function deprecateSimple(name, msg) {
+ if (hooks.deprecationHandler != null) {
+ hooks.deprecationHandler(name, msg);
+ }
+ if (!deprecations[name]) {
+ warn(msg);
+ deprecations[name] = true;
+ }
+}
+
+hooks.suppressDeprecationWarnings = false;
+hooks.deprecationHandler = null;
+
+function isFunction(input) {
+ return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
+}
+
+function set (config) {
+ var prop, i;
+ for (i in config) {
+ prop = config[i];
+ if (isFunction(prop)) {
+ this[i] = prop;
+ } else {
+ this['_' + i] = prop;
+ }
+ }
+ this._config = config;
+ // Lenient ordinal parsing accepts just a number in addition to
+ // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
+ // TODO: Remove "ordinalParse" fallback in next major release.
+ this._dayOfMonthOrdinalParseLenient = new RegExp(
+ (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
+ '|' + (/\d{1,2}/).source);
+}
+
+function mergeConfigs(parentConfig, childConfig) {
+ var res = extend({}, parentConfig), prop;
+ for (prop in childConfig) {
+ if (hasOwnProp(childConfig, prop)) {
+ if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
+ res[prop] = {};
+ extend(res[prop], parentConfig[prop]);
+ extend(res[prop], childConfig[prop]);
+ } else if (childConfig[prop] != null) {
+ res[prop] = childConfig[prop];
+ } else {
+ delete res[prop];
+ }
+ }
+ }
+ for (prop in parentConfig) {
+ if (hasOwnProp(parentConfig, prop) &&
+ !hasOwnProp(childConfig, prop) &&
+ isObject(parentConfig[prop])) {
+ // make sure changes to properties don't modify parent config
+ res[prop] = extend({}, res[prop]);
+ }
+ }
+ return res;
+}
+
+function Locale(config) {
+ if (config != null) {
+ this.set(config);
+ }
+}
+
+var keys;
+
+if (Object.keys) {
+ keys = Object.keys;
+} else {
+ keys = function (obj) {
+ var i, res = [];
+ for (i in obj) {
+ if (hasOwnProp(obj, i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ };
+}
+
+var keys$1 = keys;
+
+var defaultCalendar = {
+ sameDay : '[Today at] LT',
+ nextDay : '[Tomorrow at] LT',
+ nextWeek : 'dddd [at] LT',
+ lastDay : '[Yesterday at] LT',
+ lastWeek : '[Last] dddd [at] LT',
+ sameElse : 'L'
+};
+
+function calendar (key, mom, now) {
+ var output = this._calendar[key] || this._calendar['sameElse'];
+ return isFunction(output) ? output.call(mom, now) : output;
+}
+
+var defaultLongDateFormat = {
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
+};
+
+function longDateFormat (key) {
+ var format = this._longDateFormat[key],
+ formatUpper = this._longDateFormat[key.toUpperCase()];
+
+ if (format || !formatUpper) {
+ return format;
+ }
+
+ this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
+ return val.slice(1);
+ });
+
+ return this._longDateFormat[key];
+}
+
+var defaultInvalidDate = 'Invalid date';
+
+function invalidDate () {
+ return this._invalidDate;
+}
+
+var defaultOrdinal = '%d';
+var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
+
+function ordinal (number) {
+ return this._ordinal.replace('%d', number);
+}
+
+var defaultRelativeTime = {
+ future : 'in %s',
+ past : '%s ago',
+ s : 'a few seconds',
+ ss : '%d seconds',
+ m : 'a minute',
+ mm : '%d minutes',
+ h : 'an hour',
+ hh : '%d hours',
+ d : 'a day',
+ dd : '%d days',
+ M : 'a month',
+ MM : '%d months',
+ y : 'a year',
+ yy : '%d years'
+};
+
+function relativeTime (number, withoutSuffix, string, isFuture) {
+ var output = this._relativeTime[string];
+ return (isFunction(output)) ?
+ output(number, withoutSuffix, string, isFuture) :
+ output.replace(/%d/i, number);
+}
+
+function pastFuture (diff, output) {
+ var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
+ return isFunction(format) ? format(output) : format.replace(/%s/i, output);
+}
+
+var aliases = {};
+
+function addUnitAlias (unit, shorthand) {
+ var lowerCase = unit.toLowerCase();
+ aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
+}
+
+function normalizeUnits(units) {
+ return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
+}
+
+function normalizeObjectUnits(inputObject) {
+ var normalizedInput = {},
+ normalizedProp,
+ prop;
+
+ for (prop in inputObject) {
+ if (hasOwnProp(inputObject, prop)) {
+ normalizedProp = normalizeUnits(prop);
+ if (normalizedProp) {
+ normalizedInput[normalizedProp] = inputObject[prop];
+ }
+ }
+ }
+
+ return normalizedInput;
+}
+
+var priorities = {};
+
+function addUnitPriority(unit, priority) {
+ priorities[unit] = priority;
+}
+
+function getPrioritizedUnits(unitsObj) {
+ var units = [];
+ for (var u in unitsObj) {
+ units.push({unit: u, priority: priorities[u]});
+ }
+ units.sort(function (a, b) {
+ return a.priority - b.priority;
+ });
+ return units;
+}
+
+function makeGetSet (unit, keepTime) {
+ return function (value) {
+ if (value != null) {
+ set$1(this, unit, value);
+ hooks.updateOffset(this, keepTime);
+ return this;
+ } else {
+ return get(this, unit);
+ }
+ };
+}
+
+function get (mom, unit) {
+ return mom.isValid() ?
+ mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
+}
+
+function set$1 (mom, unit, value) {
+ if (mom.isValid()) {
+ mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
+ }
+}
+
+// MOMENTS
+
+function stringGet (units) {
+ units = normalizeUnits(units);
+ if (isFunction(this[units])) {
+ return this[units]();
+ }
+ return this;
+}
+
+
+function stringSet (units, value) {
+ if (typeof units === 'object') {
+ units = normalizeObjectUnits(units);
+ var prioritized = getPrioritizedUnits(units);
+ for (var i = 0; i < prioritized.length; i++) {
+ this[prioritized[i].unit](units[prioritized[i].unit]);
+ }
+ } else {
+ units = normalizeUnits(units);
+ if (isFunction(this[units])) {
+ return this[units](value);
+ }
+ }
+ return this;
+}
+
+function zeroFill(number, targetLength, forceSign) {
+ var absNumber = '' + Math.abs(number),
+ zerosToFill = targetLength - absNumber.length,
+ sign = number >= 0;
+ return (sign ? (forceSign ? '+' : '') : '-') +
+ Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
+}
+
+var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
+
+var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
+
+var formatFunctions = {};
+
+var formatTokenFunctions = {};
+
+// token: 'M'
+// padded: ['MM', 2]
+// ordinal: 'Mo'
+// callback: function () { this.month() + 1 }
+function addFormatToken (token, padded, ordinal, callback) {
+ var func = callback;
+ if (typeof callback === 'string') {
+ func = function () {
+ return this[callback]();
+ };
+ }
+ if (token) {
+ formatTokenFunctions[token] = func;
+ }
+ if (padded) {
+ formatTokenFunctions[padded[0]] = function () {
+ return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
+ };
+ }
+ if (ordinal) {
+ formatTokenFunctions[ordinal] = function () {
+ return this.localeData().ordinal(func.apply(this, arguments), token);
+ };
+ }
+}
+
+function removeFormattingTokens(input) {
+ if (input.match(/\[[\s\S]/)) {
+ return input.replace(/^\[|\]$/g, '');
+ }
+ return input.replace(/\\/g, '');
+}
+
+function makeFormatFunction(format) {
+ var array = format.match(formattingTokens), i, length;
+
+ for (i = 0, length = array.length; i < length; i++) {
+ if (formatTokenFunctions[array[i]]) {
+ array[i] = formatTokenFunctions[array[i]];
+ } else {
+ array[i] = removeFormattingTokens(array[i]);
+ }
+ }
+
+ return function (mom) {
+ var output = '', i;
+ for (i = 0; i < length; i++) {
+ output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
+ }
+ return output;
+ };
+}
+
+// format date using native date object
+function formatMoment(m, format) {
+ if (!m.isValid()) {
+ return m.localeData().invalidDate();
+ }
+
+ format = expandFormat(format, m.localeData());
+ formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
+
+ return formatFunctions[format](m);
+}
+
+function expandFormat(format, locale) {
+ var i = 5;
+
+ function replaceLongDateFormatTokens(input) {
+ return locale.longDateFormat(input) || input;
+ }
+
+ localFormattingTokens.lastIndex = 0;
+ while (i >= 0 && localFormattingTokens.test(format)) {
+ format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
+ localFormattingTokens.lastIndex = 0;
+ i -= 1;
+ }
+
+ return format;
+}
+
+var match1 = /\d/; // 0 - 9
+var match2 = /\d\d/; // 00 - 99
+var match3 = /\d{3}/; // 000 - 999
+var match4 = /\d{4}/; // 0000 - 9999
+var match6 = /[+-]?\d{6}/; // -999999 - 999999
+var match1to2 = /\d\d?/; // 0 - 99
+var match3to4 = /\d\d\d\d?/; // 999 - 9999
+var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
+var match1to3 = /\d{1,3}/; // 0 - 999
+var match1to4 = /\d{1,4}/; // 0 - 9999
+var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
+
+var matchUnsigned = /\d+/; // 0 - inf
+var matchSigned = /[+-]?\d+/; // -inf - inf
+
+var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
+var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
+
+var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
+
+// any word (or two) characters or numbers including two/three word month in arabic.
+// includes scottish gaelic two word and hyphenated months
+var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
+
+
+var regexes = {};
+
+function addRegexToken (token, regex, strictRegex) {
+ regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
+ return (isStrict && strictRegex) ? strictRegex : regex;
+ };
+}
+
+function getParseRegexForToken (token, config) {
+ if (!hasOwnProp(regexes, token)) {
+ return new RegExp(unescapeFormat(token));
+ }
+
+ return regexes[token](config._strict, config._locale);
+}
+
+// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
+function unescapeFormat(s) {
+ return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
+ return p1 || p2 || p3 || p4;
+ }));
+}
+
+function regexEscape(s) {
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+}
+
+var tokens = {};
+
+function addParseToken (token, callback) {
+ var i, func = callback;
+ if (typeof token === 'string') {
+ token = [token];
+ }
+ if (isNumber(callback)) {
+ func = function (input, array) {
+ array[callback] = toInt(input);
+ };
+ }
+ for (i = 0; i < token.length; i++) {
+ tokens[token[i]] = func;
+ }
+}
+
+function addWeekParseToken (token, callback) {
+ addParseToken(token, function (input, array, config, token) {
+ config._w = config._w || {};
+ callback(input, config._w, config, token);
+ });
+}
+
+function addTimeToArrayFromToken(token, input, config) {
+ if (input != null && hasOwnProp(tokens, token)) {
+ tokens[token](input, config._a, config, token);
+ }
+}
+
+var YEAR = 0;
+var MONTH = 1;
+var DATE = 2;
+var HOUR = 3;
+var MINUTE = 4;
+var SECOND = 5;
+var MILLISECOND = 6;
+var WEEK = 7;
+var WEEKDAY = 8;
+
+var indexOf;
+
+if (Array.prototype.indexOf) {
+ indexOf = Array.prototype.indexOf;
+} else {
+ indexOf = function (o) {
+ // I know
+ var i;
+ for (i = 0; i < this.length; ++i) {
+ if (this[i] === o) {
+ return i;
+ }
+ }
+ return -1;
+ };
+}
+
+var indexOf$1 = indexOf;
+
+function daysInMonth(year, month) {
+ return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
+}
+
+// FORMATTING
+
+addFormatToken('M', ['MM', 2], 'Mo', function () {
+ return this.month() + 1;
+});
+
+addFormatToken('MMM', 0, 0, function (format) {
+ return this.localeData().monthsShort(this, format);
+});
+
+addFormatToken('MMMM', 0, 0, function (format) {
+ return this.localeData().months(this, format);
+});
+
+// ALIASES
+
+addUnitAlias('month', 'M');
+
+// PRIORITY
+
+addUnitPriority('month', 8);
+
+// PARSING
+
+addRegexToken('M', match1to2);
+addRegexToken('MM', match1to2, match2);
+addRegexToken('MMM', function (isStrict, locale) {
+ return locale.monthsShortRegex(isStrict);
+});
+addRegexToken('MMMM', function (isStrict, locale) {
+ return locale.monthsRegex(isStrict);
+});
+
+addParseToken(['M', 'MM'], function (input, array) {
+ array[MONTH] = toInt(input) - 1;
+});
+
+addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
+ var month = config._locale.monthsParse(input, token, config._strict);
+ // if we didn't find a month name, mark the date as invalid.
+ if (month != null) {
+ array[MONTH] = month;
+ } else {
+ getParsingFlags(config).invalidMonth = input;
+ }
+});
+
+// LOCALES
+
+var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
+var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
+function localeMonths (m, format) {
+ if (!m) {
+ return isArray(this._months) ? this._months :
+ this._months['standalone'];
+ }
+ return isArray(this._months) ? this._months[m.month()] :
+ this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
+}
+
+var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
+function localeMonthsShort (m, format) {
+ if (!m) {
+ return isArray(this._monthsShort) ? this._monthsShort :
+ this._monthsShort['standalone'];
+ }
+ return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
+ this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
+}
+
+function handleStrictParse(monthName, format, strict) {
+ var i, ii, mom, llc = monthName.toLocaleLowerCase();
+ if (!this._monthsParse) {
+ // this is not used
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ for (i = 0; i < 12; ++i) {
+ mom = createUTC([2000, i]);
+ this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
+ this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'MMM') {
+ ii = indexOf$1.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf$1.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'MMM') {
+ ii = indexOf$1.call(this._shortMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf$1.call(this._longMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+}
+
+function localeMonthsParse (monthName, format, strict) {
+ var i, mom, regex;
+
+ if (this._monthsParseExact) {
+ return handleStrictParse.call(this, monthName, format, strict);
+ }
+
+ if (!this._monthsParse) {
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ }
+
+ // TODO: add sorting
+ // Sorting makes sure if one month (or abbr) is a prefix of another
+ // see sorting in computeMonthsParse
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = createUTC([2000, i]);
+ if (strict && !this._longMonthsParse[i]) {
+ this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
+ this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
+ }
+ if (!strict && !this._monthsParse[i]) {
+ regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
+ this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (!strict && this._monthsParse[i].test(monthName)) {
+ return i;
+ }
+ }
+}
+
+// MOMENTS
+
+function setMonth (mom, value) {
+ var dayOfMonth;
+
+ if (!mom.isValid()) {
+ // No op
+ return mom;
+ }
+
+ if (typeof value === 'string') {
+ if (/^\d+$/.test(value)) {
+ value = toInt(value);
+ } else {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (!isNumber(value)) {
+ return mom;
+ }
+ }
+ }
+
+ dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
+ mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
+ return mom;
+}
+
+function getSetMonth (value) {
+ if (value != null) {
+ setMonth(this, value);
+ hooks.updateOffset(this, true);
+ return this;
+ } else {
+ return get(this, 'Month');
+ }
+}
+
+function getDaysInMonth () {
+ return daysInMonth(this.year(), this.month());
+}
+
+var defaultMonthsShortRegex = matchWord;
+function monthsShortRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsShortStrictRegex;
+ } else {
+ return this._monthsShortRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_monthsShortRegex')) {
+ this._monthsShortRegex = defaultMonthsShortRegex;
+ }
+ return this._monthsShortStrictRegex && isStrict ?
+ this._monthsShortStrictRegex : this._monthsShortRegex;
+ }
+}
+
+var defaultMonthsRegex = matchWord;
+function monthsRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsStrictRegex;
+ } else {
+ return this._monthsRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ this._monthsRegex = defaultMonthsRegex;
+ }
+ return this._monthsStrictRegex && isStrict ?
+ this._monthsStrictRegex : this._monthsRegex;
+ }
+}
+
+function computeMonthsParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom;
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = createUTC([2000, i]);
+ shortPieces.push(this.monthsShort(mom, ''));
+ longPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.monthsShort(mom, ''));
+ }
+ // Sorting makes sure if one month (or abbr) is a prefix of another it
+ // will match the longer piece.
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 12; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ }
+ for (i = 0; i < 24; i++) {
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._monthsShortRegex = this._monthsRegex;
+ this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
+}
+
+// FORMATTING
+
+addFormatToken('Y', 0, 0, function () {
+ var y = this.year();
+ return y <= 9999 ? '' + y : '+' + y;
+});
+
+addFormatToken(0, ['YY', 2], 0, function () {
+ return this.year() % 100;
+});
+
+addFormatToken(0, ['YYYY', 4], 0, 'year');
+addFormatToken(0, ['YYYYY', 5], 0, 'year');
+addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
+
+// ALIASES
+
+addUnitAlias('year', 'y');
+
+// PRIORITIES
+
+addUnitPriority('year', 1);
+
+// PARSING
+
+addRegexToken('Y', matchSigned);
+addRegexToken('YY', match1to2, match2);
+addRegexToken('YYYY', match1to4, match4);
+addRegexToken('YYYYY', match1to6, match6);
+addRegexToken('YYYYYY', match1to6, match6);
+
+addParseToken(['YYYYY', 'YYYYYY'], YEAR);
+addParseToken('YYYY', function (input, array) {
+ array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
+});
+addParseToken('YY', function (input, array) {
+ array[YEAR] = hooks.parseTwoDigitYear(input);
+});
+addParseToken('Y', function (input, array) {
+ array[YEAR] = parseInt(input, 10);
+});
+
+// HELPERS
+
+function daysInYear(year) {
+ return isLeapYear(year) ? 366 : 365;
+}
+
+function isLeapYear(year) {
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
+}
+
+// HOOKS
+
+hooks.parseTwoDigitYear = function (input) {
+ return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
+};
+
+// MOMENTS
+
+var getSetYear = makeGetSet('FullYear', true);
+
+function getIsLeapYear () {
+ return isLeapYear(this.year());
+}
+
+function createDate (y, m, d, h, M, s, ms) {
+ // can't just apply() to create a date:
+ // https://stackoverflow.com/q/181348
+ var date = new Date(y, m, d, h, M, s, ms);
+
+ // the date constructor remaps years 0-99 to 1900-1999
+ if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
+ date.setFullYear(y);
+ }
+ return date;
+}
+
+function createUTCDate (y) {
+ var date = new Date(Date.UTC.apply(null, arguments));
+
+ // the Date.UTC function remaps years 0-99 to 1900-1999
+ if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
+ date.setUTCFullYear(y);
+ }
+ return date;
+}
+
+// start-of-first-week - start-of-year
+function firstWeekOffset(year, dow, doy) {
+ var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
+ fwd = 7 + dow - doy,
+ // first-week day local weekday -- which local weekday is fwd
+ fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
+
+ return -fwdlw + fwd - 1;
+}
+
+// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
+function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
+ var localWeekday = (7 + weekday - dow) % 7,
+ weekOffset = firstWeekOffset(year, dow, doy),
+ dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
+ resYear, resDayOfYear;
+
+ if (dayOfYear <= 0) {
+ resYear = year - 1;
+ resDayOfYear = daysInYear(resYear) + dayOfYear;
+ } else if (dayOfYear > daysInYear(year)) {
+ resYear = year + 1;
+ resDayOfYear = dayOfYear - daysInYear(year);
+ } else {
+ resYear = year;
+ resDayOfYear = dayOfYear;
+ }
+
+ return {
+ year: resYear,
+ dayOfYear: resDayOfYear
+ };
+}
+
+function weekOfYear(mom, dow, doy) {
+ var weekOffset = firstWeekOffset(mom.year(), dow, doy),
+ week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
+ resWeek, resYear;
+
+ if (week < 1) {
+ resYear = mom.year() - 1;
+ resWeek = week + weeksInYear(resYear, dow, doy);
+ } else if (week > weeksInYear(mom.year(), dow, doy)) {
+ resWeek = week - weeksInYear(mom.year(), dow, doy);
+ resYear = mom.year() + 1;
+ } else {
+ resYear = mom.year();
+ resWeek = week;
+ }
+
+ return {
+ week: resWeek,
+ year: resYear
+ };
+}
+
+function weeksInYear(year, dow, doy) {
+ var weekOffset = firstWeekOffset(year, dow, doy),
+ weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
+ return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
+}
+
+// FORMATTING
+
+addFormatToken('w', ['ww', 2], 'wo', 'week');
+addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
+
+// ALIASES
+
+addUnitAlias('week', 'w');
+addUnitAlias('isoWeek', 'W');
+
+// PRIORITIES
+
+addUnitPriority('week', 5);
+addUnitPriority('isoWeek', 5);
+
+// PARSING
+
+addRegexToken('w', match1to2);
+addRegexToken('ww', match1to2, match2);
+addRegexToken('W', match1to2);
+addRegexToken('WW', match1to2, match2);
+
+addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
+ week[token.substr(0, 1)] = toInt(input);
+});
+
+// HELPERS
+
+// LOCALES
+
+function localeWeek (mom) {
+ return weekOfYear(mom, this._week.dow, this._week.doy).week;
+}
+
+var defaultLocaleWeek = {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
+};
+
+function localeFirstDayOfWeek () {
+ return this._week.dow;
+}
+
+function localeFirstDayOfYear () {
+ return this._week.doy;
+}
+
+// MOMENTS
+
+function getSetWeek (input) {
+ var week = this.localeData().week(this);
+ return input == null ? week : this.add((input - week) * 7, 'd');
+}
+
+function getSetISOWeek (input) {
+ var week = weekOfYear(this, 1, 4).week;
+ return input == null ? week : this.add((input - week) * 7, 'd');
+}
+
+// FORMATTING
+
+addFormatToken('d', 0, 'do', 'day');
+
+addFormatToken('dd', 0, 0, function (format) {
+ return this.localeData().weekdaysMin(this, format);
+});
+
+addFormatToken('ddd', 0, 0, function (format) {
+ return this.localeData().weekdaysShort(this, format);
+});
+
+addFormatToken('dddd', 0, 0, function (format) {
+ return this.localeData().weekdays(this, format);
+});
+
+addFormatToken('e', 0, 0, 'weekday');
+addFormatToken('E', 0, 0, 'isoWeekday');
+
+// ALIASES
+
+addUnitAlias('day', 'd');
+addUnitAlias('weekday', 'e');
+addUnitAlias('isoWeekday', 'E');
+
+// PRIORITY
+addUnitPriority('day', 11);
+addUnitPriority('weekday', 11);
+addUnitPriority('isoWeekday', 11);
+
+// PARSING
+
+addRegexToken('d', match1to2);
+addRegexToken('e', match1to2);
+addRegexToken('E', match1to2);
+addRegexToken('dd', function (isStrict, locale) {
+ return locale.weekdaysMinRegex(isStrict);
+});
+addRegexToken('ddd', function (isStrict, locale) {
+ return locale.weekdaysShortRegex(isStrict);
+});
+addRegexToken('dddd', function (isStrict, locale) {
+ return locale.weekdaysRegex(isStrict);
+});
+
+addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
+ var weekday = config._locale.weekdaysParse(input, token, config._strict);
+ // if we didn't get a weekday name, mark the date as invalid
+ if (weekday != null) {
+ week.d = weekday;
+ } else {
+ getParsingFlags(config).invalidWeekday = input;
+ }
+});
+
+addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
+ week[token] = toInt(input);
+});
+
+// HELPERS
+
+function parseWeekday(input, locale) {
+ if (typeof input !== 'string') {
+ return input;
+ }
+
+ if (!isNaN(input)) {
+ return parseInt(input, 10);
+ }
+
+ input = locale.weekdaysParse(input);
+ if (typeof input === 'number') {
+ return input;
+ }
+
+ return null;
+}
+
+function parseIsoWeekday(input, locale) {
+ if (typeof input === 'string') {
+ return locale.weekdaysParse(input) % 7 || 7;
+ }
+ return isNaN(input) ? null : input;
+}
+
+// LOCALES
+
+var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
+function localeWeekdays (m, format) {
+ if (!m) {
+ return isArray(this._weekdays) ? this._weekdays :
+ this._weekdays['standalone'];
+ }
+ return isArray(this._weekdays) ? this._weekdays[m.day()] :
+ this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
+}
+
+var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
+function localeWeekdaysShort (m) {
+ return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
+}
+
+var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
+function localeWeekdaysMin (m) {
+ return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
+}
+
+function handleStrictParse$1(weekdayName, format, strict) {
+ var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
+ if (!this._weekdaysParse) {
+ this._weekdaysParse = [];
+ this._shortWeekdaysParse = [];
+ this._minWeekdaysParse = [];
+
+ for (i = 0; i < 7; ++i) {
+ mom = createUTC([2000, 1]).day(i);
+ this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
+ this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
+ this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'dddd') {
+ ii = indexOf$1.call(this._weekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf$1.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf$1.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'dddd') {
+ ii = indexOf$1.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf$1.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf$1.call(this._minWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf$1.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+}
+
+function localeWeekdaysParse (weekdayName, format, strict) {
+ var i, mom, regex;
+
+ if (this._weekdaysParseExact) {
+ return handleStrictParse$1.call(this, weekdayName, format, strict);
+ }
+
+ if (!this._weekdaysParse) {
+ this._weekdaysParse = [];
+ this._minWeekdaysParse = [];
+ this._shortWeekdaysParse = [];
+ this._fullWeekdaysParse = [];
+ }
+
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+
+ mom = createUTC([2000, 1]).day(i);
+ if (strict && !this._fullWeekdaysParse[i]) {
+ this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
+ this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
+ this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
+ }
+ if (!this._weekdaysParse[i]) {
+ regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
+ this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
+ return i;
+ } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
+ return i;
+ } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
+ return i;
+ } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
+ return i;
+ }
+ }
+}
+
+// MOMENTS
+
+function getSetDayOfWeek (input) {
+ if (!this.isValid()) {
+ return input != null ? this : NaN;
+ }
+ var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
+ if (input != null) {
+ input = parseWeekday(input, this.localeData());
+ return this.add(input - day, 'd');
+ } else {
+ return day;
+ }
+}
+
+function getSetLocaleDayOfWeek (input) {
+ if (!this.isValid()) {
+ return input != null ? this : NaN;
+ }
+ var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
+ return input == null ? weekday : this.add(input - weekday, 'd');
+}
+
+function getSetISODayOfWeek (input) {
+ if (!this.isValid()) {
+ return input != null ? this : NaN;
+ }
+
+ // behaves the same as moment#day except
+ // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
+ // as a setter, sunday should belong to the previous week.
+
+ if (input != null) {
+ var weekday = parseIsoWeekday(input, this.localeData());
+ return this.day(this.day() % 7 ? weekday : weekday - 7);
+ } else {
+ return this.day() || 7;
+ }
+}
+
+var defaultWeekdaysRegex = matchWord;
+function weekdaysRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysStrictRegex;
+ } else {
+ return this._weekdaysRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ this._weekdaysRegex = defaultWeekdaysRegex;
+ }
+ return this._weekdaysStrictRegex && isStrict ?
+ this._weekdaysStrictRegex : this._weekdaysRegex;
+ }
+}
+
+var defaultWeekdaysShortRegex = matchWord;
+function weekdaysShortRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysShortStrictRegex;
+ } else {
+ return this._weekdaysShortRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_weekdaysShortRegex')) {
+ this._weekdaysShortRegex = defaultWeekdaysShortRegex;
+ }
+ return this._weekdaysShortStrictRegex && isStrict ?
+ this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
+ }
+}
+
+var defaultWeekdaysMinRegex = matchWord;
+function weekdaysMinRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysMinStrictRegex;
+ } else {
+ return this._weekdaysMinRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_weekdaysMinRegex')) {
+ this._weekdaysMinRegex = defaultWeekdaysMinRegex;
+ }
+ return this._weekdaysMinStrictRegex && isStrict ?
+ this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
+ }
+}
+
+
+function computeWeekdaysParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom, minp, shortp, longp;
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ mom = createUTC([2000, 1]).day(i);
+ minp = this.weekdaysMin(mom, '');
+ shortp = this.weekdaysShort(mom, '');
+ longp = this.weekdays(mom, '');
+ minPieces.push(minp);
+ shortPieces.push(shortp);
+ longPieces.push(longp);
+ mixedPieces.push(minp);
+ mixedPieces.push(shortp);
+ mixedPieces.push(longp);
+ }
+ // Sorting makes sure if one weekday (or abbr) is a prefix of another it
+ // will match the longer piece.
+ minPieces.sort(cmpLenRev);
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 7; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._weekdaysShortRegex = this._weekdaysRegex;
+ this._weekdaysMinRegex = this._weekdaysRegex;
+
+ this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
+ this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
+}
+
+// FORMATTING
+
+function hFormat() {
+ return this.hours() % 12 || 12;
+}
+
+function kFormat() {
+ return this.hours() || 24;
+}
+
+addFormatToken('H', ['HH', 2], 0, 'hour');
+addFormatToken('h', ['hh', 2], 0, hFormat);
+addFormatToken('k', ['kk', 2], 0, kFormat);
+
+addFormatToken('hmm', 0, 0, function () {
+ return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
+});
+
+addFormatToken('hmmss', 0, 0, function () {
+ return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
+ zeroFill(this.seconds(), 2);
+});
+
+addFormatToken('Hmm', 0, 0, function () {
+ return '' + this.hours() + zeroFill(this.minutes(), 2);
+});
+
+addFormatToken('Hmmss', 0, 0, function () {
+ return '' + this.hours() + zeroFill(this.minutes(), 2) +
+ zeroFill(this.seconds(), 2);
+});
+
+function meridiem (token, lowercase) {
+ addFormatToken(token, 0, 0, function () {
+ return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
+ });
+}
+
+meridiem('a', true);
+meridiem('A', false);
+
+// ALIASES
+
+addUnitAlias('hour', 'h');
+
+// PRIORITY
+addUnitPriority('hour', 13);
+
+// PARSING
+
+function matchMeridiem (isStrict, locale) {
+ return locale._meridiemParse;
+}
+
+addRegexToken('a', matchMeridiem);
+addRegexToken('A', matchMeridiem);
+addRegexToken('H', match1to2);
+addRegexToken('h', match1to2);
+addRegexToken('k', match1to2);
+addRegexToken('HH', match1to2, match2);
+addRegexToken('hh', match1to2, match2);
+addRegexToken('kk', match1to2, match2);
+
+addRegexToken('hmm', match3to4);
+addRegexToken('hmmss', match5to6);
+addRegexToken('Hmm', match3to4);
+addRegexToken('Hmmss', match5to6);
+
+addParseToken(['H', 'HH'], HOUR);
+addParseToken(['k', 'kk'], function (input, array, config) {
+ var kInput = toInt(input);
+ array[HOUR] = kInput === 24 ? 0 : kInput;
+});
+addParseToken(['a', 'A'], function (input, array, config) {
+ config._isPm = config._locale.isPM(input);
+ config._meridiem = input;
+});
+addParseToken(['h', 'hh'], function (input, array, config) {
+ array[HOUR] = toInt(input);
+ getParsingFlags(config).bigHour = true;
+});
+addParseToken('hmm', function (input, array, config) {
+ var pos = input.length - 2;
+ array[HOUR] = toInt(input.substr(0, pos));
+ array[MINUTE] = toInt(input.substr(pos));
+ getParsingFlags(config).bigHour = true;
+});
+addParseToken('hmmss', function (input, array, config) {
+ var pos1 = input.length - 4;
+ var pos2 = input.length - 2;
+ array[HOUR] = toInt(input.substr(0, pos1));
+ array[MINUTE] = toInt(input.substr(pos1, 2));
+ array[SECOND] = toInt(input.substr(pos2));
+ getParsingFlags(config).bigHour = true;
+});
+addParseToken('Hmm', function (input, array, config) {
+ var pos = input.length - 2;
+ array[HOUR] = toInt(input.substr(0, pos));
+ array[MINUTE] = toInt(input.substr(pos));
+});
+addParseToken('Hmmss', function (input, array, config) {
+ var pos1 = input.length - 4;
+ var pos2 = input.length - 2;
+ array[HOUR] = toInt(input.substr(0, pos1));
+ array[MINUTE] = toInt(input.substr(pos1, 2));
+ array[SECOND] = toInt(input.substr(pos2));
+});
+
+// LOCALES
+
+function localeIsPM (input) {
+ // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
+ // Using charAt should be more compatible.
+ return ((input + '').toLowerCase().charAt(0) === 'p');
+}
+
+var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
+function localeMeridiem (hours, minutes, isLower) {
+ if (hours > 11) {
+ return isLower ? 'pm' : 'PM';
+ } else {
+ return isLower ? 'am' : 'AM';
+ }
+}
+
+
+// MOMENTS
+
+// Setting the hour should keep the time, because the user explicitly
+// specified which hour he wants. So trying to maintain the same hour (in
+// a new timezone) makes sense. Adding/subtracting hours does not follow
+// this rule.
+var getSetHour = makeGetSet('Hours', true);
+
+// months
+// week
+// weekdays
+// meridiem
+var baseConfig = {
+ calendar: defaultCalendar,
+ longDateFormat: defaultLongDateFormat,
+ invalidDate: defaultInvalidDate,
+ ordinal: defaultOrdinal,
+ dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
+ relativeTime: defaultRelativeTime,
+
+ months: defaultLocaleMonths,
+ monthsShort: defaultLocaleMonthsShort,
+
+ week: defaultLocaleWeek,
+
+ weekdays: defaultLocaleWeekdays,
+ weekdaysMin: defaultLocaleWeekdaysMin,
+ weekdaysShort: defaultLocaleWeekdaysShort,
+
+ meridiemParse: defaultLocaleMeridiemParse
+};
+
+// internal storage for locale config files
+var locales = {};
+var localeFamilies = {};
+var globalLocale;
+
+function normalizeLocale(key) {
+ return key ? key.toLowerCase().replace('_', '-') : key;
+}
+
+// pick the locale from the array
+// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
+// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
+function chooseLocale(names) {
+ var i = 0, j, next, locale, split;
+
+ while (i < names.length) {
+ split = normalizeLocale(names[i]).split('-');
+ j = split.length;
+ next = normalizeLocale(names[i + 1]);
+ next = next ? next.split('-') : null;
+ while (j > 0) {
+ locale = loadLocale(split.slice(0, j).join('-'));
+ if (locale) {
+ return locale;
+ }
+ if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
+ //the next array item is better than a shallower substring of this one
+ break;
+ }
+ j--;
+ }
+ i++;
+ }
+ return null;
+}
+
+function loadLocale(name) {
+ var oldLocale = null;
+ // TODO: Find a better way to register and load all the locales in Node
+ if (!locales[name] && (typeof module !== 'undefined') &&
+ module && module.exports) {
+ try {
+ oldLocale = globalLocale._abbr;
+ require('./locale/' + name);
+ // because defineLocale currently also sets the global locale, we
+ // want to undo that for lazy loaded locales
+ getSetGlobalLocale(oldLocale);
+ } catch (e) { }
+ }
+ return locales[name];
+}
+
+// This function will load locale and then set the global locale. If
+// no arguments are passed in, it will simply return the current global
+// locale key.
+function getSetGlobalLocale (key, values) {
+ var data;
+ if (key) {
+ if (isUndefined(values)) {
+ data = getLocale(key);
+ }
+ else {
+ data = defineLocale(key, values);
+ }
+
+ if (data) {
+ // moment.duration._locale = moment._locale = data;
+ globalLocale = data;
+ }
+ }
+
+ return globalLocale._abbr;
+}
+
+function defineLocale (name, config) {
+ if (config !== null) {
+ var parentConfig = baseConfig;
+ config.abbr = name;
+ if (locales[name] != null) {
+ deprecateSimple('defineLocaleOverride',
+ 'use moment.updateLocale(localeName, config) to change ' +
+ 'an existing locale. moment.defineLocale(localeName, ' +
+ 'config) should only be used for creating a new locale ' +
+ 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
+ parentConfig = locales[name]._config;
+ } else if (config.parentLocale != null) {
+ if (locales[config.parentLocale] != null) {
+ parentConfig = locales[config.parentLocale]._config;
+ } else {
+ if (!localeFamilies[config.parentLocale]) {
+ localeFamilies[config.parentLocale] = [];
+ }
+ localeFamilies[config.parentLocale].push({
+ name: name,
+ config: config
+ });
+ return null;
+ }
+ }
+ locales[name] = new Locale(mergeConfigs(parentConfig, config));
+
+ if (localeFamilies[name]) {
+ localeFamilies[name].forEach(function (x) {
+ defineLocale(x.name, x.config);
+ });
+ }
+
+ // backwards compat for now: also set the locale
+ // make sure we set the locale AFTER all child locales have been
+ // created, so we won't end up with the child locale set.
+ getSetGlobalLocale(name);
+
+
+ return locales[name];
+ } else {
+ // useful for testing
+ delete locales[name];
+ return null;
+ }
+}
+
+function updateLocale(name, config) {
+ if (config != null) {
+ var locale, parentConfig = baseConfig;
+ // MERGE
+ if (locales[name] != null) {
+ parentConfig = locales[name]._config;
+ }
+ config = mergeConfigs(parentConfig, config);
+ locale = new Locale(config);
+ locale.parentLocale = locales[name];
+ locales[name] = locale;
+
+ // backwards compat for now: also set the locale
+ getSetGlobalLocale(name);
+ } else {
+ // pass null for config to unupdate, useful for tests
+ if (locales[name] != null) {
+ if (locales[name].parentLocale != null) {
+ locales[name] = locales[name].parentLocale;
+ } else if (locales[name] != null) {
+ delete locales[name];
+ }
+ }
+ }
+ return locales[name];
+}
+
+// returns locale data
+function getLocale (key) {
+ var locale;
+
+ if (key && key._locale && key._locale._abbr) {
+ key = key._locale._abbr;
+ }
+
+ if (!key) {
+ return globalLocale;
+ }
+
+ if (!isArray(key)) {
+ //short-circuit everything else
+ locale = loadLocale(key);
+ if (locale) {
+ return locale;
+ }
+ key = [key];
+ }
+
+ return chooseLocale(key);
+}
+
+function listLocales() {
+ return keys$1(locales);
+}
+
+function checkOverflow (m) {
+ var overflow;
+ var a = m._a;
+
+ if (a && getParsingFlags(m).overflow === -2) {
+ overflow =
+ a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
+ a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
+ a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
+ a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
+ a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
+ a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
+ -1;
+
+ if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
+ overflow = DATE;
+ }
+ if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
+ overflow = WEEK;
+ }
+ if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
+ overflow = WEEKDAY;
+ }
+
+ getParsingFlags(m).overflow = overflow;
+ }
+
+ return m;
+}
+
+// iso 8601 regex
+// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
+var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
+var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
+
+var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
+
+var isoDates = [
+ ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
+ ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
+ ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
+ ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
+ ['YYYY-DDD', /\d{4}-\d{3}/],
+ ['YYYY-MM', /\d{4}-\d\d/, false],
+ ['YYYYYYMMDD', /[+-]\d{10}/],
+ ['YYYYMMDD', /\d{8}/],
+ // YYYYMM is NOT allowed by the standard
+ ['GGGG[W]WWE', /\d{4}W\d{3}/],
+ ['GGGG[W]WW', /\d{4}W\d{2}/, false],
+ ['YYYYDDD', /\d{7}/]
+];
+
+// iso time formats and regexes
+var isoTimes = [
+ ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
+ ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
+ ['HH:mm:ss', /\d\d:\d\d:\d\d/],
+ ['HH:mm', /\d\d:\d\d/],
+ ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
+ ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
+ ['HHmmss', /\d\d\d\d\d\d/],
+ ['HHmm', /\d\d\d\d/],
+ ['HH', /\d\d/]
+];
+
+var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
+
+// date from iso format
+function configFromISO(config) {
+ var i, l,
+ string = config._i,
+ match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
+ allowTime, dateFormat, timeFormat, tzFormat;
+
+ if (match) {
+ getParsingFlags(config).iso = true;
+
+ for (i = 0, l = isoDates.length; i < l; i++) {
+ if (isoDates[i][1].exec(match[1])) {
+ dateFormat = isoDates[i][0];
+ allowTime = isoDates[i][2] !== false;
+ break;
+ }
+ }
+ if (dateFormat == null) {
+ config._isValid = false;
+ return;
+ }
+ if (match[3]) {
+ for (i = 0, l = isoTimes.length; i < l; i++) {
+ if (isoTimes[i][1].exec(match[3])) {
+ // match[2] should be 'T' or space
+ timeFormat = (match[2] || ' ') + isoTimes[i][0];
+ break;
+ }
+ }
+ if (timeFormat == null) {
+ config._isValid = false;
+ return;
+ }
+ }
+ if (!allowTime && timeFormat != null) {
+ config._isValid = false;
+ return;
+ }
+ if (match[4]) {
+ if (tzRegex.exec(match[4])) {
+ tzFormat = 'Z';
+ } else {
+ config._isValid = false;
+ return;
+ }
+ }
+ config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
+ configFromStringAndFormat(config);
+ } else {
+ config._isValid = false;
+ }
+}
+
+// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
+var basicRfcRegex = /^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/;
+
+// date and time from ref 2822 format
+function configFromRFC2822(config) {
+ var string, match, dayFormat,
+ dateFormat, timeFormat, tzFormat;
+ var timezones = {
+ ' GMT': ' +0000',
+ ' EDT': ' -0400',
+ ' EST': ' -0500',
+ ' CDT': ' -0500',
+ ' CST': ' -0600',
+ ' MDT': ' -0600',
+ ' MST': ' -0700',
+ ' PDT': ' -0700',
+ ' PST': ' -0800'
+ };
+ var military = 'YXWVUTSRQPONZABCDEFGHIKLM';
+ var timezone, timezoneIndex;
+
+ string = config._i
+ .replace(/\([^\)]*\)|[\n\t]/g, ' ') // Remove comments and folding whitespace
+ .replace(/(\s\s+)/g, ' ') // Replace multiple-spaces with a single space
+ .replace(/^\s|\s$/g, ''); // Remove leading and trailing spaces
+ match = basicRfcRegex.exec(string);
+
+ if (match) {
+ dayFormat = match[1] ? 'ddd' + ((match[1].length === 5) ? ', ' : ' ') : '';
+ dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY ');
+ timeFormat = 'HH:mm' + (match[4] ? ':ss' : '');
+
+ // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
+ if (match[1]) { // day of week given
+ var momentDate = new Date(match[2]);
+ var momentDay = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][momentDate.getDay()];
+
+ if (match[1].substr(0,3) !== momentDay) {
+ getParsingFlags(config).weekdayMismatch = true;
+ config._isValid = false;
+ return;
+ }
+ }
+
+ switch (match[5].length) {
+ case 2: // military
+ if (timezoneIndex === 0) {
+ timezone = ' +0000';
+ } else {
+ timezoneIndex = military.indexOf(match[5][1].toUpperCase()) - 12;
+ timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
+ (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
+ }
+ break;
+ case 4: // Zone
+ timezone = timezones[match[5]];
+ break;
+ default: // UT or +/-9999
+ timezone = timezones[' GMT'];
+ }
+ match[5] = timezone;
+ config._i = match.splice(1).join('');
+ tzFormat = ' ZZ';
+ config._f = dayFormat + dateFormat + timeFormat + tzFormat;
+ configFromStringAndFormat(config);
+ getParsingFlags(config).rfc2822 = true;
+ } else {
+ config._isValid = false;
+ }
+}
+
+// date from iso format or fallback
+function configFromString(config) {
+ var matched = aspNetJsonRegex.exec(config._i);
+
+ if (matched !== null) {
+ config._d = new Date(+matched[1]);
+ return;
+ }
+
+ configFromISO(config);
+ if (config._isValid === false) {
+ delete config._isValid;
+ } else {
+ return;
+ }
+
+ configFromRFC2822(config);
+ if (config._isValid === false) {
+ delete config._isValid;
+ } else {
+ return;
+ }
+
+ // Final attempt, use Input Fallback
+ hooks.createFromInputFallback(config);
+}
+
+hooks.createFromInputFallback = deprecate(
+ 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
+ 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
+ 'discouraged and will be removed in an upcoming major release. Please refer to ' +
+ 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
+ function (config) {
+ config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
+ }
+);
+
+// Pick the first defined of two or three arguments.
+function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+}
+
+function currentDateArray(config) {
+ // hooks is actually the exported moment object
+ var nowValue = new Date(hooks.now());
+ if (config._useUTC) {
+ return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
+ }
+ return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
+}
+
+// convert an array to a date.
+// the array should mirror the parameters below
+// note: all values past the year are optional and will default to the lowest possible value.
+// [year, month, day , hour, minute, second, millisecond]
+function configFromArray (config) {
+ var i, date, input = [], currentDate, yearToUse;
+
+ if (config._d) {
+ return;
+ }
+
+ currentDate = currentDateArray(config);
+
+ //compute day of the year from weeks and weekdays
+ if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
+ dayOfYearFromWeekInfo(config);
+ }
+
+ //if the day of the year is set, figure out what it is
+ if (config._dayOfYear != null) {
+ yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
+
+ if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
+ getParsingFlags(config)._overflowDayOfYear = true;
+ }
+
+ date = createUTCDate(yearToUse, 0, config._dayOfYear);
+ config._a[MONTH] = date.getUTCMonth();
+ config._a[DATE] = date.getUTCDate();
+ }
+
+ // Default to current date.
+ // * if no year, month, day of month are given, default to today
+ // * if day of month is given, default month and year
+ // * if month is given, default only year
+ // * if year is given, don't default anything
+ for (i = 0; i < 3 && config._a[i] == null; ++i) {
+ config._a[i] = input[i] = currentDate[i];
+ }
+
+ // Zero out whatever was not defaulted, including time
+ for (; i < 7; i++) {
+ config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
+ }
+
+ // Check for 24:00:00.000
+ if (config._a[HOUR] === 24 &&
+ config._a[MINUTE] === 0 &&
+ config._a[SECOND] === 0 &&
+ config._a[MILLISECOND] === 0) {
+ config._nextDay = true;
+ config._a[HOUR] = 0;
+ }
+
+ config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
+ // Apply timezone offset from input. The actual utcOffset can be changed
+ // with parseZone.
+ if (config._tzm != null) {
+ config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
+ }
+
+ if (config._nextDay) {
+ config._a[HOUR] = 24;
+ }
+}
+
+function dayOfYearFromWeekInfo(config) {
+ var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
+
+ w = config._w;
+ if (w.GG != null || w.W != null || w.E != null) {
+ dow = 1;
+ doy = 4;
+
+ // TODO: We need to take the current isoWeekYear, but that depends on
+ // how we interpret now (local, utc, fixed offset). So create
+ // a now version of current config (take local/utc/offset flags, and
+ // create now).
+ weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
+ week = defaults(w.W, 1);
+ weekday = defaults(w.E, 1);
+ if (weekday < 1 || weekday > 7) {
+ weekdayOverflow = true;
+ }
+ } else {
+ dow = config._locale._week.dow;
+ doy = config._locale._week.doy;
+
+ var curWeek = weekOfYear(createLocal(), dow, doy);
+
+ weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
+
+ // Default to current week.
+ week = defaults(w.w, curWeek.week);
+
+ if (w.d != null) {
+ // weekday -- low day numbers are considered next week
+ weekday = w.d;
+ if (weekday < 0 || weekday > 6) {
+ weekdayOverflow = true;
+ }
+ } else if (w.e != null) {
+ // local weekday -- counting starts from begining of week
+ weekday = w.e + dow;
+ if (w.e < 0 || w.e > 6) {
+ weekdayOverflow = true;
+ }
+ } else {
+ // default to begining of week
+ weekday = dow;
+ }
+ }
+ if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
+ getParsingFlags(config)._overflowWeeks = true;
+ } else if (weekdayOverflow != null) {
+ getParsingFlags(config)._overflowWeekday = true;
+ } else {
+ temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
+ config._a[YEAR] = temp.year;
+ config._dayOfYear = temp.dayOfYear;
+ }
+}
+
+// constant that refers to the ISO standard
+hooks.ISO_8601 = function () {};
+
+// constant that refers to the RFC 2822 form
+hooks.RFC_2822 = function () {};
+
+// date from string and format string
+function configFromStringAndFormat(config) {
+ // TODO: Move this to another part of the creation flow to prevent circular deps
+ if (config._f === hooks.ISO_8601) {
+ configFromISO(config);
+ return;
+ }
+ if (config._f === hooks.RFC_2822) {
+ configFromRFC2822(config);
+ return;
+ }
+ config._a = [];
+ getParsingFlags(config).empty = true;
+
+ // This array is used to make a Date, either with `new Date` or `Date.UTC`
+ var string = '' + config._i,
+ i, parsedInput, tokens, token, skipped,
+ stringLength = string.length,
+ totalParsedInputLength = 0;
+
+ tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
+
+ for (i = 0; i < tokens.length; i++) {
+ token = tokens[i];
+ parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
+ // console.log('token', token, 'parsedInput', parsedInput,
+ // 'regex', getParseRegexForToken(token, config));
+ if (parsedInput) {
+ skipped = string.substr(0, string.indexOf(parsedInput));
+ if (skipped.length > 0) {
+ getParsingFlags(config).unusedInput.push(skipped);
+ }
+ string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
+ totalParsedInputLength += parsedInput.length;
+ }
+ // don't parse if it's not a known token
+ if (formatTokenFunctions[token]) {
+ if (parsedInput) {
+ getParsingFlags(config).empty = false;
+ }
+ else {
+ getParsingFlags(config).unusedTokens.push(token);
+ }
+ addTimeToArrayFromToken(token, parsedInput, config);
+ }
+ else if (config._strict && !parsedInput) {
+ getParsingFlags(config).unusedTokens.push(token);
+ }
+ }
+
+ // add remaining unparsed input length to the string
+ getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
+ if (string.length > 0) {
+ getParsingFlags(config).unusedInput.push(string);
+ }
+
+ // clear _12h flag if hour is <= 12
+ if (config._a[HOUR] <= 12 &&
+ getParsingFlags(config).bigHour === true &&
+ config._a[HOUR] > 0) {
+ getParsingFlags(config).bigHour = undefined;
+ }
+
+ getParsingFlags(config).parsedDateParts = config._a.slice(0);
+ getParsingFlags(config).meridiem = config._meridiem;
+ // handle meridiem
+ config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
+
+ configFromArray(config);
+ checkOverflow(config);
+}
+
+
+function meridiemFixWrap (locale, hour, meridiem) {
+ var isPm;
+
+ if (meridiem == null) {
+ // nothing to do
+ return hour;
+ }
+ if (locale.meridiemHour != null) {
+ return locale.meridiemHour(hour, meridiem);
+ } else if (locale.isPM != null) {
+ // Fallback
+ isPm = locale.isPM(meridiem);
+ if (isPm && hour < 12) {
+ hour += 12;
+ }
+ if (!isPm && hour === 12) {
+ hour = 0;
+ }
+ return hour;
+ } else {
+ // this is not supposed to happen
+ return hour;
+ }
+}
+
+// date from string and array of format strings
+function configFromStringAndArray(config) {
+ var tempConfig,
+ bestMoment,
+
+ scoreToBeat,
+ i,
+ currentScore;
+
+ if (config._f.length === 0) {
+ getParsingFlags(config).invalidFormat = true;
+ config._d = new Date(NaN);
+ return;
+ }
+
+ for (i = 0; i < config._f.length; i++) {
+ currentScore = 0;
+ tempConfig = copyConfig({}, config);
+ if (config._useUTC != null) {
+ tempConfig._useUTC = config._useUTC;
+ }
+ tempConfig._f = config._f[i];
+ configFromStringAndFormat(tempConfig);
+
+ if (!isValid(tempConfig)) {
+ continue;
+ }
+
+ // if there is any input that was not parsed add a penalty for that format
+ currentScore += getParsingFlags(tempConfig).charsLeftOver;
+
+ //or tokens
+ currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
+
+ getParsingFlags(tempConfig).score = currentScore;
+
+ if (scoreToBeat == null || currentScore < scoreToBeat) {
+ scoreToBeat = currentScore;
+ bestMoment = tempConfig;
+ }
+ }
+
+ extend(config, bestMoment || tempConfig);
+}
+
+function configFromObject(config) {
+ if (config._d) {
+ return;
+ }
+
+ var i = normalizeObjectUnits(config._i);
+ config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
+ return obj && parseInt(obj, 10);
+ });
+
+ configFromArray(config);
+}
+
+function createFromConfig (config) {
+ var res = new Moment(checkOverflow(prepareConfig(config)));
+ if (res._nextDay) {
+ // Adding is smart enough around DST
+ res.add(1, 'd');
+ res._nextDay = undefined;
+ }
+
+ return res;
+}
+
+function prepareConfig (config) {
+ var input = config._i,
+ format = config._f;
+
+ config._locale = config._locale || getLocale(config._l);
+
+ if (input === null || (format === undefined && input === '')) {
+ return createInvalid({nullInput: true});
+ }
+
+ if (typeof input === 'string') {
+ config._i = input = config._locale.preparse(input);
+ }
+
+ if (isMoment(input)) {
+ return new Moment(checkOverflow(input));
+ } else if (isDate(input)) {
+ config._d = input;
+ } else if (isArray(format)) {
+ configFromStringAndArray(config);
+ } else if (format) {
+ configFromStringAndFormat(config);
+ } else {
+ configFromInput(config);
+ }
+
+ if (!isValid(config)) {
+ config._d = null;
+ }
+
+ return config;
+}
+
+function configFromInput(config) {
+ var input = config._i;
+ if (isUndefined(input)) {
+ config._d = new Date(hooks.now());
+ } else if (isDate(input)) {
+ config._d = new Date(input.valueOf());
+ } else if (typeof input === 'string') {
+ configFromString(config);
+ } else if (isArray(input)) {
+ config._a = map(input.slice(0), function (obj) {
+ return parseInt(obj, 10);
+ });
+ configFromArray(config);
+ } else if (isObject(input)) {
+ configFromObject(config);
+ } else if (isNumber(input)) {
+ // from milliseconds
+ config._d = new Date(input);
+ } else {
+ hooks.createFromInputFallback(config);
+ }
+}
+
+function createLocalOrUTC (input, format, locale, strict, isUTC) {
+ var c = {};
+
+ if (locale === true || locale === false) {
+ strict = locale;
+ locale = undefined;
+ }
+
+ if ((isObject(input) && isObjectEmpty(input)) ||
+ (isArray(input) && input.length === 0)) {
+ input = undefined;
+ }
+ // object construction must be done this way.
+ // https://github.com/moment/moment/issues/1423
+ c._isAMomentObject = true;
+ c._useUTC = c._isUTC = isUTC;
+ c._l = locale;
+ c._i = input;
+ c._f = format;
+ c._strict = strict;
+
+ return createFromConfig(c);
+}
+
+function createLocal (input, format, locale, strict) {
+ return createLocalOrUTC(input, format, locale, strict, false);
+}
+
+var prototypeMin = deprecate(
+ 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
+ function () {
+ var other = createLocal.apply(null, arguments);
+ if (this.isValid() && other.isValid()) {
+ return other < this ? this : other;
+ } else {
+ return createInvalid();
+ }
+ }
+);
+
+var prototypeMax = deprecate(
+ 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
+ function () {
+ var other = createLocal.apply(null, arguments);
+ if (this.isValid() && other.isValid()) {
+ return other > this ? this : other;
+ } else {
+ return createInvalid();
+ }
+ }
+);
+
+// Pick a moment m from moments so that m[fn](other) is true for all
+// other. This relies on the function fn to be transitive.
+//
+// moments should either be an array of moment objects or an array, whose
+// first element is an array of moment objects.
+function pickBy(fn, moments) {
+ var res, i;
+ if (moments.length === 1 && isArray(moments[0])) {
+ moments = moments[0];
+ }
+ if (!moments.length) {
+ return createLocal();
+ }
+ res = moments[0];
+ for (i = 1; i < moments.length; ++i) {
+ if (!moments[i].isValid() || moments[i][fn](res)) {
+ res = moments[i];
+ }
+ }
+ return res;
+}
+
+// TODO: Use [].sort instead?
+function min () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isBefore', args);
+}
+
+function max () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isAfter', args);
+}
+
+var now = function () {
+ return Date.now ? Date.now() : +(new Date());
+};
+
+var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
+
+function isDurationValid(m) {
+ for (var key in m) {
+ if (!(ordering.indexOf(key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
+ return false;
+ }
+ }
+
+ var unitHasDecimal = false;
+ for (var i = 0; i < ordering.length; ++i) {
+ if (m[ordering[i]]) {
+ if (unitHasDecimal) {
+ return false; // only allow non-integers for smallest unit
+ }
+ if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
+ unitHasDecimal = true;
+ }
+ }
+ }
+
+ return true;
+}
+
+function isValid$1() {
+ return this._isValid;
+}
+
+function createInvalid$1() {
+ return createDuration(NaN);
+}
+
+function Duration (duration) {
+ var normalizedInput = normalizeObjectUnits(duration),
+ years = normalizedInput.year || 0,
+ quarters = normalizedInput.quarter || 0,
+ months = normalizedInput.month || 0,
+ weeks = normalizedInput.week || 0,
+ days = normalizedInput.day || 0,
+ hours = normalizedInput.hour || 0,
+ minutes = normalizedInput.minute || 0,
+ seconds = normalizedInput.second || 0,
+ milliseconds = normalizedInput.millisecond || 0;
+
+ this._isValid = isDurationValid(normalizedInput);
+
+ // representation for dateAddRemove
+ this._milliseconds = +milliseconds +
+ seconds * 1e3 + // 1000
+ minutes * 6e4 + // 1000 * 60
+ hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
+ // Because of dateAddRemove treats 24 hours as different from a
+ // day when working around DST, we need to store them separately
+ this._days = +days +
+ weeks * 7;
+ // It is impossible translate months into days without knowing
+ // which months you are are talking about, so we have to store
+ // it separately.
+ this._months = +months +
+ quarters * 3 +
+ years * 12;
+
+ this._data = {};
+
+ this._locale = getLocale();
+
+ this._bubble();
+}
+
+function isDuration (obj) {
+ return obj instanceof Duration;
+}
+
+function absRound (number) {
+ if (number < 0) {
+ return Math.round(-1 * number) * -1;
+ } else {
+ return Math.round(number);
+ }
+}
+
+// FORMATTING
+
+function offset (token, separator) {
+ addFormatToken(token, 0, 0, function () {
+ var offset = this.utcOffset();
+ var sign = '+';
+ if (offset < 0) {
+ offset = -offset;
+ sign = '-';
+ }
+ return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
+ });
+}
+
+offset('Z', ':');
+offset('ZZ', '');
+
+// PARSING
+
+addRegexToken('Z', matchShortOffset);
+addRegexToken('ZZ', matchShortOffset);
+addParseToken(['Z', 'ZZ'], function (input, array, config) {
+ config._useUTC = true;
+ config._tzm = offsetFromString(matchShortOffset, input);
+});
+
+// HELPERS
+
+// timezone chunker
+// '+10:00' > ['10', '00']
+// '-1530' > ['-15', '30']
+var chunkOffset = /([\+\-]|\d\d)/gi;
+
+function offsetFromString(matcher, string) {
+ var matches = (string || '').match(matcher);
+
+ if (matches === null) {
+ return null;
+ }
+
+ var chunk = matches[matches.length - 1] || [];
+ var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
+ var minutes = +(parts[1] * 60) + toInt(parts[2]);
+
+ return minutes === 0 ?
+ 0 :
+ parts[0] === '+' ? minutes : -minutes;
+}
+
+// Return a moment from input, that is local/utc/zone equivalent to model.
+function cloneWithOffset(input, model) {
+ var res, diff;
+ if (model._isUTC) {
+ res = model.clone();
+ diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
+ // Use low-level api, because this fn is low-level api.
+ res._d.setTime(res._d.valueOf() + diff);
+ hooks.updateOffset(res, false);
+ return res;
+ } else {
+ return createLocal(input).local();
+ }
+}
+
+function getDateOffset (m) {
+ // On Firefox.24 Date#getTimezoneOffset returns a floating point.
+ // https://github.com/moment/moment/pull/1871
+ return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
+}
+
+// HOOKS
+
+// This function will be called whenever a moment is mutated.
+// It is intended to keep the offset in sync with the timezone.
+hooks.updateOffset = function () {};
+
+// MOMENTS
+
+// keepLocalTime = true means only change the timezone, without
+// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
+// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
+// +0200, so we adjust the time as needed, to be valid.
+//
+// Keeping the time actually adds/subtracts (one hour)
+// from the actual represented time. That is why we call updateOffset
+// a second time. In case it wants us to change the offset again
+// _changeInProgress == true case, then we have to adjust, because
+// there is no such time in the given timezone.
+function getSetOffset (input, keepLocalTime, keepMinutes) {
+ var offset = this._offset || 0,
+ localAdjust;
+ if (!this.isValid()) {
+ return input != null ? this : NaN;
+ }
+ if (input != null) {
+ if (typeof input === 'string') {
+ input = offsetFromString(matchShortOffset, input);
+ if (input === null) {
+ return this;
+ }
+ } else if (Math.abs(input) < 16 && !keepMinutes) {
+ input = input * 60;
+ }
+ if (!this._isUTC && keepLocalTime) {
+ localAdjust = getDateOffset(this);
+ }
+ this._offset = input;
+ this._isUTC = true;
+ if (localAdjust != null) {
+ this.add(localAdjust, 'm');
+ }
+ if (offset !== input) {
+ if (!keepLocalTime || this._changeInProgress) {
+ addSubtract(this, createDuration(input - offset, 'm'), 1, false);
+ } else if (!this._changeInProgress) {
+ this._changeInProgress = true;
+ hooks.updateOffset(this, true);
+ this._changeInProgress = null;
+ }
+ }
+ return this;
+ } else {
+ return this._isUTC ? offset : getDateOffset(this);
+ }
+}
+
+function getSetZone (input, keepLocalTime) {
+ if (input != null) {
+ if (typeof input !== 'string') {
+ input = -input;
+ }
+
+ this.utcOffset(input, keepLocalTime);
+
+ return this;
+ } else {
+ return -this.utcOffset();
+ }
+}
+
+function setOffsetToUTC (keepLocalTime) {
+ return this.utcOffset(0, keepLocalTime);
+}
+
+function setOffsetToLocal (keepLocalTime) {
+ if (this._isUTC) {
+ this.utcOffset(0, keepLocalTime);
+ this._isUTC = false;
+
+ if (keepLocalTime) {
+ this.subtract(getDateOffset(this), 'm');
+ }
+ }
+ return this;
+}
+
+function setOffsetToParsedOffset () {
+ if (this._tzm != null) {
+ this.utcOffset(this._tzm, false, true);
+ } else if (typeof this._i === 'string') {
+ var tZone = offsetFromString(matchOffset, this._i);
+ if (tZone != null) {
+ this.utcOffset(tZone);
+ }
+ else {
+ this.utcOffset(0, true);
+ }
+ }
+ return this;
+}
+
+function hasAlignedHourOffset (input) {
+ if (!this.isValid()) {
+ return false;
+ }
+ input = input ? createLocal(input).utcOffset() : 0;
+
+ return (this.utcOffset() - input) % 60 === 0;
+}
+
+function isDaylightSavingTime () {
+ return (
+ this.utcOffset() > this.clone().month(0).utcOffset() ||
+ this.utcOffset() > this.clone().month(5).utcOffset()
+ );
+}
+
+function isDaylightSavingTimeShifted () {
+ if (!isUndefined(this._isDSTShifted)) {
+ return this._isDSTShifted;
+ }
+
+ var c = {};
+
+ copyConfig(c, this);
+ c = prepareConfig(c);
+
+ if (c._a) {
+ var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
+ this._isDSTShifted = this.isValid() &&
+ compareArrays(c._a, other.toArray()) > 0;
+ } else {
+ this._isDSTShifted = false;
+ }
+
+ return this._isDSTShifted;
+}
+
+function isLocal () {
+ return this.isValid() ? !this._isUTC : false;
+}
+
+function isUtcOffset () {
+ return this.isValid() ? this._isUTC : false;
+}
+
+function isUtc () {
+ return this.isValid() ? this._isUTC && this._offset === 0 : false;
+}
+
+// ASP.NET json date format regex
+var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
+
+// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
+// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
+// and further modified to allow for strings containing both week and day
+var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
+
+function createDuration (input, key) {
+ var duration = input,
+ // matching against regexp is expensive, do it on demand
+ match = null,
+ sign,
+ ret,
+ diffRes;
+
+ if (isDuration(input)) {
+ duration = {
+ ms : input._milliseconds,
+ d : input._days,
+ M : input._months
+ };
+ } else if (isNumber(input)) {
+ duration = {};
+ if (key) {
+ duration[key] = input;
+ } else {
+ duration.milliseconds = input;
+ }
+ } else if (!!(match = aspNetRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ duration = {
+ y : 0,
+ d : toInt(match[DATE]) * sign,
+ h : toInt(match[HOUR]) * sign,
+ m : toInt(match[MINUTE]) * sign,
+ s : toInt(match[SECOND]) * sign,
+ ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
+ };
+ } else if (!!(match = isoRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ duration = {
+ y : parseIso(match[2], sign),
+ M : parseIso(match[3], sign),
+ w : parseIso(match[4], sign),
+ d : parseIso(match[5], sign),
+ h : parseIso(match[6], sign),
+ m : parseIso(match[7], sign),
+ s : parseIso(match[8], sign)
+ };
+ } else if (duration == null) {// checks for null or undefined
+ duration = {};
+ } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
+ diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
+
+ duration = {};
+ duration.ms = diffRes.milliseconds;
+ duration.M = diffRes.months;
+ }
+
+ ret = new Duration(duration);
+
+ if (isDuration(input) && hasOwnProp(input, '_locale')) {
+ ret._locale = input._locale;
+ }
+
+ return ret;
+}
+
+createDuration.fn = Duration.prototype;
+createDuration.invalid = createInvalid$1;
+
+function parseIso (inp, sign) {
+ // We'd normally use ~~inp for this, but unfortunately it also
+ // converts floats to ints.
+ // inp may be undefined, so careful calling replace on it.
+ var res = inp && parseFloat(inp.replace(',', '.'));
+ // apply sign while we're at it
+ return (isNaN(res) ? 0 : res) * sign;
+}
+
+function positiveMomentsDifference(base, other) {
+ var res = {milliseconds: 0, months: 0};
+
+ res.months = other.month() - base.month() +
+ (other.year() - base.year()) * 12;
+ if (base.clone().add(res.months, 'M').isAfter(other)) {
+ --res.months;
+ }
+
+ res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
+
+ return res;
+}
+
+function momentsDifference(base, other) {
+ var res;
+ if (!(base.isValid() && other.isValid())) {
+ return {milliseconds: 0, months: 0};
+ }
+
+ other = cloneWithOffset(other, base);
+ if (base.isBefore(other)) {
+ res = positiveMomentsDifference(base, other);
+ } else {
+ res = positiveMomentsDifference(other, base);
+ res.milliseconds = -res.milliseconds;
+ res.months = -res.months;
+ }
+
+ return res;
+}
+
+// TODO: remove 'name' arg after deprecation is removed
+function createAdder(direction, name) {
+ return function (val, period) {
+ var dur, tmp;
+ //invert the arguments, but complain about it
+ if (period !== null && !isNaN(+period)) {
+ deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
+ 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
+ tmp = val; val = period; period = tmp;
+ }
+
+ val = typeof val === 'string' ? +val : val;
+ dur = createDuration(val, period);
+ addSubtract(this, dur, direction);
+ return this;
+ };
+}
+
+function addSubtract (mom, duration, isAdding, updateOffset) {
+ var milliseconds = duration._milliseconds,
+ days = absRound(duration._days),
+ months = absRound(duration._months);
+
+ if (!mom.isValid()) {
+ // No op
+ return;
+ }
+
+ updateOffset = updateOffset == null ? true : updateOffset;
+
+ if (milliseconds) {
+ mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
+ }
+ if (days) {
+ set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
+ }
+ if (months) {
+ setMonth(mom, get(mom, 'Month') + months * isAdding);
+ }
+ if (updateOffset) {
+ hooks.updateOffset(mom, days || months);
+ }
+}
+
+var add = createAdder(1, 'add');
+var subtract = createAdder(-1, 'subtract');
+
+function getCalendarFormat(myMoment, now) {
+ var diff = myMoment.diff(now, 'days', true);
+ return diff < -6 ? 'sameElse' :
+ diff < -1 ? 'lastWeek' :
+ diff < 0 ? 'lastDay' :
+ diff < 1 ? 'sameDay' :
+ diff < 2 ? 'nextDay' :
+ diff < 7 ? 'nextWeek' : 'sameElse';
+}
+
+function calendar$1 (time, formats) {
+ // We want to compare the start of today, vs this.
+ // Getting start-of-today depends on whether we're local/utc/offset or not.
+ var now = time || createLocal(),
+ sod = cloneWithOffset(now, this).startOf('day'),
+ format = hooks.calendarFormat(this, sod) || 'sameElse';
+
+ var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
+
+ return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
+}
+
+function clone () {
+ return new Moment(this);
+}
+
+function isAfter (input, units) {
+ var localInput = isMoment(input) ? input : createLocal(input);
+ if (!(this.isValid() && localInput.isValid())) {
+ return false;
+ }
+ units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
+ if (units === 'millisecond') {
+ return this.valueOf() > localInput.valueOf();
+ } else {
+ return localInput.valueOf() < this.clone().startOf(units).valueOf();
+ }
+}
+
+function isBefore (input, units) {
+ var localInput = isMoment(input) ? input : createLocal(input);
+ if (!(this.isValid() && localInput.isValid())) {
+ return false;
+ }
+ units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
+ if (units === 'millisecond') {
+ return this.valueOf() < localInput.valueOf();
+ } else {
+ return this.clone().endOf(units).valueOf() < localInput.valueOf();
+ }
+}
+
+function isBetween (from, to, units, inclusivity) {
+ inclusivity = inclusivity || '()';
+ return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
+ (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
+}
+
+function isSame (input, units) {
+ var localInput = isMoment(input) ? input : createLocal(input),
+ inputMs;
+ if (!(this.isValid() && localInput.isValid())) {
+ return false;
+ }
+ units = normalizeUnits(units || 'millisecond');
+ if (units === 'millisecond') {
+ return this.valueOf() === localInput.valueOf();
+ } else {
+ inputMs = localInput.valueOf();
+ return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
+ }
+}
+
+function isSameOrAfter (input, units) {
+ return this.isSame(input, units) || this.isAfter(input,units);
+}
+
+function isSameOrBefore (input, units) {
+ return this.isSame(input, units) || this.isBefore(input,units);
+}
+
+function diff (input, units, asFloat) {
+ var that,
+ zoneDelta,
+ delta, output;
+
+ if (!this.isValid()) {
+ return NaN;
+ }
+
+ that = cloneWithOffset(input, this);
+
+ if (!that.isValid()) {
+ return NaN;
+ }
+
+ zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
+
+ units = normalizeUnits(units);
+
+ if (units === 'year' || units === 'month' || units === 'quarter') {
+ output = monthDiff(this, that);
+ if (units === 'quarter') {
+ output = output / 3;
+ } else if (units === 'year') {
+ output = output / 12;
+ }
+ } else {
+ delta = this - that;
+ output = units === 'second' ? delta / 1e3 : // 1000
+ units === 'minute' ? delta / 6e4 : // 1000 * 60
+ units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
+ units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
+ units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
+ delta;
+ }
+ return asFloat ? output : absFloor(output);
+}
+
+function monthDiff (a, b) {
+ // difference in months
+ var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
+ // b is in (anchor - 1 month, anchor + 1 month)
+ anchor = a.clone().add(wholeMonthDiff, 'months'),
+ anchor2, adjust;
+
+ if (b - anchor < 0) {
+ anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor - anchor2);
+ } else {
+ anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor2 - anchor);
+ }
+
+ //check for negative zero, return zero if negative zero
+ return -(wholeMonthDiff + adjust) || 0;
+}
+
+hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
+hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
+
+function toString () {
+ return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
+}
+
+function toISOString() {
+ if (!this.isValid()) {
+ return null;
+ }
+ var m = this.clone().utc();
+ if (m.year() < 0 || m.year() > 9999) {
+ return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
+ if (isFunction(Date.prototype.toISOString)) {
+ // native implementation is ~50x faster, use it when we can
+ return this.toDate().toISOString();
+ }
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+}
+
+/**
+ * Return a human readable representation of a moment that can
+ * also be evaluated to get a new moment which is the same
+ *
+ * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
+ */
+function inspect () {
+ if (!this.isValid()) {
+ return 'moment.invalid(/* ' + this._i + ' */)';
+ }
+ var func = 'moment';
+ var zone = '';
+ if (!this.isLocal()) {
+ func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
+ zone = 'Z';
+ }
+ var prefix = '[' + func + '("]';
+ var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
+ var datetime = '-MM-DD[T]HH:mm:ss.SSS';
+ var suffix = zone + '[")]';
+
+ return this.format(prefix + year + datetime + suffix);
+}
+
+function format (inputString) {
+ if (!inputString) {
+ inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
+ }
+ var output = formatMoment(this, inputString);
+ return this.localeData().postformat(output);
+}
+
+function from (time, withoutSuffix) {
+ if (this.isValid() &&
+ ((isMoment(time) && time.isValid()) ||
+ createLocal(time).isValid())) {
+ return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
+ } else {
+ return this.localeData().invalidDate();
+ }
+}
+
+function fromNow (withoutSuffix) {
+ return this.from(createLocal(), withoutSuffix);
+}
+
+function to (time, withoutSuffix) {
+ if (this.isValid() &&
+ ((isMoment(time) && time.isValid()) ||
+ createLocal(time).isValid())) {
+ return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
+ } else {
+ return this.localeData().invalidDate();
+ }
+}
+
+function toNow (withoutSuffix) {
+ return this.to(createLocal(), withoutSuffix);
+}
+
+// If passed a locale key, it will set the locale for this
+// instance. Otherwise, it will return the locale configuration
+// variables for this instance.
+function locale (key) {
+ var newLocaleData;
+
+ if (key === undefined) {
+ return this._locale._abbr;
+ } else {
+ newLocaleData = getLocale(key);
+ if (newLocaleData != null) {
+ this._locale = newLocaleData;
+ }
+ return this;
+ }
+}
+
+var lang = deprecate(
+ 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
+ function (key) {
+ if (key === undefined) {
+ return this.localeData();
+ } else {
+ return this.locale(key);
+ }
+ }
+);
+
+function localeData () {
+ return this._locale;
+}
+
+function startOf (units) {
+ units = normalizeUnits(units);
+ // the following switch intentionally omits break keywords
+ // to utilize falling through the cases.
+ switch (units) {
+ case 'year':
+ this.month(0);
+ /* falls through */
+ case 'quarter':
+ case 'month':
+ this.date(1);
+ /* falls through */
+ case 'week':
+ case 'isoWeek':
+ case 'day':
+ case 'date':
+ this.hours(0);
+ /* falls through */
+ case 'hour':
+ this.minutes(0);
+ /* falls through */
+ case 'minute':
+ this.seconds(0);
+ /* falls through */
+ case 'second':
+ this.milliseconds(0);
+ }
+
+ // weeks are a special case
+ if (units === 'week') {
+ this.weekday(0);
+ }
+ if (units === 'isoWeek') {
+ this.isoWeekday(1);
+ }
+
+ // quarters are also special
+ if (units === 'quarter') {
+ this.month(Math.floor(this.month() / 3) * 3);
+ }
+
+ return this;
+}
+
+function endOf (units) {
+ units = normalizeUnits(units);
+ if (units === undefined || units === 'millisecond') {
+ return this;
+ }
+
+ // 'date' is an alias for 'day', so it should be considered as such.
+ if (units === 'date') {
+ units = 'day';
+ }
+
+ return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
+}
+
+function valueOf () {
+ return this._d.valueOf() - ((this._offset || 0) * 60000);
+}
+
+function unix () {
+ return Math.floor(this.valueOf() / 1000);
+}
+
+function toDate () {
+ return new Date(this.valueOf());
+}
+
+function toArray () {
+ var m = this;
+ return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
+}
+
+function toObject () {
+ var m = this;
+ return {
+ years: m.year(),
+ months: m.month(),
+ date: m.date(),
+ hours: m.hours(),
+ minutes: m.minutes(),
+ seconds: m.seconds(),
+ milliseconds: m.milliseconds()
+ };
+}
+
+function toJSON () {
+ // new Date(NaN).toJSON() === null
+ return this.isValid() ? this.toISOString() : null;
+}
+
+function isValid$2 () {
+ return isValid(this);
+}
+
+function parsingFlags () {
+ return extend({}, getParsingFlags(this));
+}
+
+function invalidAt () {
+ return getParsingFlags(this).overflow;
+}
+
+function creationData() {
+ return {
+ input: this._i,
+ format: this._f,
+ locale: this._locale,
+ isUTC: this._isUTC,
+ strict: this._strict
+ };
+}
+
+// FORMATTING
+
+addFormatToken(0, ['gg', 2], 0, function () {
+ return this.weekYear() % 100;
+});
+
+addFormatToken(0, ['GG', 2], 0, function () {
+ return this.isoWeekYear() % 100;
+});
+
+function addWeekYearFormatToken (token, getter) {
+ addFormatToken(0, [token, token.length], 0, getter);
+}
+
+addWeekYearFormatToken('gggg', 'weekYear');
+addWeekYearFormatToken('ggggg', 'weekYear');
+addWeekYearFormatToken('GGGG', 'isoWeekYear');
+addWeekYearFormatToken('GGGGG', 'isoWeekYear');
+
+// ALIASES
+
+addUnitAlias('weekYear', 'gg');
+addUnitAlias('isoWeekYear', 'GG');
+
+// PRIORITY
+
+addUnitPriority('weekYear', 1);
+addUnitPriority('isoWeekYear', 1);
+
+
+// PARSING
+
+addRegexToken('G', matchSigned);
+addRegexToken('g', matchSigned);
+addRegexToken('GG', match1to2, match2);
+addRegexToken('gg', match1to2, match2);
+addRegexToken('GGGG', match1to4, match4);
+addRegexToken('gggg', match1to4, match4);
+addRegexToken('GGGGG', match1to6, match6);
+addRegexToken('ggggg', match1to6, match6);
+
+addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
+ week[token.substr(0, 2)] = toInt(input);
+});
+
+addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
+ week[token] = hooks.parseTwoDigitYear(input);
+});
+
+// MOMENTS
+
+function getSetWeekYear (input) {
+ return getSetWeekYearHelper.call(this,
+ input,
+ this.week(),
+ this.weekday(),
+ this.localeData()._week.dow,
+ this.localeData()._week.doy);
+}
+
+function getSetISOWeekYear (input) {
+ return getSetWeekYearHelper.call(this,
+ input, this.isoWeek(), this.isoWeekday(), 1, 4);
+}
+
+function getISOWeeksInYear () {
+ return weeksInYear(this.year(), 1, 4);
+}
+
+function getWeeksInYear () {
+ var weekInfo = this.localeData()._week;
+ return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
+}
+
+function getSetWeekYearHelper(input, week, weekday, dow, doy) {
+ var weeksTarget;
+ if (input == null) {
+ return weekOfYear(this, dow, doy).year;
+ } else {
+ weeksTarget = weeksInYear(input, dow, doy);
+ if (week > weeksTarget) {
+ week = weeksTarget;
+ }
+ return setWeekAll.call(this, input, week, weekday, dow, doy);
+ }
+}
+
+function setWeekAll(weekYear, week, weekday, dow, doy) {
+ var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
+ date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
+
+ this.year(date.getUTCFullYear());
+ this.month(date.getUTCMonth());
+ this.date(date.getUTCDate());
+ return this;
+}
+
+// FORMATTING
+
+addFormatToken('Q', 0, 'Qo', 'quarter');
+
+// ALIASES
+
+addUnitAlias('quarter', 'Q');
+
+// PRIORITY
+
+addUnitPriority('quarter', 7);
+
+// PARSING
+
+addRegexToken('Q', match1);
+addParseToken('Q', function (input, array) {
+ array[MONTH] = (toInt(input) - 1) * 3;
+});
+
+// MOMENTS
+
+function getSetQuarter (input) {
+ return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
+}
+
+// FORMATTING
+
+addFormatToken('D', ['DD', 2], 'Do', 'date');
+
+// ALIASES
+
+addUnitAlias('date', 'D');
+
+// PRIOROITY
+addUnitPriority('date', 9);
+
+// PARSING
+
+addRegexToken('D', match1to2);
+addRegexToken('DD', match1to2, match2);
+addRegexToken('Do', function (isStrict, locale) {
+ // TODO: Remove "ordinalParse" fallback in next major release.
+ return isStrict ?
+ (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
+ locale._dayOfMonthOrdinalParseLenient;
+});
+
+addParseToken(['D', 'DD'], DATE);
+addParseToken('Do', function (input, array) {
+ array[DATE] = toInt(input.match(match1to2)[0], 10);
+});
+
+// MOMENTS
+
+var getSetDayOfMonth = makeGetSet('Date', true);
+
+// FORMATTING
+
+addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
+
+// ALIASES
+
+addUnitAlias('dayOfYear', 'DDD');
+
+// PRIORITY
+addUnitPriority('dayOfYear', 4);
+
+// PARSING
+
+addRegexToken('DDD', match1to3);
+addRegexToken('DDDD', match3);
+addParseToken(['DDD', 'DDDD'], function (input, array, config) {
+ config._dayOfYear = toInt(input);
+});
+
+// HELPERS
+
+// MOMENTS
+
+function getSetDayOfYear (input) {
+ var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
+ return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
+}
+
+// FORMATTING
+
+addFormatToken('m', ['mm', 2], 0, 'minute');
+
+// ALIASES
+
+addUnitAlias('minute', 'm');
+
+// PRIORITY
+
+addUnitPriority('minute', 14);
+
+// PARSING
+
+addRegexToken('m', match1to2);
+addRegexToken('mm', match1to2, match2);
+addParseToken(['m', 'mm'], MINUTE);
+
+// MOMENTS
+
+var getSetMinute = makeGetSet('Minutes', false);
+
+// FORMATTING
+
+addFormatToken('s', ['ss', 2], 0, 'second');
+
+// ALIASES
+
+addUnitAlias('second', 's');
+
+// PRIORITY
+
+addUnitPriority('second', 15);
+
+// PARSING
+
+addRegexToken('s', match1to2);
+addRegexToken('ss', match1to2, match2);
+addParseToken(['s', 'ss'], SECOND);
+
+// MOMENTS
+
+var getSetSecond = makeGetSet('Seconds', false);
+
+// FORMATTING
+
+addFormatToken('S', 0, 0, function () {
+ return ~~(this.millisecond() / 100);
+});
+
+addFormatToken(0, ['SS', 2], 0, function () {
+ return ~~(this.millisecond() / 10);
+});
+
+addFormatToken(0, ['SSS', 3], 0, 'millisecond');
+addFormatToken(0, ['SSSS', 4], 0, function () {
+ return this.millisecond() * 10;
+});
+addFormatToken(0, ['SSSSS', 5], 0, function () {
+ return this.millisecond() * 100;
+});
+addFormatToken(0, ['SSSSSS', 6], 0, function () {
+ return this.millisecond() * 1000;
+});
+addFormatToken(0, ['SSSSSSS', 7], 0, function () {
+ return this.millisecond() * 10000;
+});
+addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
+ return this.millisecond() * 100000;
+});
+addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
+ return this.millisecond() * 1000000;
+});
+
+
+// ALIASES
+
+addUnitAlias('millisecond', 'ms');
+
+// PRIORITY
+
+addUnitPriority('millisecond', 16);
+
+// PARSING
+
+addRegexToken('S', match1to3, match1);
+addRegexToken('SS', match1to3, match2);
+addRegexToken('SSS', match1to3, match3);
+
+var token;
+for (token = 'SSSS'; token.length <= 9; token += 'S') {
+ addRegexToken(token, matchUnsigned);
+}
+
+function parseMs(input, array) {
+ array[MILLISECOND] = toInt(('0.' + input) * 1000);
+}
+
+for (token = 'S'; token.length <= 9; token += 'S') {
+ addParseToken(token, parseMs);
+}
+// MOMENTS
+
+var getSetMillisecond = makeGetSet('Milliseconds', false);
+
+// FORMATTING
+
+addFormatToken('z', 0, 0, 'zoneAbbr');
+addFormatToken('zz', 0, 0, 'zoneName');
+
+// MOMENTS
+
+function getZoneAbbr () {
+ return this._isUTC ? 'UTC' : '';
+}
+
+function getZoneName () {
+ return this._isUTC ? 'Coordinated Universal Time' : '';
+}
+
+var proto = Moment.prototype;
+
+proto.add = add;
+proto.calendar = calendar$1;
+proto.clone = clone;
+proto.diff = diff;
+proto.endOf = endOf;
+proto.format = format;
+proto.from = from;
+proto.fromNow = fromNow;
+proto.to = to;
+proto.toNow = toNow;
+proto.get = stringGet;
+proto.invalidAt = invalidAt;
+proto.isAfter = isAfter;
+proto.isBefore = isBefore;
+proto.isBetween = isBetween;
+proto.isSame = isSame;
+proto.isSameOrAfter = isSameOrAfter;
+proto.isSameOrBefore = isSameOrBefore;
+proto.isValid = isValid$2;
+proto.lang = lang;
+proto.locale = locale;
+proto.localeData = localeData;
+proto.max = prototypeMax;
+proto.min = prototypeMin;
+proto.parsingFlags = parsingFlags;
+proto.set = stringSet;
+proto.startOf = startOf;
+proto.subtract = subtract;
+proto.toArray = toArray;
+proto.toObject = toObject;
+proto.toDate = toDate;
+proto.toISOString = toISOString;
+proto.inspect = inspect;
+proto.toJSON = toJSON;
+proto.toString = toString;
+proto.unix = unix;
+proto.valueOf = valueOf;
+proto.creationData = creationData;
+
+// Year
+proto.year = getSetYear;
+proto.isLeapYear = getIsLeapYear;
+
+// Week Year
+proto.weekYear = getSetWeekYear;
+proto.isoWeekYear = getSetISOWeekYear;
+
+// Quarter
+proto.quarter = proto.quarters = getSetQuarter;
+
+// Month
+proto.month = getSetMonth;
+proto.daysInMonth = getDaysInMonth;
+
+// Week
+proto.week = proto.weeks = getSetWeek;
+proto.isoWeek = proto.isoWeeks = getSetISOWeek;
+proto.weeksInYear = getWeeksInYear;
+proto.isoWeeksInYear = getISOWeeksInYear;
+
+// Day
+proto.date = getSetDayOfMonth;
+proto.day = proto.days = getSetDayOfWeek;
+proto.weekday = getSetLocaleDayOfWeek;
+proto.isoWeekday = getSetISODayOfWeek;
+proto.dayOfYear = getSetDayOfYear;
+
+// Hour
+proto.hour = proto.hours = getSetHour;
+
+// Minute
+proto.minute = proto.minutes = getSetMinute;
+
+// Second
+proto.second = proto.seconds = getSetSecond;
+
+// Millisecond
+proto.millisecond = proto.milliseconds = getSetMillisecond;
+
+// Offset
+proto.utcOffset = getSetOffset;
+proto.utc = setOffsetToUTC;
+proto.local = setOffsetToLocal;
+proto.parseZone = setOffsetToParsedOffset;
+proto.hasAlignedHourOffset = hasAlignedHourOffset;
+proto.isDST = isDaylightSavingTime;
+proto.isLocal = isLocal;
+proto.isUtcOffset = isUtcOffset;
+proto.isUtc = isUtc;
+proto.isUTC = isUtc;
+
+// Timezone
+proto.zoneAbbr = getZoneAbbr;
+proto.zoneName = getZoneName;
+
+// Deprecations
+proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
+proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
+proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
+proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
+proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
+
+function createUnix (input) {
+ return createLocal(input * 1000);
+}
+
+function createInZone () {
+ return createLocal.apply(null, arguments).parseZone();
+}
+
+function preParsePostFormat (string) {
+ return string;
+}
+
+var proto$1 = Locale.prototype;
+
+proto$1.calendar = calendar;
+proto$1.longDateFormat = longDateFormat;
+proto$1.invalidDate = invalidDate;
+proto$1.ordinal = ordinal;
+proto$1.preparse = preParsePostFormat;
+proto$1.postformat = preParsePostFormat;
+proto$1.relativeTime = relativeTime;
+proto$1.pastFuture = pastFuture;
+proto$1.set = set;
+
+// Month
+proto$1.months = localeMonths;
+proto$1.monthsShort = localeMonthsShort;
+proto$1.monthsParse = localeMonthsParse;
+proto$1.monthsRegex = monthsRegex;
+proto$1.monthsShortRegex = monthsShortRegex;
+
+// Week
+proto$1.week = localeWeek;
+proto$1.firstDayOfYear = localeFirstDayOfYear;
+proto$1.firstDayOfWeek = localeFirstDayOfWeek;
+
+// Day of Week
+proto$1.weekdays = localeWeekdays;
+proto$1.weekdaysMin = localeWeekdaysMin;
+proto$1.weekdaysShort = localeWeekdaysShort;
+proto$1.weekdaysParse = localeWeekdaysParse;
+
+proto$1.weekdaysRegex = weekdaysRegex;
+proto$1.weekdaysShortRegex = weekdaysShortRegex;
+proto$1.weekdaysMinRegex = weekdaysMinRegex;
+
+// Hours
+proto$1.isPM = localeIsPM;
+proto$1.meridiem = localeMeridiem;
+
+function get$1 (format, index, field, setter) {
+ var locale = getLocale();
+ var utc = createUTC().set(setter, index);
+ return locale[field](utc, format);
+}
+
+function listMonthsImpl (format, index, field) {
+ if (isNumber(format)) {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+
+ if (index != null) {
+ return get$1(format, index, field, 'month');
+ }
+
+ var i;
+ var out = [];
+ for (i = 0; i < 12; i++) {
+ out[i] = get$1(format, i, field, 'month');
+ }
+ return out;
+}
+
+// ()
+// (5)
+// (fmt, 5)
+// (fmt)
+// (true)
+// (true, 5)
+// (true, fmt, 5)
+// (true, fmt)
+function listWeekdaysImpl (localeSorted, format, index, field) {
+ if (typeof localeSorted === 'boolean') {
+ if (isNumber(format)) {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ } else {
+ format = localeSorted;
+ index = format;
+ localeSorted = false;
+
+ if (isNumber(format)) {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ }
+
+ var locale = getLocale(),
+ shift = localeSorted ? locale._week.dow : 0;
+
+ if (index != null) {
+ return get$1(format, (index + shift) % 7, field, 'day');
+ }
+
+ var i;
+ var out = [];
+ for (i = 0; i < 7; i++) {
+ out[i] = get$1(format, (i + shift) % 7, field, 'day');
+ }
+ return out;
+}
+
+function listMonths (format, index) {
+ return listMonthsImpl(format, index, 'months');
+}
+
+function listMonthsShort (format, index) {
+ return listMonthsImpl(format, index, 'monthsShort');
+}
+
+function listWeekdays (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
+}
+
+function listWeekdaysShort (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
+}
+
+function listWeekdaysMin (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
+}
+
+getSetGlobalLocale('en', {
+ dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (toInt(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
+ }
+});
+
+// Side effect imports
+hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
+hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
+
+var mathAbs = Math.abs;
+
+function abs () {
+ var data = this._data;
+
+ this._milliseconds = mathAbs(this._milliseconds);
+ this._days = mathAbs(this._days);
+ this._months = mathAbs(this._months);
+
+ data.milliseconds = mathAbs(data.milliseconds);
+ data.seconds = mathAbs(data.seconds);
+ data.minutes = mathAbs(data.minutes);
+ data.hours = mathAbs(data.hours);
+ data.months = mathAbs(data.months);
+ data.years = mathAbs(data.years);
+
+ return this;
+}
+
+function addSubtract$1 (duration, input, value, direction) {
+ var other = createDuration(input, value);
+
+ duration._milliseconds += direction * other._milliseconds;
+ duration._days += direction * other._days;
+ duration._months += direction * other._months;
+
+ return duration._bubble();
+}
+
+// supports only 2.0-style add(1, 's') or add(duration)
+function add$1 (input, value) {
+ return addSubtract$1(this, input, value, 1);
+}
+
+// supports only 2.0-style subtract(1, 's') or subtract(duration)
+function subtract$1 (input, value) {
+ return addSubtract$1(this, input, value, -1);
+}
+
+function absCeil (number) {
+ if (number < 0) {
+ return Math.floor(number);
+ } else {
+ return Math.ceil(number);
+ }
+}
+
+function bubble () {
+ var milliseconds = this._milliseconds;
+ var days = this._days;
+ var months = this._months;
+ var data = this._data;
+ var seconds, minutes, hours, years, monthsFromDays;
+
+ // if we have a mix of positive and negative values, bubble down first
+ // check: https://github.com/moment/moment/issues/2166
+ if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
+ (milliseconds <= 0 && days <= 0 && months <= 0))) {
+ milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
+ days = 0;
+ months = 0;
+ }
+
+ // The following code bubbles up values, see the tests for
+ // examples of what that means.
+ data.milliseconds = milliseconds % 1000;
+
+ seconds = absFloor(milliseconds / 1000);
+ data.seconds = seconds % 60;
+
+ minutes = absFloor(seconds / 60);
+ data.minutes = minutes % 60;
+
+ hours = absFloor(minutes / 60);
+ data.hours = hours % 24;
+
+ days += absFloor(hours / 24);
+
+ // convert days to months
+ monthsFromDays = absFloor(daysToMonths(days));
+ months += monthsFromDays;
+ days -= absCeil(monthsToDays(monthsFromDays));
+
+ // 12 months -> 1 year
+ years = absFloor(months / 12);
+ months %= 12;
+
+ data.days = days;
+ data.months = months;
+ data.years = years;
+
+ return this;
+}
+
+function daysToMonths (days) {
+ // 400 years have 146097 days (taking into account leap year rules)
+ // 400 years have 12 months === 4800
+ return days * 4800 / 146097;
+}
+
+function monthsToDays (months) {
+ // the reverse of daysToMonths
+ return months * 146097 / 4800;
+}
+
+function as (units) {
+ if (!this.isValid()) {
+ return NaN;
+ }
+ var days;
+ var months;
+ var milliseconds = this._milliseconds;
+
+ units = normalizeUnits(units);
+
+ if (units === 'month' || units === 'year') {
+ days = this._days + milliseconds / 864e5;
+ months = this._months + daysToMonths(days);
+ return units === 'month' ? months : months / 12;
+ } else {
+ // handle milliseconds separately because of floating point math errors (issue #1867)
+ days = this._days + Math.round(monthsToDays(this._months));
+ switch (units) {
+ case 'week' : return days / 7 + milliseconds / 6048e5;
+ case 'day' : return days + milliseconds / 864e5;
+ case 'hour' : return days * 24 + milliseconds / 36e5;
+ case 'minute' : return days * 1440 + milliseconds / 6e4;
+ case 'second' : return days * 86400 + milliseconds / 1000;
+ // Math.floor prevents floating point math errors here
+ case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
+ default: throw new Error('Unknown unit ' + units);
+ }
+ }
+}
+
+// TODO: Use this.as('ms')?
+function valueOf$1 () {
+ if (!this.isValid()) {
+ return NaN;
+ }
+ return (
+ this._milliseconds +
+ this._days * 864e5 +
+ (this._months % 12) * 2592e6 +
+ toInt(this._months / 12) * 31536e6
+ );
+}
+
+function makeAs (alias) {
+ return function () {
+ return this.as(alias);
+ };
+}
+
+var asMilliseconds = makeAs('ms');
+var asSeconds = makeAs('s');
+var asMinutes = makeAs('m');
+var asHours = makeAs('h');
+var asDays = makeAs('d');
+var asWeeks = makeAs('w');
+var asMonths = makeAs('M');
+var asYears = makeAs('y');
+
+function get$2 (units) {
+ units = normalizeUnits(units);
+ return this.isValid() ? this[units + 's']() : NaN;
+}
+
+function makeGetter(name) {
+ return function () {
+ return this.isValid() ? this._data[name] : NaN;
+ };
+}
+
+var milliseconds = makeGetter('milliseconds');
+var seconds = makeGetter('seconds');
+var minutes = makeGetter('minutes');
+var hours = makeGetter('hours');
+var days = makeGetter('days');
+var months = makeGetter('months');
+var years = makeGetter('years');
+
+function weeks () {
+ return absFloor(this.days() / 7);
+}
+
+var round = Math.round;
+var thresholds = {
+ ss: 44, // a few seconds to seconds
+ s : 45, // seconds to minute
+ m : 45, // minutes to hour
+ h : 22, // hours to day
+ d : 26, // days to month
+ M : 11 // months to year
+};
+
+// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
+function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
+ return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
+}
+
+function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
+ var duration = createDuration(posNegDuration).abs();
+ var seconds = round(duration.as('s'));
+ var minutes = round(duration.as('m'));
+ var hours = round(duration.as('h'));
+ var days = round(duration.as('d'));
+ var months = round(duration.as('M'));
+ var years = round(duration.as('y'));
+
+ var a = seconds <= thresholds.ss && ['s', seconds] ||
+ seconds < thresholds.s && ['ss', seconds] ||
+ minutes <= 1 && ['m'] ||
+ minutes < thresholds.m && ['mm', minutes] ||
+ hours <= 1 && ['h'] ||
+ hours < thresholds.h && ['hh', hours] ||
+ days <= 1 && ['d'] ||
+ days < thresholds.d && ['dd', days] ||
+ months <= 1 && ['M'] ||
+ months < thresholds.M && ['MM', months] ||
+ years <= 1 && ['y'] || ['yy', years];
+
+ a[2] = withoutSuffix;
+ a[3] = +posNegDuration > 0;
+ a[4] = locale;
+ return substituteTimeAgo.apply(null, a);
+}
+
+// This function allows you to set the rounding function for relative time strings
+function getSetRelativeTimeRounding (roundingFunction) {
+ if (roundingFunction === undefined) {
+ return round;
+ }
+ if (typeof(roundingFunction) === 'function') {
+ round = roundingFunction;
+ return true;
+ }
+ return false;
+}
+
+// This function allows you to set a threshold for relative time strings
+function getSetRelativeTimeThreshold (threshold, limit) {
+ if (thresholds[threshold] === undefined) {
+ return false;
+ }
+ if (limit === undefined) {
+ return thresholds[threshold];
+ }
+ thresholds[threshold] = limit;
+ if (threshold === 's') {
+ thresholds.ss = limit - 1;
+ }
+ return true;
+}
+
+function humanize (withSuffix) {
+ if (!this.isValid()) {
+ return this.localeData().invalidDate();
+ }
+
+ var locale = this.localeData();
+ var output = relativeTime$1(this, !withSuffix, locale);
+
+ if (withSuffix) {
+ output = locale.pastFuture(+this, output);
+ }
+
+ return locale.postformat(output);
+}
+
+var abs$1 = Math.abs;
+
+function toISOString$1() {
+ // for ISO strings we do not use the normal bubbling rules:
+ // * milliseconds bubble up until they become hours
+ // * days do not bubble at all
+ // * months bubble up until they become years
+ // This is because there is no context-free conversion between hours and days
+ // (think of clock changes)
+ // and also not between days and months (28-31 days per month)
+ if (!this.isValid()) {
+ return this.localeData().invalidDate();
+ }
+
+ var seconds = abs$1(this._milliseconds) / 1000;
+ var days = abs$1(this._days);
+ var months = abs$1(this._months);
+ var minutes, hours, years;
+
+ // 3600 seconds -> 60 minutes -> 1 hour
+ minutes = absFloor(seconds / 60);
+ hours = absFloor(minutes / 60);
+ seconds %= 60;
+ minutes %= 60;
+
+ // 12 months -> 1 year
+ years = absFloor(months / 12);
+ months %= 12;
+
+
+ // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
+ var Y = years;
+ var M = months;
+ var D = days;
+ var h = hours;
+ var m = minutes;
+ var s = seconds;
+ var total = this.asSeconds();
+
+ if (!total) {
+ // this is the same as C#'s (Noda) and python (isodate)...
+ // but not other JS (goog.date)
+ return 'P0D';
+ }
+
+ return (total < 0 ? '-' : '') +
+ 'P' +
+ (Y ? Y + 'Y' : '') +
+ (M ? M + 'M' : '') +
+ (D ? D + 'D' : '') +
+ ((h || m || s) ? 'T' : '') +
+ (h ? h + 'H' : '') +
+ (m ? m + 'M' : '') +
+ (s ? s + 'S' : '');
+}
+
+var proto$2 = Duration.prototype;
+
+proto$2.isValid = isValid$1;
+proto$2.abs = abs;
+proto$2.add = add$1;
+proto$2.subtract = subtract$1;
+proto$2.as = as;
+proto$2.asMilliseconds = asMilliseconds;
+proto$2.asSeconds = asSeconds;
+proto$2.asMinutes = asMinutes;
+proto$2.asHours = asHours;
+proto$2.asDays = asDays;
+proto$2.asWeeks = asWeeks;
+proto$2.asMonths = asMonths;
+proto$2.asYears = asYears;
+proto$2.valueOf = valueOf$1;
+proto$2._bubble = bubble;
+proto$2.get = get$2;
+proto$2.milliseconds = milliseconds;
+proto$2.seconds = seconds;
+proto$2.minutes = minutes;
+proto$2.hours = hours;
+proto$2.days = days;
+proto$2.weeks = weeks;
+proto$2.months = months;
+proto$2.years = years;
+proto$2.humanize = humanize;
+proto$2.toISOString = toISOString$1;
+proto$2.toString = toISOString$1;
+proto$2.toJSON = toISOString$1;
+proto$2.locale = locale;
+proto$2.localeData = localeData;
+
+// Deprecations
+proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
+proto$2.lang = lang;
+
+// Side effect imports
+
+// FORMATTING
+
+addFormatToken('X', 0, 0, 'unix');
+addFormatToken('x', 0, 0, 'valueOf');
+
+// PARSING
+
+addRegexToken('x', matchSigned);
+addRegexToken('X', matchTimestamp);
+addParseToken('X', function (input, array, config) {
+ config._d = new Date(parseFloat(input, 10) * 1000);
+});
+addParseToken('x', function (input, array, config) {
+ config._d = new Date(toInt(input));
+});
+
+// Side effect imports
+
+
+hooks.version = '2.18.1';
+
+setHookCallback(createLocal);
+
+hooks.fn = proto;
+hooks.min = min;
+hooks.max = max;
+hooks.now = now;
+hooks.utc = createUTC;
+hooks.unix = createUnix;
+hooks.months = listMonths;
+hooks.isDate = isDate;
+hooks.locale = getSetGlobalLocale;
+hooks.invalid = createInvalid;
+hooks.duration = createDuration;
+hooks.isMoment = isMoment;
+hooks.weekdays = listWeekdays;
+hooks.parseZone = createInZone;
+hooks.localeData = getLocale;
+hooks.isDuration = isDuration;
+hooks.monthsShort = listMonthsShort;
+hooks.weekdaysMin = listWeekdaysMin;
+hooks.defineLocale = defineLocale;
+hooks.updateLocale = updateLocale;
+hooks.locales = listLocales;
+hooks.weekdaysShort = listWeekdaysShort;
+hooks.normalizeUnits = normalizeUnits;
+hooks.relativeTimeRounding = getSetRelativeTimeRounding;
+hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
+hooks.calendarFormat = getCalendarFormat;
+hooks.prototype = proto;
+
+return hooks;
+
+})));
+
+},{}],7:[function(require,module,exports){
+/**
+ * @namespace Chart
+ */
+var Chart = require(29)();
+
+Chart.helpers = require(45);
+
+// @todo dispatch these helpers into appropriated helpers/helpers.* file and write unit tests!
+require(27)(Chart);
+
+Chart.defaults = require(25);
+Chart.Element = require(26);
+Chart.elements = require(40);
+Chart.Interaction = require(28);
+Chart.platform = require(48);
+
+require(31)(Chart);
+require(22)(Chart);
+require(23)(Chart);
+require(24)(Chart);
+require(30)(Chart);
+require(33)(Chart);
+require(32)(Chart);
+require(35)(Chart);
+
+require(54)(Chart);
+require(52)(Chart);
+require(53)(Chart);
+require(55)(Chart);
+require(56)(Chart);
+require(57)(Chart);
+
+// Controllers must be loaded after elements
+// See Chart.core.datasetController.dataElementType
+require(15)(Chart);
+require(16)(Chart);
+require(17)(Chart);
+require(18)(Chart);
+require(19)(Chart);
+require(20)(Chart);
+require(21)(Chart);
+
+require(8)(Chart);
+require(9)(Chart);
+require(10)(Chart);
+require(11)(Chart);
+require(12)(Chart);
+require(13)(Chart);
+require(14)(Chart);
+
+// Loading built-it plugins
+var plugins = [];
+
+plugins.push(
+ require(49)(Chart),
+ require(50)(Chart),
+ require(51)(Chart)
+);
+
+Chart.plugins.register(plugins);
+
+Chart.platform.initialize();
+
+module.exports = Chart;
+if (typeof window !== 'undefined') {
+ window.Chart = Chart;
+}
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.canvas instead.
+ * @namespace Chart.canvasHelpers
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+Chart.canvasHelpers = Chart.helpers.canvas;
+
+},{"10":10,"11":11,"12":12,"13":13,"14":14,"15":15,"16":16,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"26":26,"27":27,"28":28,"29":29,"30":30,"31":31,"32":32,"33":33,"35":35,"40":40,"45":45,"48":48,"49":49,"50":50,"51":51,"52":52,"53":53,"54":54,"55":55,"56":56,"57":57,"8":8,"9":9}],8:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Bar = function(context, config) {
+ config.type = 'bar';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],9:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Bubble = function(context, config) {
+ config.type = 'bubble';
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],10:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Doughnut = function(context, config) {
+ config.type = 'doughnut';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],11:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Line = function(context, config) {
+ config.type = 'line';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],12:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.PolarArea = function(context, config) {
+ config.type = 'polarArea';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],13:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Radar = function(context, config) {
+ config.type = 'radar';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],14:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+ Chart.Scatter = function(context, config) {
+ config.type = 'scatter';
+ return new Chart(context, config);
+ };
+};
+
+},{}],15:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('bar', {
+ hover: {
+ mode: 'label'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'category',
+
+ // Specific to Bar Controller
+ categoryPercentage: 0.8,
+ barPercentage: 0.9,
+
+ // offset settings
+ offset: true,
+
+ // grid line settings
+ gridLines: {
+ offsetGridLines: true
+ }
+ }],
+
+ yAxes: [{
+ type: 'linear'
+ }]
+ }
+});
+
+defaults._set('horizontalBar', {
+ hover: {
+ mode: 'index',
+ axis: 'y'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'linear',
+ position: 'bottom'
+ }],
+
+ yAxes: [{
+ position: 'left',
+ type: 'category',
+
+ // Specific to Horizontal Bar Controller
+ categoryPercentage: 0.8,
+ barPercentage: 0.9,
+
+ // offset settings
+ offset: true,
+
+ // grid line settings
+ gridLines: {
+ offsetGridLines: true
+ }
+ }]
+ },
+
+ elements: {
+ rectangle: {
+ borderSkipped: 'left'
+ }
+ },
+
+ tooltips: {
+ callbacks: {
+ title: function(item, data) {
+ // Pick first xLabel for now
+ var title = '';
+
+ if (item.length > 0) {
+ if (item[0].yLabel) {
+ title = item[0].yLabel;
+ } else if (data.labels.length > 0 && item[0].index < data.labels.length) {
+ title = data.labels[item[0].index];
+ }
+ }
+
+ return title;
+ },
+
+ label: function(item, data) {
+ var datasetLabel = data.datasets[item.datasetIndex].label || '';
+ return datasetLabel + ': ' + item.xLabel;
+ }
+ },
+ mode: 'index',
+ axis: 'y'
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.bar = Chart.DatasetController.extend({
+
+ dataElementType: elements.Rectangle,
+
+ initialize: function() {
+ var me = this;
+ var meta;
+
+ Chart.DatasetController.prototype.initialize.apply(me, arguments);
+
+ meta = me.getMeta();
+ meta.stack = me.getDataset().stack;
+ meta.bar = true;
+ },
+
+ update: function(reset) {
+ var me = this;
+ var rects = me.getMeta().data;
+ var i, ilen;
+
+ me._ruler = me.getRuler();
+
+ for (i = 0, ilen = rects.length; i < ilen; ++i) {
+ me.updateElement(rects[i], i, reset);
+ }
+ },
+
+ updateElement: function(rectangle, index, reset) {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var dataset = me.getDataset();
+ var custom = rectangle.custom || {};
+ var rectangleOptions = chart.options.elements.rectangle;
+
+ rectangle._xScale = me.getScaleForId(meta.xAxisID);
+ rectangle._yScale = me.getScaleForId(meta.yAxisID);
+ rectangle._datasetIndex = me.index;
+ rectangle._index = index;
+
+ rectangle._model = {
+ datasetLabel: dataset.label,
+ label: chart.data.labels[index],
+ borderSkipped: custom.borderSkipped ? custom.borderSkipped : rectangleOptions.borderSkipped,
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.backgroundColor, index, rectangleOptions.backgroundColor),
+ borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.borderColor, index, rectangleOptions.borderColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.borderWidth, index, rectangleOptions.borderWidth)
+ };
+
+ me.updateElementGeometry(rectangle, index, reset);
+
+ rectangle.pivot();
+ },
+
+ /**
+ * @private
+ */
+ updateElementGeometry: function(rectangle, index, reset) {
+ var me = this;
+ var model = rectangle._model;
+ var vscale = me.getValueScale();
+ var base = vscale.getBasePixel();
+ var horizontal = vscale.isHorizontal();
+ var ruler = me._ruler || me.getRuler();
+ var vpixels = me.calculateBarValuePixels(me.index, index);
+ var ipixels = me.calculateBarIndexPixels(me.index, index, ruler);
+
+ model.horizontal = horizontal;
+ model.base = reset ? base : vpixels.base;
+ model.x = horizontal ? reset ? base : vpixels.head : ipixels.center;
+ model.y = horizontal ? ipixels.center : reset ? base : vpixels.head;
+ model.height = horizontal ? ipixels.size : undefined;
+ model.width = horizontal ? undefined : ipixels.size;
+ },
+
+ /**
+ * @private
+ */
+ getValueScaleId: function() {
+ return this.getMeta().yAxisID;
+ },
+
+ /**
+ * @private
+ */
+ getIndexScaleId: function() {
+ return this.getMeta().xAxisID;
+ },
+
+ /**
+ * @private
+ */
+ getValueScale: function() {
+ return this.getScaleForId(this.getValueScaleId());
+ },
+
+ /**
+ * @private
+ */
+ getIndexScale: function() {
+ return this.getScaleForId(this.getIndexScaleId());
+ },
+
+ /**
+ * Returns the effective number of stacks based on groups and bar visibility.
+ * @private
+ */
+ getStackCount: function(last) {
+ var me = this;
+ var chart = me.chart;
+ var scale = me.getIndexScale();
+ var stacked = scale.options.stacked;
+ var ilen = last === undefined ? chart.data.datasets.length : last + 1;
+ var stacks = [];
+ var i, meta;
+
+ for (i = 0; i < ilen; ++i) {
+ meta = chart.getDatasetMeta(i);
+ if (meta.bar && chart.isDatasetVisible(i) &&
+ (stacked === false ||
+ (stacked === true && stacks.indexOf(meta.stack) === -1) ||
+ (stacked === undefined && (meta.stack === undefined || stacks.indexOf(meta.stack) === -1)))) {
+ stacks.push(meta.stack);
+ }
+ }
+
+ return stacks.length;
+ },
+
+ /**
+ * Returns the stack index for the given dataset based on groups and bar visibility.
+ * @private
+ */
+ getStackIndex: function(datasetIndex) {
+ return this.getStackCount(datasetIndex) - 1;
+ },
+
+ /**
+ * @private
+ */
+ getRuler: function() {
+ var me = this;
+ var scale = me.getIndexScale();
+ var stackCount = me.getStackCount();
+ var datasetIndex = me.index;
+ var pixels = [];
+ var isHorizontal = scale.isHorizontal();
+ var start = isHorizontal ? scale.left : scale.top;
+ var end = start + (isHorizontal ? scale.width : scale.height);
+ var i, ilen;
+
+ for (i = 0, ilen = me.getMeta().data.length; i < ilen; ++i) {
+ pixels.push(scale.getPixelForValue(null, i, datasetIndex));
+ }
+
+ return {
+ pixels: pixels,
+ start: start,
+ end: end,
+ stackCount: stackCount,
+ scale: scale
+ };
+ },
+
+ /**
+ * Note: pixel values are not clamped to the scale area.
+ * @private
+ */
+ calculateBarValuePixels: function(datasetIndex, index) {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var scale = me.getValueScale();
+ var datasets = chart.data.datasets;
+ var value = scale.getRightValue(datasets[datasetIndex].data[index]);
+ var stacked = scale.options.stacked;
+ var stack = meta.stack;
+ var start = 0;
+ var i, imeta, ivalue, base, head, size;
+
+ if (stacked || (stacked === undefined && stack !== undefined)) {
+ for (i = 0; i < datasetIndex; ++i) {
+ imeta = chart.getDatasetMeta(i);
+
+ if (imeta.bar &&
+ imeta.stack === stack &&
+ imeta.controller.getValueScaleId() === scale.id &&
+ chart.isDatasetVisible(i)) {
+
+ ivalue = scale.getRightValue(datasets[i].data[index]);
+ if ((value < 0 && ivalue < 0) || (value >= 0 && ivalue > 0)) {
+ start += ivalue;
+ }
+ }
+ }
+ }
+
+ base = scale.getPixelForValue(start);
+ head = scale.getPixelForValue(start + value);
+ size = (head - base) / 2;
+
+ return {
+ size: size,
+ base: base,
+ head: head,
+ center: head + size / 2
+ };
+ },
+
+ /**
+ * @private
+ */
+ calculateBarIndexPixels: function(datasetIndex, index, ruler) {
+ var me = this;
+ var options = ruler.scale.options;
+ var stackIndex = me.getStackIndex(datasetIndex);
+ var pixels = ruler.pixels;
+ var base = pixels[index];
+ var length = pixels.length;
+ var start = ruler.start;
+ var end = ruler.end;
+ var leftSampleSize, rightSampleSize, leftCategorySize, rightCategorySize, fullBarSize, size;
+
+ if (length === 1) {
+ leftSampleSize = base > start ? base - start : end - base;
+ rightSampleSize = base < end ? end - base : base - start;
+ } else {
+ if (index > 0) {
+ leftSampleSize = (base - pixels[index - 1]) / 2;
+ if (index === length - 1) {
+ rightSampleSize = leftSampleSize;
+ }
+ }
+ if (index < length - 1) {
+ rightSampleSize = (pixels[index + 1] - base) / 2;
+ if (index === 0) {
+ leftSampleSize = rightSampleSize;
+ }
+ }
+ }
+
+ leftCategorySize = leftSampleSize * options.categoryPercentage;
+ rightCategorySize = rightSampleSize * options.categoryPercentage;
+ fullBarSize = (leftCategorySize + rightCategorySize) / ruler.stackCount;
+ size = fullBarSize * options.barPercentage;
+
+ size = Math.min(
+ helpers.valueOrDefault(options.barThickness, size),
+ helpers.valueOrDefault(options.maxBarThickness, Infinity));
+
+ base -= leftCategorySize;
+ base += fullBarSize * stackIndex;
+ base += (fullBarSize - size) / 2;
+
+ return {
+ size: size,
+ base: base,
+ head: base + size,
+ center: base + size / 2
+ };
+ },
+
+ draw: function() {
+ var me = this;
+ var chart = me.chart;
+ var scale = me.getValueScale();
+ var rects = me.getMeta().data;
+ var dataset = me.getDataset();
+ var ilen = rects.length;
+ var i = 0;
+
+ helpers.canvas.clipArea(chart.ctx, chart.chartArea);
+
+ for (; i < ilen; ++i) {
+ if (!isNaN(scale.getRightValue(dataset.data[i]))) {
+ rects[i].draw();
+ }
+ }
+
+ helpers.canvas.unclipArea(chart.ctx);
+ },
+
+ setHoverStyle: function(rectangle) {
+ var dataset = this.chart.data.datasets[rectangle._datasetIndex];
+ var index = rectangle._index;
+ var custom = rectangle.custom || {};
+ var model = rectangle._model;
+
+ model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.valueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.valueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.valueAtIndexOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
+ },
+
+ removeHoverStyle: function(rectangle) {
+ var dataset = this.chart.data.datasets[rectangle._datasetIndex];
+ var index = rectangle._index;
+ var custom = rectangle.custom || {};
+ var model = rectangle._model;
+ var rectangleElementOptions = this.chart.options.elements.rectangle;
+
+ model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.backgroundColor, index, rectangleElementOptions.backgroundColor);
+ model.borderColor = custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.borderColor, index, rectangleElementOptions.borderColor);
+ model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.borderWidth, index, rectangleElementOptions.borderWidth);
+ }
+ });
+
+ Chart.controllers.horizontalBar = Chart.controllers.bar.extend({
+ /**
+ * @private
+ */
+ getValueScaleId: function() {
+ return this.getMeta().xAxisID;
+ },
+
+ /**
+ * @private
+ */
+ getIndexScaleId: function() {
+ return this.getMeta().yAxisID;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],16:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('bubble', {
+ hover: {
+ mode: 'single'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'linear', // bubble should probably use a linear scale by default
+ position: 'bottom',
+ id: 'x-axis-0' // need an ID so datasets can reference the scale
+ }],
+ yAxes: [{
+ type: 'linear',
+ position: 'left',
+ id: 'y-axis-0'
+ }]
+ },
+
+ tooltips: {
+ callbacks: {
+ title: function() {
+ // Title doesn't make sense for scatter since we format the data as a point
+ return '';
+ },
+ label: function(item, data) {
+ var datasetLabel = data.datasets[item.datasetIndex].label || '';
+ var dataPoint = data.datasets[item.datasetIndex].data[item.index];
+ return datasetLabel + ': (' + item.xLabel + ', ' + item.yLabel + ', ' + dataPoint.r + ')';
+ }
+ }
+ }
+});
+
+
+module.exports = function(Chart) {
+
+ Chart.controllers.bubble = Chart.DatasetController.extend({
+ /**
+ * @protected
+ */
+ dataElementType: elements.Point,
+
+ /**
+ * @protected
+ */
+ update: function(reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var points = meta.data;
+
+ // Update Points
+ helpers.each(points, function(point, index) {
+ me.updateElement(point, index, reset);
+ });
+ },
+
+ /**
+ * @protected
+ */
+ updateElement: function(point, index, reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var custom = point.custom || {};
+ var xScale = me.getScaleForId(meta.xAxisID);
+ var yScale = me.getScaleForId(meta.yAxisID);
+ var options = me._resolveElementOptions(point, index);
+ var data = me.getDataset().data[index];
+ var dsIndex = me.index;
+
+ var x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex);
+ var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex);
+
+ point._xScale = xScale;
+ point._yScale = yScale;
+ point._options = options;
+ point._datasetIndex = dsIndex;
+ point._index = index;
+ point._model = {
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderWidth: options.borderWidth,
+ hitRadius: options.hitRadius,
+ pointStyle: options.pointStyle,
+ radius: reset ? 0 : options.radius,
+ skip: custom.skip || isNaN(x) || isNaN(y),
+ x: x,
+ y: y,
+ };
+
+ point.pivot();
+ },
+
+ /**
+ * @protected
+ */
+ setHoverStyle: function(point) {
+ var model = point._model;
+ var options = point._options;
+
+ model.backgroundColor = helpers.valueOrDefault(options.hoverBackgroundColor, helpers.getHoverColor(options.backgroundColor));
+ model.borderColor = helpers.valueOrDefault(options.hoverBorderColor, helpers.getHoverColor(options.borderColor));
+ model.borderWidth = helpers.valueOrDefault(options.hoverBorderWidth, options.borderWidth);
+ model.radius = options.radius + options.hoverRadius;
+ },
+
+ /**
+ * @protected
+ */
+ removeHoverStyle: function(point) {
+ var model = point._model;
+ var options = point._options;
+
+ model.backgroundColor = options.backgroundColor;
+ model.borderColor = options.borderColor;
+ model.borderWidth = options.borderWidth;
+ model.radius = options.radius;
+ },
+
+ /**
+ * @private
+ */
+ _resolveElementOptions: function(point, index) {
+ var me = this;
+ var chart = me.chart;
+ var datasets = chart.data.datasets;
+ var dataset = datasets[me.index];
+ var custom = point.custom || {};
+ var options = chart.options.elements.point;
+ var resolve = helpers.options.resolve;
+ var data = dataset.data[index];
+ var values = {};
+ var i, ilen, key;
+
+ // Scriptable options
+ var context = {
+ chart: chart,
+ dataIndex: index,
+ dataset: dataset,
+ datasetIndex: me.index
+ };
+
+ var keys = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderWidth',
+ 'hoverBackgroundColor',
+ 'hoverBorderColor',
+ 'hoverBorderWidth',
+ 'hoverRadius',
+ 'hitRadius',
+ 'pointStyle'
+ ];
+
+ for (i = 0, ilen = keys.length; i < ilen; ++i) {
+ key = keys[i];
+ values[key] = resolve([
+ custom[key],
+ dataset[key],
+ options[key]
+ ], context, index);
+ }
+
+ // Custom radius resolution
+ values.radius = resolve([
+ custom.radius,
+ data ? data.r : undefined,
+ dataset.radius,
+ options.radius
+ ], context, index);
+
+ return values;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],17:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('doughnut', {
+ animation: {
+ // Boolean - Whether we animate the rotation of the Doughnut
+ animateRotate: true,
+ // Boolean - Whether we animate scaling the Doughnut from the centre
+ animateScale: false
+ },
+ hover: {
+ mode: 'single'
+ },
+ legendCallback: function(chart) {
+ var text = [];
+ text.push('<ul class="' + chart.id + '-legend">');
+
+ var data = chart.data;
+ var datasets = data.datasets;
+ var labels = data.labels;
+
+ if (datasets.length) {
+ for (var i = 0; i < datasets[0].data.length; ++i) {
+ text.push('<li><span style="background-color:' + datasets[0].backgroundColor[i] + '"></span>');
+ if (labels[i]) {
+ text.push(labels[i]);
+ }
+ text.push('</li>');
+ }
+ }
+
+ text.push('</ul>');
+ return text.join('');
+ },
+ legend: {
+ labels: {
+ generateLabels: function(chart) {
+ var data = chart.data;
+ if (data.labels.length && data.datasets.length) {
+ return data.labels.map(function(label, i) {
+ var meta = chart.getDatasetMeta(0);
+ var ds = data.datasets[0];
+ var arc = meta.data[i];
+ var custom = arc && arc.custom || {};
+ var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+ var arcOpts = chart.options.elements.arc;
+ var fill = custom.backgroundColor ? custom.backgroundColor : valueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor);
+ var stroke = custom.borderColor ? custom.borderColor : valueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor);
+ var bw = custom.borderWidth ? custom.borderWidth : valueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth);
+
+ return {
+ text: label,
+ fillStyle: fill,
+ strokeStyle: stroke,
+ lineWidth: bw,
+ hidden: isNaN(ds.data[i]) || meta.data[i].hidden,
+
+ // Extra data used for toggling the correct item
+ index: i
+ };
+ });
+ }
+ return [];
+ }
+ },
+
+ onClick: function(e, legendItem) {
+ var index = legendItem.index;
+ var chart = this.chart;
+ var i, ilen, meta;
+
+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
+ meta = chart.getDatasetMeta(i);
+ // toggle visibility of index if exists
+ if (meta.data[index]) {
+ meta.data[index].hidden = !meta.data[index].hidden;
+ }
+ }
+
+ chart.update();
+ }
+ },
+
+ // The percentage of the chart that we cut out of the middle.
+ cutoutPercentage: 50,
+
+ // The rotation of the chart, where the first data arc begins.
+ rotation: Math.PI * -0.5,
+
+ // The total circumference of the chart.
+ circumference: Math.PI * 2.0,
+
+ // Need to override these to give a nice default
+ tooltips: {
+ callbacks: {
+ title: function() {
+ return '';
+ },
+ label: function(tooltipItem, data) {
+ var dataLabel = data.labels[tooltipItem.index];
+ var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
+
+ if (helpers.isArray(dataLabel)) {
+ // show value on first line of multiline label
+ // need to clone because we are changing the value
+ dataLabel = dataLabel.slice();
+ dataLabel[0] += value;
+ } else {
+ dataLabel += value;
+ }
+
+ return dataLabel;
+ }
+ }
+ }
+});
+
+defaults._set('pie', helpers.clone(defaults.doughnut));
+defaults._set('pie', {
+ cutoutPercentage: 0
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.doughnut = Chart.controllers.pie = Chart.DatasetController.extend({
+
+ dataElementType: elements.Arc,
+
+ linkScales: helpers.noop,
+
+ // Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly
+ getRingIndex: function(datasetIndex) {
+ var ringIndex = 0;
+
+ for (var j = 0; j < datasetIndex; ++j) {
+ if (this.chart.isDatasetVisible(j)) {
+ ++ringIndex;
+ }
+ }
+
+ return ringIndex;
+ },
+
+ update: function(reset) {
+ var me = this;
+ var chart = me.chart;
+ var chartArea = chart.chartArea;
+ var opts = chart.options;
+ var arcOpts = opts.elements.arc;
+ var availableWidth = chartArea.right - chartArea.left - arcOpts.borderWidth;
+ var availableHeight = chartArea.bottom - chartArea.top - arcOpts.borderWidth;
+ var minSize = Math.min(availableWidth, availableHeight);
+ var offset = {x: 0, y: 0};
+ var meta = me.getMeta();
+ var cutoutPercentage = opts.cutoutPercentage;
+ var circumference = opts.circumference;
+
+ // If the chart's circumference isn't a full circle, calculate minSize as a ratio of the width/height of the arc
+ if (circumference < Math.PI * 2.0) {
+ var startAngle = opts.rotation % (Math.PI * 2.0);
+ startAngle += Math.PI * 2.0 * (startAngle >= Math.PI ? -1 : startAngle < -Math.PI ? 1 : 0);
+ var endAngle = startAngle + circumference;
+ var start = {x: Math.cos(startAngle), y: Math.sin(startAngle)};
+ var end = {x: Math.cos(endAngle), y: Math.sin(endAngle)};
+ var contains0 = (startAngle <= 0 && endAngle >= 0) || (startAngle <= Math.PI * 2.0 && Math.PI * 2.0 <= endAngle);
+ var contains90 = (startAngle <= Math.PI * 0.5 && Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 2.5 && Math.PI * 2.5 <= endAngle);
+ var contains180 = (startAngle <= -Math.PI && -Math.PI <= endAngle) || (startAngle <= Math.PI && Math.PI <= endAngle);
+ var contains270 = (startAngle <= -Math.PI * 0.5 && -Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 1.5 && Math.PI * 1.5 <= endAngle);
+ var cutout = cutoutPercentage / 100.0;
+ var min = {x: contains180 ? -1 : Math.min(start.x * (start.x < 0 ? 1 : cutout), end.x * (end.x < 0 ? 1 : cutout)), y: contains270 ? -1 : Math.min(start.y * (start.y < 0 ? 1 : cutout), end.y * (end.y < 0 ? 1 : cutout))};
+ var max = {x: contains0 ? 1 : Math.max(start.x * (start.x > 0 ? 1 : cutout), end.x * (end.x > 0 ? 1 : cutout)), y: contains90 ? 1 : Math.max(start.y * (start.y > 0 ? 1 : cutout), end.y * (end.y > 0 ? 1 : cutout))};
+ var size = {width: (max.x - min.x) * 0.5, height: (max.y - min.y) * 0.5};
+ minSize = Math.min(availableWidth / size.width, availableHeight / size.height);
+ offset = {x: (max.x + min.x) * -0.5, y: (max.y + min.y) * -0.5};
+ }
+
+ chart.borderWidth = me.getMaxBorderWidth(meta.data);
+ chart.outerRadius = Math.max((minSize - chart.borderWidth) / 2, 0);
+ chart.innerRadius = Math.max(cutoutPercentage ? (chart.outerRadius / 100) * (cutoutPercentage) : 0, 0);
+ chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
+ chart.offsetX = offset.x * chart.outerRadius;
+ chart.offsetY = offset.y * chart.outerRadius;
+
+ meta.total = me.calculateTotal();
+
+ me.outerRadius = chart.outerRadius - (chart.radiusLength * me.getRingIndex(me.index));
+ me.innerRadius = Math.max(me.outerRadius - chart.radiusLength, 0);
+
+ helpers.each(meta.data, function(arc, index) {
+ me.updateElement(arc, index, reset);
+ });
+ },
+
+ updateElement: function(arc, index, reset) {
+ var me = this;
+ var chart = me.chart;
+ var chartArea = chart.chartArea;
+ var opts = chart.options;
+ var animationOpts = opts.animation;
+ var centerX = (chartArea.left + chartArea.right) / 2;
+ var centerY = (chartArea.top + chartArea.bottom) / 2;
+ var startAngle = opts.rotation; // non reset case handled later
+ var endAngle = opts.rotation; // non reset case handled later
+ var dataset = me.getDataset();
+ var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumference / (2.0 * Math.PI));
+ var innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius;
+ var outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius;
+ var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+
+ helpers.extend(arc, {
+ // Utility
+ _datasetIndex: me.index,
+ _index: index,
+
+ // Desired view properties
+ _model: {
+ x: centerX + chart.offsetX,
+ y: centerY + chart.offsetY,
+ startAngle: startAngle,
+ endAngle: endAngle,
+ circumference: circumference,
+ outerRadius: outerRadius,
+ innerRadius: innerRadius,
+ label: valueAtIndexOrDefault(dataset.label, index, chart.data.labels[index])
+ }
+ });
+
+ var model = arc._model;
+ // Resets the visual styles
+ this.removeHoverStyle(arc);
+
+ // Set correct angles if not resetting
+ if (!reset || !animationOpts.animateRotate) {
+ if (index === 0) {
+ model.startAngle = opts.rotation;
+ } else {
+ model.startAngle = me.getMeta().data[index - 1]._model.endAngle;
+ }
+
+ model.endAngle = model.startAngle + model.circumference;
+ }
+
+ arc.pivot();
+ },
+
+ removeHoverStyle: function(arc) {
+ Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc);
+ },
+
+ calculateTotal: function() {
+ var dataset = this.getDataset();
+ var meta = this.getMeta();
+ var total = 0;
+ var value;
+
+ helpers.each(meta.data, function(element, index) {
+ value = dataset.data[index];
+ if (!isNaN(value) && !element.hidden) {
+ total += Math.abs(value);
+ }
+ });
+
+ /* if (total === 0) {
+ total = NaN;
+ }*/
+
+ return total;
+ },
+
+ calculateCircumference: function(value) {
+ var total = this.getMeta().total;
+ if (total > 0 && !isNaN(value)) {
+ return (Math.PI * 2.0) * (value / total);
+ }
+ return 0;
+ },
+
+ // gets the max border or hover width to properly scale pie charts
+ getMaxBorderWidth: function(arcs) {
+ var max = 0;
+ var index = this.index;
+ var length = arcs.length;
+ var borderWidth;
+ var hoverWidth;
+
+ for (var i = 0; i < length; i++) {
+ borderWidth = arcs[i]._model ? arcs[i]._model.borderWidth : 0;
+ hoverWidth = arcs[i]._chart ? arcs[i]._chart.config.data.datasets[index].hoverBorderWidth : 0;
+
+ max = borderWidth > max ? borderWidth : max;
+ max = hoverWidth > max ? hoverWidth : max;
+ }
+ return max;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],18:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('line', {
+ showLines: true,
+ spanGaps: false,
+
+ hover: {
+ mode: 'label'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'category',
+ id: 'x-axis-0'
+ }],
+ yAxes: [{
+ type: 'linear',
+ id: 'y-axis-0'
+ }]
+ }
+});
+
+module.exports = function(Chart) {
+
+ function lineEnabled(dataset, options) {
+ return helpers.valueOrDefault(dataset.showLine, options.showLines);
+ }
+
+ Chart.controllers.line = Chart.DatasetController.extend({
+
+ datasetElementType: elements.Line,
+
+ dataElementType: elements.Point,
+
+ update: function(reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var line = meta.dataset;
+ var points = meta.data || [];
+ var options = me.chart.options;
+ var lineElementOptions = options.elements.line;
+ var scale = me.getScaleForId(meta.yAxisID);
+ var i, ilen, custom;
+ var dataset = me.getDataset();
+ var showLine = lineEnabled(dataset, options);
+
+ // Update Line
+ if (showLine) {
+ custom = line.custom || {};
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
+ dataset.lineTension = dataset.tension;
+ }
+
+ // Utility
+ line._scale = scale;
+ line._datasetIndex = me.index;
+ // Data
+ line._children = points;
+ // Model
+ line._model = {
+ // Appearance
+ // The default behavior of lines is to break at null values, according
+ // to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
+ // This option gives lines the ability to span gaps
+ spanGaps: dataset.spanGaps ? dataset.spanGaps : options.spanGaps,
+ tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
+ borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor),
+ borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle),
+ borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash),
+ borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset),
+ borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle),
+ fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill),
+ steppedLine: custom.steppedLine ? custom.steppedLine : helpers.valueOrDefault(dataset.steppedLine, lineElementOptions.stepped),
+ cubicInterpolationMode: custom.cubicInterpolationMode ? custom.cubicInterpolationMode : helpers.valueOrDefault(dataset.cubicInterpolationMode, lineElementOptions.cubicInterpolationMode),
+ };
+
+ line.pivot();
+ }
+
+ // Update Points
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ me.updateElement(points[i], i, reset);
+ }
+
+ if (showLine && line._model.tension !== 0) {
+ me.updateBezierControlPoints();
+ }
+
+ // Now pivot the point for animation
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ points[i].pivot();
+ }
+ },
+
+ getPointBackgroundColor: function(point, index) {
+ var backgroundColor = this.chart.options.elements.point.backgroundColor;
+ var dataset = this.getDataset();
+ var custom = point.custom || {};
+
+ if (custom.backgroundColor) {
+ backgroundColor = custom.backgroundColor;
+ } else if (dataset.pointBackgroundColor) {
+ backgroundColor = helpers.valueAtIndexOrDefault(dataset.pointBackgroundColor, index, backgroundColor);
+ } else if (dataset.backgroundColor) {
+ backgroundColor = dataset.backgroundColor;
+ }
+
+ return backgroundColor;
+ },
+
+ getPointBorderColor: function(point, index) {
+ var borderColor = this.chart.options.elements.point.borderColor;
+ var dataset = this.getDataset();
+ var custom = point.custom || {};
+
+ if (custom.borderColor) {
+ borderColor = custom.borderColor;
+ } else if (dataset.pointBorderColor) {
+ borderColor = helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, borderColor);
+ } else if (dataset.borderColor) {
+ borderColor = dataset.borderColor;
+ }
+
+ return borderColor;
+ },
+
+ getPointBorderWidth: function(point, index) {
+ var borderWidth = this.chart.options.elements.point.borderWidth;
+ var dataset = this.getDataset();
+ var custom = point.custom || {};
+
+ if (!isNaN(custom.borderWidth)) {
+ borderWidth = custom.borderWidth;
+ } else if (!isNaN(dataset.pointBorderWidth) || helpers.isArray(dataset.pointBorderWidth)) {
+ borderWidth = helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, borderWidth);
+ } else if (!isNaN(dataset.borderWidth)) {
+ borderWidth = dataset.borderWidth;
+ }
+
+ return borderWidth;
+ },
+
+ updateElement: function(point, index, reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var custom = point.custom || {};
+ var dataset = me.getDataset();
+ var datasetIndex = me.index;
+ var value = dataset.data[index];
+ var yScale = me.getScaleForId(meta.yAxisID);
+ var xScale = me.getScaleForId(meta.xAxisID);
+ var pointOptions = me.chart.options.elements.point;
+ var x, y;
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
+ dataset.pointRadius = dataset.radius;
+ }
+ if ((dataset.hitRadius !== undefined) && (dataset.pointHitRadius === undefined)) {
+ dataset.pointHitRadius = dataset.hitRadius;
+ }
+
+ x = xScale.getPixelForValue(typeof value === 'object' ? value : NaN, index, datasetIndex);
+ y = reset ? yScale.getBasePixel() : me.calculatePointY(value, index, datasetIndex);
+
+ // Utility
+ point._xScale = xScale;
+ point._yScale = yScale;
+ point._datasetIndex = datasetIndex;
+ point._index = index;
+
+ // Desired view properties
+ point._model = {
+ x: x,
+ y: y,
+ skip: custom.skip || isNaN(x) || isNaN(y),
+ // Appearance
+ radius: custom.radius || helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointOptions.radius),
+ pointStyle: custom.pointStyle || helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointOptions.pointStyle),
+ backgroundColor: me.getPointBackgroundColor(point, index),
+ borderColor: me.getPointBorderColor(point, index),
+ borderWidth: me.getPointBorderWidth(point, index),
+ tension: meta.dataset._model ? meta.dataset._model.tension : 0,
+ steppedLine: meta.dataset._model ? meta.dataset._model.steppedLine : false,
+ // Tooltip
+ hitRadius: custom.hitRadius || helpers.valueAtIndexOrDefault(dataset.pointHitRadius, index, pointOptions.hitRadius)
+ };
+ },
+
+ calculatePointY: function(value, index, datasetIndex) {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var yScale = me.getScaleForId(meta.yAxisID);
+ var sumPos = 0;
+ var sumNeg = 0;
+ var i, ds, dsMeta;
+
+ if (yScale.options.stacked) {
+ for (i = 0; i < datasetIndex; i++) {
+ ds = chart.data.datasets[i];
+ dsMeta = chart.getDatasetMeta(i);
+ if (dsMeta.type === 'line' && dsMeta.yAxisID === yScale.id && chart.isDatasetVisible(i)) {
+ var stackedRightValue = Number(yScale.getRightValue(ds.data[index]));
+ if (stackedRightValue < 0) {
+ sumNeg += stackedRightValue || 0;
+ } else {
+ sumPos += stackedRightValue || 0;
+ }
+ }
+ }
+
+ var rightValue = Number(yScale.getRightValue(value));
+ if (rightValue < 0) {
+ return yScale.getPixelForValue(sumNeg + rightValue);
+ }
+ return yScale.getPixelForValue(sumPos + rightValue);
+ }
+
+ return yScale.getPixelForValue(value);
+ },
+
+ updateBezierControlPoints: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var area = me.chart.chartArea;
+ var points = (meta.data || []);
+ var i, ilen, point, model, controlPoints;
+
+ // Only consider points that are drawn in case the spanGaps option is used
+ if (meta.dataset._model.spanGaps) {
+ points = points.filter(function(pt) {
+ return !pt._model.skip;
+ });
+ }
+
+ function capControlPoint(pt, min, max) {
+ return Math.max(Math.min(pt, max), min);
+ }
+
+ if (meta.dataset._model.cubicInterpolationMode === 'monotone') {
+ helpers.splineCurveMonotone(points);
+ } else {
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ point = points[i];
+ model = point._model;
+ controlPoints = helpers.splineCurve(
+ helpers.previousItem(points, i)._model,
+ model,
+ helpers.nextItem(points, i)._model,
+ meta.dataset._model.tension
+ );
+ model.controlPointPreviousX = controlPoints.previous.x;
+ model.controlPointPreviousY = controlPoints.previous.y;
+ model.controlPointNextX = controlPoints.next.x;
+ model.controlPointNextY = controlPoints.next.y;
+ }
+ }
+
+ if (me.chart.options.elements.line.capBezierPoints) {
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ model = points[i]._model;
+ model.controlPointPreviousX = capControlPoint(model.controlPointPreviousX, area.left, area.right);
+ model.controlPointPreviousY = capControlPoint(model.controlPointPreviousY, area.top, area.bottom);
+ model.controlPointNextX = capControlPoint(model.controlPointNextX, area.left, area.right);
+ model.controlPointNextY = capControlPoint(model.controlPointNextY, area.top, area.bottom);
+ }
+ }
+ },
+
+ draw: function() {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var points = meta.data || [];
+ var area = chart.chartArea;
+ var ilen = points.length;
+ var i = 0;
+
+ helpers.canvas.clipArea(chart.ctx, area);
+
+ if (lineEnabled(me.getDataset(), chart.options)) {
+ meta.dataset.draw();
+ }
+
+ helpers.canvas.unclipArea(chart.ctx);
+
+ // Draw the points
+ for (; i < ilen; ++i) {
+ points[i].draw(area);
+ }
+ },
+
+ setHoverStyle: function(point) {
+ // Point
+ var dataset = this.chart.data.datasets[point._datasetIndex];
+ var index = point._index;
+ var custom = point.custom || {};
+ var model = point._model;
+
+ model.radius = custom.hoverRadius || helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
+ model.backgroundColor = custom.hoverBackgroundColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
+ },
+
+ removeHoverStyle: function(point) {
+ var me = this;
+ var dataset = me.chart.data.datasets[point._datasetIndex];
+ var index = point._index;
+ var custom = point.custom || {};
+ var model = point._model;
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
+ dataset.pointRadius = dataset.radius;
+ }
+
+ model.radius = custom.radius || helpers.valueAtIndexOrDefault(dataset.pointRadius, index, me.chart.options.elements.point.radius);
+ model.backgroundColor = me.getPointBackgroundColor(point, index);
+ model.borderColor = me.getPointBorderColor(point, index);
+ model.borderWidth = me.getPointBorderWidth(point, index);
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],19:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('polarArea', {
+ scale: {
+ type: 'radialLinear',
+ angleLines: {
+ display: false
+ },
+ gridLines: {
+ circular: true
+ },
+ pointLabels: {
+ display: false
+ },
+ ticks: {
+ beginAtZero: true
+ }
+ },
+
+ // Boolean - Whether to animate the rotation of the chart
+ animation: {
+ animateRotate: true,
+ animateScale: true
+ },
+
+ startAngle: -0.5 * Math.PI,
+ legendCallback: function(chart) {
+ var text = [];
+ text.push('<ul class="' + chart.id + '-legend">');
+
+ var data = chart.data;
+ var datasets = data.datasets;
+ var labels = data.labels;
+
+ if (datasets.length) {
+ for (var i = 0; i < datasets[0].data.length; ++i) {
+ text.push('<li><span style="background-color:' + datasets[0].backgroundColor[i] + '"></span>');
+ if (labels[i]) {
+ text.push(labels[i]);
+ }
+ text.push('</li>');
+ }
+ }
+
+ text.push('</ul>');
+ return text.join('');
+ },
+ legend: {
+ labels: {
+ generateLabels: function(chart) {
+ var data = chart.data;
+ if (data.labels.length && data.datasets.length) {
+ return data.labels.map(function(label, i) {
+ var meta = chart.getDatasetMeta(0);
+ var ds = data.datasets[0];
+ var arc = meta.data[i];
+ var custom = arc.custom || {};
+ var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+ var arcOpts = chart.options.elements.arc;
+ var fill = custom.backgroundColor ? custom.backgroundColor : valueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor);
+ var stroke = custom.borderColor ? custom.borderColor : valueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor);
+ var bw = custom.borderWidth ? custom.borderWidth : valueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth);
+
+ return {
+ text: label,
+ fillStyle: fill,
+ strokeStyle: stroke,
+ lineWidth: bw,
+ hidden: isNaN(ds.data[i]) || meta.data[i].hidden,
+
+ // Extra data used for toggling the correct item
+ index: i
+ };
+ });
+ }
+ return [];
+ }
+ },
+
+ onClick: function(e, legendItem) {
+ var index = legendItem.index;
+ var chart = this.chart;
+ var i, ilen, meta;
+
+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
+ meta = chart.getDatasetMeta(i);
+ meta.data[index].hidden = !meta.data[index].hidden;
+ }
+
+ chart.update();
+ }
+ },
+
+ // Need to override these to give a nice default
+ tooltips: {
+ callbacks: {
+ title: function() {
+ return '';
+ },
+ label: function(item, data) {
+ return data.labels[item.index] + ': ' + item.yLabel;
+ }
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.polarArea = Chart.DatasetController.extend({
+
+ dataElementType: elements.Arc,
+
+ linkScales: helpers.noop,
+
+ update: function(reset) {
+ var me = this;
+ var chart = me.chart;
+ var chartArea = chart.chartArea;
+ var meta = me.getMeta();
+ var opts = chart.options;
+ var arcOpts = opts.elements.arc;
+ var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);
+ chart.outerRadius = Math.max((minSize - arcOpts.borderWidth / 2) / 2, 0);
+ chart.innerRadius = Math.max(opts.cutoutPercentage ? (chart.outerRadius / 100) * (opts.cutoutPercentage) : 1, 0);
+ chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
+
+ me.outerRadius = chart.outerRadius - (chart.radiusLength * me.index);
+ me.innerRadius = me.outerRadius - chart.radiusLength;
+
+ meta.count = me.countVisibleElements();
+
+ helpers.each(meta.data, function(arc, index) {
+ me.updateElement(arc, index, reset);
+ });
+ },
+
+ updateElement: function(arc, index, reset) {
+ var me = this;
+ var chart = me.chart;
+ var dataset = me.getDataset();
+ var opts = chart.options;
+ var animationOpts = opts.animation;
+ var scale = chart.scale;
+ var labels = chart.data.labels;
+
+ var circumference = me.calculateCircumference(dataset.data[index]);
+ var centerX = scale.xCenter;
+ var centerY = scale.yCenter;
+
+ // If there is NaN data before us, we need to calculate the starting angle correctly.
+ // We could be way more efficient here, but its unlikely that the polar area chart will have a lot of data
+ var visibleCount = 0;
+ var meta = me.getMeta();
+ for (var i = 0; i < index; ++i) {
+ if (!isNaN(dataset.data[i]) && !meta.data[i].hidden) {
+ ++visibleCount;
+ }
+ }
+
+ // var negHalfPI = -0.5 * Math.PI;
+ var datasetStartAngle = opts.startAngle;
+ var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
+ var startAngle = datasetStartAngle + (circumference * visibleCount);
+ var endAngle = startAngle + (arc.hidden ? 0 : circumference);
+
+ var resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
+
+ helpers.extend(arc, {
+ // Utility
+ _datasetIndex: me.index,
+ _index: index,
+ _scale: scale,
+
+ // Desired view properties
+ _model: {
+ x: centerX,
+ y: centerY,
+ innerRadius: 0,
+ outerRadius: reset ? resetRadius : distance,
+ startAngle: reset && animationOpts.animateRotate ? datasetStartAngle : startAngle,
+ endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : endAngle,
+ label: helpers.valueAtIndexOrDefault(labels, index, labels[index])
+ }
+ });
+
+ // Apply border and fill style
+ me.removeHoverStyle(arc);
+
+ arc.pivot();
+ },
+
+ removeHoverStyle: function(arc) {
+ Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc);
+ },
+
+ countVisibleElements: function() {
+ var dataset = this.getDataset();
+ var meta = this.getMeta();
+ var count = 0;
+
+ helpers.each(meta.data, function(element, index) {
+ if (!isNaN(dataset.data[index]) && !element.hidden) {
+ count++;
+ }
+ });
+
+ return count;
+ },
+
+ calculateCircumference: function(value) {
+ var count = this.getMeta().count;
+ if (count > 0 && !isNaN(value)) {
+ return (2 * Math.PI) / count;
+ }
+ return 0;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],20:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('radar', {
+ scale: {
+ type: 'radialLinear'
+ },
+ elements: {
+ line: {
+ tension: 0 // no bezier in radar
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.radar = Chart.DatasetController.extend({
+
+ datasetElementType: elements.Line,
+
+ dataElementType: elements.Point,
+
+ linkScales: helpers.noop,
+
+ update: function(reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var line = meta.dataset;
+ var points = meta.data;
+ var custom = line.custom || {};
+ var dataset = me.getDataset();
+ var lineElementOptions = me.chart.options.elements.line;
+ var scale = me.chart.scale;
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
+ dataset.lineTension = dataset.tension;
+ }
+
+ helpers.extend(meta.dataset, {
+ // Utility
+ _datasetIndex: me.index,
+ _scale: scale,
+ // Data
+ _children: points,
+ _loop: true,
+ // Model
+ _model: {
+ // Appearance
+ tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
+ borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor),
+ fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill),
+ borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle),
+ borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash),
+ borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset),
+ borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle),
+ }
+ });
+
+ meta.dataset.pivot();
+
+ // Update Points
+ helpers.each(points, function(point, index) {
+ me.updateElement(point, index, reset);
+ }, me);
+
+ // Update bezier control points
+ me.updateBezierControlPoints();
+ },
+ updateElement: function(point, index, reset) {
+ var me = this;
+ var custom = point.custom || {};
+ var dataset = me.getDataset();
+ var scale = me.chart.scale;
+ var pointElementOptions = me.chart.options.elements.point;
+ var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]);
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
+ dataset.pointRadius = dataset.radius;
+ }
+ if ((dataset.hitRadius !== undefined) && (dataset.pointHitRadius === undefined)) {
+ dataset.pointHitRadius = dataset.hitRadius;
+ }
+
+ helpers.extend(point, {
+ // Utility
+ _datasetIndex: me.index,
+ _index: index,
+ _scale: scale,
+
+ // Desired view properties
+ _model: {
+ x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales
+ y: reset ? scale.yCenter : pointPosition.y,
+
+ // Appearance
+ tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, me.chart.options.elements.line.tension),
+ radius: custom.radius ? custom.radius : helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointElementOptions.radius),
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.pointBackgroundColor, index, pointElementOptions.backgroundColor),
+ borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth),
+ pointStyle: custom.pointStyle ? custom.pointStyle : helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointElementOptions.pointStyle),
+
+ // Tooltip
+ hitRadius: custom.hitRadius ? custom.hitRadius : helpers.valueAtIndexOrDefault(dataset.pointHitRadius, index, pointElementOptions.hitRadius)
+ }
+ });
+
+ point._model.skip = custom.skip ? custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
+ },
+ updateBezierControlPoints: function() {
+ var chartArea = this.chart.chartArea;
+ var meta = this.getMeta();
+
+ helpers.each(meta.data, function(point, index) {
+ var model = point._model;
+ var controlPoints = helpers.splineCurve(
+ helpers.previousItem(meta.data, index, true)._model,
+ model,
+ helpers.nextItem(meta.data, index, true)._model,
+ model.tension
+ );
+
+ // Prevent the bezier going outside of the bounds of the graph
+ model.controlPointPreviousX = Math.max(Math.min(controlPoints.previous.x, chartArea.right), chartArea.left);
+ model.controlPointPreviousY = Math.max(Math.min(controlPoints.previous.y, chartArea.bottom), chartArea.top);
+
+ model.controlPointNextX = Math.max(Math.min(controlPoints.next.x, chartArea.right), chartArea.left);
+ model.controlPointNextY = Math.max(Math.min(controlPoints.next.y, chartArea.bottom), chartArea.top);
+
+ // Now pivot the point for animation
+ point.pivot();
+ });
+ },
+
+ setHoverStyle: function(point) {
+ // Point
+ var dataset = this.chart.data.datasets[point._datasetIndex];
+ var custom = point.custom || {};
+ var index = point._index;
+ var model = point._model;
+
+ model.radius = custom.hoverRadius ? custom.hoverRadius : helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
+ model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
+ },
+
+ removeHoverStyle: function(point) {
+ var dataset = this.chart.data.datasets[point._datasetIndex];
+ var custom = point.custom || {};
+ var index = point._index;
+ var model = point._model;
+ var pointElementOptions = this.chart.options.elements.point;
+
+ model.radius = custom.radius ? custom.radius : helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointElementOptions.radius);
+ model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.pointBackgroundColor, index, pointElementOptions.backgroundColor);
+ model.borderColor = custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor);
+ model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth);
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],21:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+
+defaults._set('scatter', {
+ hover: {
+ mode: 'single'
+ },
+
+ scales: {
+ xAxes: [{
+ id: 'x-axis-1', // need an ID so datasets can reference the scale
+ type: 'linear', // scatter should not use a category axis
+ position: 'bottom'
+ }],
+ yAxes: [{
+ id: 'y-axis-1',
+ type: 'linear',
+ position: 'left'
+ }]
+ },
+
+ showLines: false,
+
+ tooltips: {
+ callbacks: {
+ title: function() {
+ return ''; // doesn't make sense for scatter since data are formatted as a point
+ },
+ label: function(item) {
+ return '(' + item.xLabel + ', ' + item.yLabel + ')';
+ }
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ // Scatter charts use line controllers
+ Chart.controllers.scatter = Chart.controllers.line;
+
+};
+
+},{"25":25}],22:[function(require,module,exports){
+/* global window: false */
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ animation: {
+ duration: 1000,
+ easing: 'easeOutQuart',
+ onProgress: helpers.noop,
+ onComplete: helpers.noop
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.Animation = Element.extend({
+ chart: null, // the animation associated chart instance
+ currentStep: 0, // the current animation step
+ numSteps: 60, // default number of steps
+ easing: '', // the easing to use for this animation
+ render: null, // render function used by the animation service
+
+ onAnimationProgress: null, // user specified callback to fire on each step of the animation
+ onAnimationComplete: null, // user specified callback to fire when the animation finishes
+ });
+
+ Chart.animationService = {
+ frameDuration: 17,
+ animations: [],
+ dropFrames: 0,
+ request: null,
+
+ /**
+ * @param {Chart} chart - The chart to animate.
+ * @param {Chart.Animation} animation - The animation that we will animate.
+ * @param {Number} duration - The animation duration in ms.
+ * @param {Boolean} lazy - if true, the chart is not marked as animating to enable more responsive interactions
+ */
+ addAnimation: function(chart, animation, duration, lazy) {
+ var animations = this.animations;
+ var i, ilen;
+
+ animation.chart = chart;
+
+ if (!lazy) {
+ chart.animating = true;
+ }
+
+ for (i = 0, ilen = animations.length; i < ilen; ++i) {
+ if (animations[i].chart === chart) {
+ animations[i] = animation;
+ return;
+ }
+ }
+
+ animations.push(animation);
+
+ // If there are no animations queued, manually kickstart a digest, for lack of a better word
+ if (animations.length === 1) {
+ this.requestAnimationFrame();
+ }
+ },
+
+ cancelAnimation: function(chart) {
+ var index = helpers.findIndex(this.animations, function(animation) {
+ return animation.chart === chart;
+ });
+
+ if (index !== -1) {
+ this.animations.splice(index, 1);
+ chart.animating = false;
+ }
+ },
+
+ requestAnimationFrame: function() {
+ var me = this;
+ if (me.request === null) {
+ // Skip animation frame requests until the active one is executed.
+ // This can happen when processing mouse events, e.g. 'mousemove'
+ // and 'mouseout' events will trigger multiple renders.
+ me.request = helpers.requestAnimFrame.call(window, function() {
+ me.request = null;
+ me.startDigest();
+ });
+ }
+ },
+
+ /**
+ * @private
+ */
+ startDigest: function() {
+ var me = this;
+ var startTime = Date.now();
+ var framesToDrop = 0;
+
+ if (me.dropFrames > 1) {
+ framesToDrop = Math.floor(me.dropFrames);
+ me.dropFrames = me.dropFrames % 1;
+ }
+
+ me.advance(1 + framesToDrop);
+
+ var endTime = Date.now();
+
+ me.dropFrames += (endTime - startTime) / me.frameDuration;
+
+ // Do we have more stuff to animate?
+ if (me.animations.length > 0) {
+ me.requestAnimationFrame();
+ }
+ },
+
+ /**
+ * @private
+ */
+ advance: function(count) {
+ var animations = this.animations;
+ var animation, chart;
+ var i = 0;
+
+ while (i < animations.length) {
+ animation = animations[i];
+ chart = animation.chart;
+
+ animation.currentStep = (animation.currentStep || 0) + count;
+ animation.currentStep = Math.min(animation.currentStep, animation.numSteps);
+
+ helpers.callback(animation.render, [chart, animation], chart);
+ helpers.callback(animation.onAnimationProgress, [animation], chart);
+
+ if (animation.currentStep >= animation.numSteps) {
+ helpers.callback(animation.onAnimationComplete, [animation], chart);
+ chart.animating = false;
+ animations.splice(i, 1);
+ } else {
+ ++i;
+ }
+ }
+ }
+ };
+
+ /**
+ * Provided for backward compatibility, use Chart.Animation instead
+ * @prop Chart.Animation#animationObject
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ */
+ Object.defineProperty(Chart.Animation.prototype, 'animationObject', {
+ get: function() {
+ return this;
+ }
+ });
+
+ /**
+ * Provided for backward compatibility, use Chart.Animation#chart instead
+ * @prop Chart.Animation#chartInstance
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ */
+ Object.defineProperty(Chart.Animation.prototype, 'chartInstance', {
+ get: function() {
+ return this.chart;
+ },
+ set: function(value) {
+ this.chart = value;
+ }
+ });
+
+};
+
+},{"25":25,"26":26,"45":45}],23:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+var Interaction = require(28);
+var platform = require(48);
+
+module.exports = function(Chart) {
+ var plugins = Chart.plugins;
+
+ // Create a dictionary of chart types, to allow for extension of existing types
+ Chart.types = {};
+
+ // Store a reference to each instance - allowing us to globally resize chart instances on window resize.
+ // Destroy method on the chart will remove the instance of the chart from this reference.
+ Chart.instances = {};
+
+ // Controllers available for dataset visualization eg. bar, line, slice, etc.
+ Chart.controllers = {};
+
+ /**
+ * Initializes the given config with global and chart default values.
+ */
+ function initConfig(config) {
+ config = config || {};
+
+ // Do NOT use configMerge() for the data object because this method merges arrays
+ // and so would change references to labels and datasets, preventing data updates.
+ var data = config.data = config.data || {};
+ data.datasets = data.datasets || [];
+ data.labels = data.labels || [];
+
+ config.options = helpers.configMerge(
+ defaults.global,
+ defaults[config.type],
+ config.options || {});
+
+ return config;
+ }
+
+ /**
+ * Updates the config of the chart
+ * @param chart {Chart} chart to update the options for
+ */
+ function updateConfig(chart) {
+ var newOptions = chart.options;
+
+ // Update Scale(s) with options
+ if (newOptions.scale) {
+ chart.scale.options = newOptions.scale;
+ } else if (newOptions.scales) {
+ newOptions.scales.xAxes.concat(newOptions.scales.yAxes).forEach(function(scaleOptions) {
+ chart.scales[scaleOptions.id].options = scaleOptions;
+ });
+ }
+
+ // Tooltip
+ chart.tooltip._options = newOptions.tooltips;
+ }
+
+ function positionIsHorizontal(position) {
+ return position === 'top' || position === 'bottom';
+ }
+
+ helpers.extend(Chart.prototype, /** @lends Chart */ {
+ /**
+ * @private
+ */
+ construct: function(item, config) {
+ var me = this;
+
+ config = initConfig(config);
+
+ var context = platform.acquireContext(item, config);
+ var canvas = context && context.canvas;
+ var height = canvas && canvas.height;
+ var width = canvas && canvas.width;
+
+ me.id = helpers.uid();
+ me.ctx = context;
+ me.canvas = canvas;
+ me.config = config;
+ me.width = width;
+ me.height = height;
+ me.aspectRatio = height ? width / height : null;
+ me.options = config.options;
+ me._bufferedRender = false;
+
+ /**
+ * Provided for backward compatibility, Chart and Chart.Controller have been merged,
+ * the "instance" still need to be defined since it might be called from plugins.
+ * @prop Chart#chart
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+ me.chart = me;
+ me.controller = me; // chart.chart.controller #inception
+
+ // Add the chart instance to the global namespace
+ Chart.instances[me.id] = me;
+
+ // Define alias to the config data: `chart.data === chart.config.data`
+ Object.defineProperty(me, 'data', {
+ get: function() {
+ return me.config.data;
+ },
+ set: function(value) {
+ me.config.data = value;
+ }
+ });
+
+ if (!context || !canvas) {
+ // The given item is not a compatible context2d element, let's return before finalizing
+ // the chart initialization but after setting basic chart / controller properties that
+ // can help to figure out that the chart is not valid (e.g chart.canvas !== null);
+ // https://github.com/chartjs/Chart.js/issues/2807
+ console.error("Failed to create chart: can't acquire context from the given item");
+ return;
+ }
+
+ me.initialize();
+ me.update();
+ },
+
+ /**
+ * @private
+ */
+ initialize: function() {
+ var me = this;
+
+ // Before init plugin notification
+ plugins.notify(me, 'beforeInit');
+
+ helpers.retinaScale(me, me.options.devicePixelRatio);
+
+ me.bindEvents();
+
+ if (me.options.responsive) {
+ // Initial resize before chart draws (must be silent to preserve initial animations).
+ me.resize(true);
+ }
+
+ // Make sure scales have IDs and are built before we build any controllers.
+ me.ensureScalesHaveIDs();
+ me.buildScales();
+ me.initToolTip();
+
+ // After init plugin notification
+ plugins.notify(me, 'afterInit');
+
+ return me;
+ },
+
+ clear: function() {
+ helpers.canvas.clear(this);
+ return this;
+ },
+
+ stop: function() {
+ // Stops any current animation loop occurring
+ Chart.animationService.cancelAnimation(this);
+ return this;
+ },
+
+ resize: function(silent) {
+ var me = this;
+ var options = me.options;
+ var canvas = me.canvas;
+ var aspectRatio = (options.maintainAspectRatio && me.aspectRatio) || null;
+
+ // the canvas render width and height will be casted to integers so make sure that
+ // the canvas display style uses the same integer values to avoid blurring effect.
+
+ // Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased
+ var newWidth = Math.max(0, Math.floor(helpers.getMaximumWidth(canvas)));
+ var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)));
+
+ if (me.width === newWidth && me.height === newHeight) {
+ return;
+ }
+
+ canvas.width = me.width = newWidth;
+ canvas.height = me.height = newHeight;
+ canvas.style.width = newWidth + 'px';
+ canvas.style.height = newHeight + 'px';
+
+ helpers.retinaScale(me, options.devicePixelRatio);
+
+ if (!silent) {
+ // Notify any plugins about the resize
+ var newSize = {width: newWidth, height: newHeight};
+ plugins.notify(me, 'resize', [newSize]);
+
+ // Notify of resize
+ if (me.options.onResize) {
+ me.options.onResize(me, newSize);
+ }
+
+ me.stop();
+ me.update(me.options.responsiveAnimationDuration);
+ }
+ },
+
+ ensureScalesHaveIDs: function() {
+ var options = this.options;
+ var scalesOptions = options.scales || {};
+ var scaleOptions = options.scale;
+
+ helpers.each(scalesOptions.xAxes, function(xAxisOptions, index) {
+ xAxisOptions.id = xAxisOptions.id || ('x-axis-' + index);
+ });
+
+ helpers.each(scalesOptions.yAxes, function(yAxisOptions, index) {
+ yAxisOptions.id = yAxisOptions.id || ('y-axis-' + index);
+ });
+
+ if (scaleOptions) {
+ scaleOptions.id = scaleOptions.id || 'scale';
+ }
+ },
+
+ /**
+ * Builds a map of scale ID to scale object for future lookup.
+ */
+ buildScales: function() {
+ var me = this;
+ var options = me.options;
+ var scales = me.scales = {};
+ var items = [];
+
+ if (options.scales) {
+ items = items.concat(
+ (options.scales.xAxes || []).map(function(xAxisOptions) {
+ return {options: xAxisOptions, dtype: 'category', dposition: 'bottom'};
+ }),
+ (options.scales.yAxes || []).map(function(yAxisOptions) {
+ return {options: yAxisOptions, dtype: 'linear', dposition: 'left'};
+ })
+ );
+ }
+
+ if (options.scale) {
+ items.push({
+ options: options.scale,
+ dtype: 'radialLinear',
+ isDefault: true,
+ dposition: 'chartArea'
+ });
+ }
+
+ helpers.each(items, function(item) {
+ var scaleOptions = item.options;
+ var scaleType = helpers.valueOrDefault(scaleOptions.type, item.dtype);
+ var scaleClass = Chart.scaleService.getScaleConstructor(scaleType);
+ if (!scaleClass) {
+ return;
+ }
+
+ if (positionIsHorizontal(scaleOptions.position) !== positionIsHorizontal(item.dposition)) {
+ scaleOptions.position = item.dposition;
+ }
+
+ var scale = new scaleClass({
+ id: scaleOptions.id,
+ options: scaleOptions,
+ ctx: me.ctx,
+ chart: me
+ });
+
+ scales[scale.id] = scale;
+ scale.mergeTicksOptions();
+
+ // TODO(SB): I think we should be able to remove this custom case (options.scale)
+ // and consider it as a regular scale part of the "scales"" map only! This would
+ // make the logic easier and remove some useless? custom code.
+ if (item.isDefault) {
+ me.scale = scale;
+ }
+ });
+
+ Chart.scaleService.addScalesToLayout(this);
+ },
+
+ buildOrUpdateControllers: function() {
+ var me = this;
+ var types = [];
+ var newControllers = [];
+
+ helpers.each(me.data.datasets, function(dataset, datasetIndex) {
+ var meta = me.getDatasetMeta(datasetIndex);
+ var type = dataset.type || me.config.type;
+
+ if (meta.type && meta.type !== type) {
+ me.destroyDatasetMeta(datasetIndex);
+ meta = me.getDatasetMeta(datasetIndex);
+ }
+ meta.type = type;
+
+ types.push(meta.type);
+
+ if (meta.controller) {
+ meta.controller.updateIndex(datasetIndex);
+ } else {
+ var ControllerClass = Chart.controllers[meta.type];
+ if (ControllerClass === undefined) {
+ throw new Error('"' + meta.type + '" is not a chart type.');
+ }
+
+ meta.controller = new ControllerClass(me, datasetIndex);
+ newControllers.push(meta.controller);
+ }
+ }, me);
+
+ return newControllers;
+ },
+
+ /**
+ * Reset the elements of all datasets
+ * @private
+ */
+ resetElements: function() {
+ var me = this;
+ helpers.each(me.data.datasets, function(dataset, datasetIndex) {
+ me.getDatasetMeta(datasetIndex).controller.reset();
+ }, me);
+ },
+
+ /**
+ * Resets the chart back to it's state before the initial animation
+ */
+ reset: function() {
+ this.resetElements();
+ this.tooltip.initialize();
+ },
+
+ update: function(config) {
+ var me = this;
+
+ if (!config || typeof config !== 'object') {
+ // backwards compatibility
+ config = {
+ duration: config,
+ lazy: arguments[1]
+ };
+ }
+
+ updateConfig(me);
+
+ if (plugins.notify(me, 'beforeUpdate') === false) {
+ return;
+ }
+
+ // In case the entire data object changed
+ me.tooltip._data = me.data;
+
+ // Make sure dataset controllers are updated and new controllers are reset
+ var newControllers = me.buildOrUpdateControllers();
+
+ // Make sure all dataset controllers have correct meta data counts
+ helpers.each(me.data.datasets, function(dataset, datasetIndex) {
+ me.getDatasetMeta(datasetIndex).controller.buildOrUpdateElements();
+ }, me);
+
+ me.updateLayout();
+
+ // Can only reset the new controllers after the scales have been updated
+ helpers.each(newControllers, function(controller) {
+ controller.reset();
+ });
+
+ me.updateDatasets();
+
+ // Need to reset tooltip in case it is displayed with elements that are removed
+ // after update.
+ me.tooltip.initialize();
+
+ // Last active contains items that were previously in the tooltip.
+ // When we reset the tooltip, we need to clear it
+ me.lastActive = [];
+
+ // Do this before render so that any plugins that need final scale updates can use it
+ plugins.notify(me, 'afterUpdate');
+
+ if (me._bufferedRender) {
+ me._bufferedRequest = {
+ duration: config.duration,
+ easing: config.easing,
+ lazy: config.lazy
+ };
+ } else {
+ me.render(config);
+ }
+ },
+
+ /**
+ * Updates the chart layout unless a plugin returns `false` to the `beforeLayout`
+ * hook, in which case, plugins will not be called on `afterLayout`.
+ * @private
+ */
+ updateLayout: function() {
+ var me = this;
+
+ if (plugins.notify(me, 'beforeLayout') === false) {
+ return;
+ }
+
+ Chart.layoutService.update(this, this.width, this.height);
+
+ /**
+ * Provided for backward compatibility, use `afterLayout` instead.
+ * @method IPlugin#afterScaleUpdate
+ * @deprecated since version 2.5.0
+ * @todo remove at version 3
+ * @private
+ */
+ plugins.notify(me, 'afterScaleUpdate');
+ plugins.notify(me, 'afterLayout');
+ },
+
+ /**
+ * Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate`
+ * hook, in which case, plugins will not be called on `afterDatasetsUpdate`.
+ * @private
+ */
+ updateDatasets: function() {
+ var me = this;
+
+ if (plugins.notify(me, 'beforeDatasetsUpdate') === false) {
+ return;
+ }
+
+ for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
+ me.updateDataset(i);
+ }
+
+ plugins.notify(me, 'afterDatasetsUpdate');
+ },
+
+ /**
+ * Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate`
+ * hook, in which case, plugins will not be called on `afterDatasetUpdate`.
+ * @private
+ */
+ updateDataset: function(index) {
+ var me = this;
+ var meta = me.getDatasetMeta(index);
+ var args = {
+ meta: meta,
+ index: index
+ };
+
+ if (plugins.notify(me, 'beforeDatasetUpdate', [args]) === false) {
+ return;
+ }
+
+ meta.controller.update();
+
+ plugins.notify(me, 'afterDatasetUpdate', [args]);
+ },
+
+ render: function(config) {
+ var me = this;
+
+ if (!config || typeof config !== 'object') {
+ // backwards compatibility
+ config = {
+ duration: config,
+ lazy: arguments[1]
+ };
+ }
+
+ var duration = config.duration;
+ var lazy = config.lazy;
+
+ if (plugins.notify(me, 'beforeRender') === false) {
+ return;
+ }
+
+ var animationOptions = me.options.animation;
+ var onComplete = function(animation) {
+ plugins.notify(me, 'afterRender');
+ helpers.callback(animationOptions && animationOptions.onComplete, [animation], me);
+ };
+
+ if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
+ var animation = new Chart.Animation({
+ numSteps: (duration || animationOptions.duration) / 16.66, // 60 fps
+ easing: config.easing || animationOptions.easing,
+
+ render: function(chart, animationObject) {
+ var easingFunction = helpers.easing.effects[animationObject.easing];
+ var currentStep = animationObject.currentStep;
+ var stepDecimal = currentStep / animationObject.numSteps;
+
+ chart.draw(easingFunction(stepDecimal), stepDecimal, currentStep);
+ },
+
+ onAnimationProgress: animationOptions.onProgress,
+ onAnimationComplete: onComplete
+ });
+
+ Chart.animationService.addAnimation(me, animation, duration, lazy);
+ } else {
+ me.draw();
+
+ // See https://github.com/chartjs/Chart.js/issues/3781
+ onComplete(new Chart.Animation({numSteps: 0, chart: me}));
+ }
+
+ return me;
+ },
+
+ draw: function(easingValue) {
+ var me = this;
+
+ me.clear();
+
+ if (helpers.isNullOrUndef(easingValue)) {
+ easingValue = 1;
+ }
+
+ me.transition(easingValue);
+
+ if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) {
+ return;
+ }
+
+ // Draw all the scales
+ helpers.each(me.boxes, function(box) {
+ box.draw(me.chartArea);
+ }, me);
+
+ if (me.scale) {
+ me.scale.draw();
+ }
+
+ me.drawDatasets(easingValue);
+ me._drawTooltip(easingValue);
+
+ plugins.notify(me, 'afterDraw', [easingValue]);
+ },
+
+ /**
+ * @private
+ */
+ transition: function(easingValue) {
+ var me = this;
+
+ for (var i = 0, ilen = (me.data.datasets || []).length; i < ilen; ++i) {
+ if (me.isDatasetVisible(i)) {
+ me.getDatasetMeta(i).controller.transition(easingValue);
+ }
+ }
+
+ me.tooltip.transition(easingValue);
+ },
+
+ /**
+ * Draws all datasets unless a plugin returns `false` to the `beforeDatasetsDraw`
+ * hook, in which case, plugins will not be called on `afterDatasetsDraw`.
+ * @private
+ */
+ drawDatasets: function(easingValue) {
+ var me = this;
+
+ if (plugins.notify(me, 'beforeDatasetsDraw', [easingValue]) === false) {
+ return;
+ }
+
+ // Draw datasets reversed to support proper line stacking
+ for (var i = (me.data.datasets || []).length - 1; i >= 0; --i) {
+ if (me.isDatasetVisible(i)) {
+ me.drawDataset(i, easingValue);
+ }
+ }
+
+ plugins.notify(me, 'afterDatasetsDraw', [easingValue]);
+ },
+
+ /**
+ * Draws dataset at index unless a plugin returns `false` to the `beforeDatasetDraw`
+ * hook, in which case, plugins will not be called on `afterDatasetDraw`.
+ * @private
+ */
+ drawDataset: function(index, easingValue) {
+ var me = this;
+ var meta = me.getDatasetMeta(index);
+ var args = {
+ meta: meta,
+ index: index,
+ easingValue: easingValue
+ };
+
+ if (plugins.notify(me, 'beforeDatasetDraw', [args]) === false) {
+ return;
+ }
+
+ meta.controller.draw(easingValue);
+
+ plugins.notify(me, 'afterDatasetDraw', [args]);
+ },
+
+ /**
+ * Draws tooltip unless a plugin returns `false` to the `beforeTooltipDraw`
+ * hook, in which case, plugins will not be called on `afterTooltipDraw`.
+ * @private
+ */
+ _drawTooltip: function(easingValue) {
+ var me = this;
+ var tooltip = me.tooltip;
+ var args = {
+ tooltip: tooltip,
+ easingValue: easingValue
+ };
+
+ if (plugins.notify(me, 'beforeTooltipDraw', [args]) === false) {
+ return;
+ }
+
+ tooltip.draw();
+
+ plugins.notify(me, 'afterTooltipDraw', [args]);
+ },
+
+ // Get the single element that was clicked on
+ // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
+ getElementAtEvent: function(e) {
+ return Interaction.modes.single(this, e);
+ },
+
+ getElementsAtEvent: function(e) {
+ return Interaction.modes.label(this, e, {intersect: true});
+ },
+
+ getElementsAtXAxis: function(e) {
+ return Interaction.modes['x-axis'](this, e, {intersect: true});
+ },
+
+ getElementsAtEventForMode: function(e, mode, options) {
+ var method = Interaction.modes[mode];
+ if (typeof method === 'function') {
+ return method(this, e, options);
+ }
+
+ return [];
+ },
+
+ getDatasetAtEvent: function(e) {
+ return Interaction.modes.dataset(this, e, {intersect: true});
+ },
+
+ getDatasetMeta: function(datasetIndex) {
+ var me = this;
+ var dataset = me.data.datasets[datasetIndex];
+ if (!dataset._meta) {
+ dataset._meta = {};
+ }
+
+ var meta = dataset._meta[me.id];
+ if (!meta) {
+ meta = dataset._meta[me.id] = {
+ type: null,
+ data: [],
+ dataset: null,
+ controller: null,
+ hidden: null, // See isDatasetVisible() comment
+ xAxisID: null,
+ yAxisID: null
+ };
+ }
+
+ return meta;
+ },
+
+ getVisibleDatasetCount: function() {
+ var count = 0;
+ for (var i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {
+ if (this.isDatasetVisible(i)) {
+ count++;
+ }
+ }
+ return count;
+ },
+
+ isDatasetVisible: function(datasetIndex) {
+ var meta = this.getDatasetMeta(datasetIndex);
+
+ // meta.hidden is a per chart dataset hidden flag override with 3 states: if true or false,
+ // the dataset.hidden value is ignored, else if null, the dataset hidden state is returned.
+ return typeof meta.hidden === 'boolean' ? !meta.hidden : !this.data.datasets[datasetIndex].hidden;
+ },
+
+ generateLegend: function() {
+ return this.options.legendCallback(this);
+ },
+
+ /**
+ * @private
+ */
+ destroyDatasetMeta: function(datasetIndex) {
+ var id = this.id;
+ var dataset = this.data.datasets[datasetIndex];
+ var meta = dataset._meta && dataset._meta[id];
+
+ if (meta) {
+ meta.controller.destroy();
+ delete dataset._meta[id];
+ }
+ },
+
+ destroy: function() {
+ var me = this;
+ var canvas = me.canvas;
+ var i, ilen;
+
+ me.stop();
+
+ // dataset controllers need to cleanup associated data
+ for (i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
+ me.destroyDatasetMeta(i);
+ }
+
+ if (canvas) {
+ me.unbindEvents();
+ helpers.canvas.clear(me);
+ platform.releaseContext(me.ctx);
+ me.canvas = null;
+ me.ctx = null;
+ }
+
+ plugins.notify(me, 'destroy');
+
+ delete Chart.instances[me.id];
+ },
+
+ toBase64Image: function() {
+ return this.canvas.toDataURL.apply(this.canvas, arguments);
+ },
+
+ initToolTip: function() {
+ var me = this;
+ me.tooltip = new Chart.Tooltip({
+ _chart: me,
+ _chartInstance: me, // deprecated, backward compatibility
+ _data: me.data,
+ _options: me.options.tooltips
+ }, me);
+ },
+
+ /**
+ * @private
+ */
+ bindEvents: function() {
+ var me = this;
+ var listeners = me._listeners = {};
+ var listener = function() {
+ me.eventHandler.apply(me, arguments);
+ };
+
+ helpers.each(me.options.events, function(type) {
+ platform.addEventListener(me, type, listener);
+ listeners[type] = listener;
+ });
+
+ // Elements used to detect size change should not be injected for non responsive charts.
+ // See https://github.com/chartjs/Chart.js/issues/2210
+ if (me.options.responsive) {
+ listener = function() {
+ me.resize();
+ };
+
+ platform.addEventListener(me, 'resize', listener);
+ listeners.resize = listener;
+ }
+ },
+
+ /**
+ * @private
+ */
+ unbindEvents: function() {
+ var me = this;
+ var listeners = me._listeners;
+ if (!listeners) {
+ return;
+ }
+
+ delete me._listeners;
+ helpers.each(listeners, function(listener, type) {
+ platform.removeEventListener(me, type, listener);
+ });
+ },
+
+ updateHoverStyle: function(elements, mode, enabled) {
+ var method = enabled ? 'setHoverStyle' : 'removeHoverStyle';
+ var element, i, ilen;
+
+ for (i = 0, ilen = elements.length; i < ilen; ++i) {
+ element = elements[i];
+ if (element) {
+ this.getDatasetMeta(element._datasetIndex).controller[method](element);
+ }
+ }
+ },
+
+ /**
+ * @private
+ */
+ eventHandler: function(e) {
+ var me = this;
+ var tooltip = me.tooltip;
+
+ if (plugins.notify(me, 'beforeEvent', [e]) === false) {
+ return;
+ }
+
+ // Buffer any update calls so that renders do not occur
+ me._bufferedRender = true;
+ me._bufferedRequest = null;
+
+ var changed = me.handleEvent(e);
+ changed |= tooltip && tooltip.handleEvent(e);
+
+ plugins.notify(me, 'afterEvent', [e]);
+
+ var bufferedRequest = me._bufferedRequest;
+ if (bufferedRequest) {
+ // If we have an update that was triggered, we need to do a normal render
+ me.render(bufferedRequest);
+ } else if (changed && !me.animating) {
+ // If entering, leaving, or changing elements, animate the change via pivot
+ me.stop();
+
+ // We only need to render at this point. Updating will cause scales to be
+ // recomputed generating flicker & using more memory than necessary.
+ me.render(me.options.hover.animationDuration, true);
+ }
+
+ me._bufferedRender = false;
+ me._bufferedRequest = null;
+
+ return me;
+ },
+
+ /**
+ * Handle an event
+ * @private
+ * @param {IEvent} event the event to handle
+ * @return {Boolean} true if the chart needs to re-render
+ */
+ handleEvent: function(e) {
+ var me = this;
+ var options = me.options || {};
+ var hoverOptions = options.hover;
+ var changed = false;
+
+ me.lastActive = me.lastActive || [];
+
+ // Find Active Elements for hover and tooltips
+ if (e.type === 'mouseout') {
+ me.active = [];
+ } else {
+ me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions);
+ }
+
+ // Invoke onHover hook
+ // Need to call with native event here to not break backwards compatibility
+ helpers.callback(options.onHover || options.hover.onHover, [e.native, me.active], me);
+
+ if (e.type === 'mouseup' || e.type === 'click') {
+ if (options.onClick) {
+ // Use e.native here for backwards compatibility
+ options.onClick.call(me, e.native, me.active);
+ }
+ }
+
+ // Remove styling for last active (even if it may still be active)
+ if (me.lastActive.length) {
+ me.updateHoverStyle(me.lastActive, hoverOptions.mode, false);
+ }
+
+ // Built in hover styling
+ if (me.active.length && hoverOptions.mode) {
+ me.updateHoverStyle(me.active, hoverOptions.mode, true);
+ }
+
+ changed = !helpers.arrayEquals(me.active, me.lastActive);
+
+ // Remember Last Actives
+ me.lastActive = me.active;
+
+ return changed;
+ }
+ });
+
+ /**
+ * Provided for backward compatibility, use Chart instead.
+ * @class Chart.Controller
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+ Chart.Controller = Chart;
+};
+
+},{"25":25,"28":28,"45":45,"48":48}],24:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];
+
+ /**
+ * Hooks the array methods that add or remove values ('push', pop', 'shift', 'splice',
+ * 'unshift') and notify the listener AFTER the array has been altered. Listeners are
+ * called on the 'onData*' callbacks (e.g. onDataPush, etc.) with same arguments.
+ */
+ function listenArrayEvents(array, listener) {
+ if (array._chartjs) {
+ array._chartjs.listeners.push(listener);
+ return;
+ }
+
+ Object.defineProperty(array, '_chartjs', {
+ configurable: true,
+ enumerable: false,
+ value: {
+ listeners: [listener]
+ }
+ });
+
+ arrayEvents.forEach(function(key) {
+ var method = 'onData' + key.charAt(0).toUpperCase() + key.slice(1);
+ var base = array[key];
+
+ Object.defineProperty(array, key, {
+ configurable: true,
+ enumerable: false,
+ value: function() {
+ var args = Array.prototype.slice.call(arguments);
+ var res = base.apply(this, args);
+
+ helpers.each(array._chartjs.listeners, function(object) {
+ if (typeof object[method] === 'function') {
+ object[method].apply(object, args);
+ }
+ });
+
+ return res;
+ }
+ });
+ });
+ }
+
+ /**
+ * Removes the given array event listener and cleanup extra attached properties (such as
+ * the _chartjs stub and overridden methods) if array doesn't have any more listeners.
+ */
+ function unlistenArrayEvents(array, listener) {
+ var stub = array._chartjs;
+ if (!stub) {
+ return;
+ }
+
+ var listeners = stub.listeners;
+ var index = listeners.indexOf(listener);
+ if (index !== -1) {
+ listeners.splice(index, 1);
+ }
+
+ if (listeners.length > 0) {
+ return;
+ }
+
+ arrayEvents.forEach(function(key) {
+ delete array[key];
+ });
+
+ delete array._chartjs;
+ }
+
+ // Base class for all dataset controllers (line, bar, etc)
+ Chart.DatasetController = function(chart, datasetIndex) {
+ this.initialize(chart, datasetIndex);
+ };
+
+ helpers.extend(Chart.DatasetController.prototype, {
+
+ /**
+ * Element type used to generate a meta dataset (e.g. Chart.element.Line).
+ * @type {Chart.core.element}
+ */
+ datasetElementType: null,
+
+ /**
+ * Element type used to generate a meta data (e.g. Chart.element.Point).
+ * @type {Chart.core.element}
+ */
+ dataElementType: null,
+
+ initialize: function(chart, datasetIndex) {
+ var me = this;
+ me.chart = chart;
+ me.index = datasetIndex;
+ me.linkScales();
+ me.addElements();
+ },
+
+ updateIndex: function(datasetIndex) {
+ this.index = datasetIndex;
+ },
+
+ linkScales: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var dataset = me.getDataset();
+
+ if (meta.xAxisID === null) {
+ meta.xAxisID = dataset.xAxisID || me.chart.options.scales.xAxes[0].id;
+ }
+ if (meta.yAxisID === null) {
+ meta.yAxisID = dataset.yAxisID || me.chart.options.scales.yAxes[0].id;
+ }
+ },
+
+ getDataset: function() {
+ return this.chart.data.datasets[this.index];
+ },
+
+ getMeta: function() {
+ return this.chart.getDatasetMeta(this.index);
+ },
+
+ getScaleForId: function(scaleID) {
+ return this.chart.scales[scaleID];
+ },
+
+ reset: function() {
+ this.update(true);
+ },
+
+ /**
+ * @private
+ */
+ destroy: function() {
+ if (this._data) {
+ unlistenArrayEvents(this._data, this);
+ }
+ },
+
+ createMetaDataset: function() {
+ var me = this;
+ var type = me.datasetElementType;
+ return type && new type({
+ _chart: me.chart,
+ _datasetIndex: me.index
+ });
+ },
+
+ createMetaData: function(index) {
+ var me = this;
+ var type = me.dataElementType;
+ return type && new type({
+ _chart: me.chart,
+ _datasetIndex: me.index,
+ _index: index
+ });
+ },
+
+ addElements: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var data = me.getDataset().data || [];
+ var metaData = meta.data;
+ var i, ilen;
+
+ for (i = 0, ilen = data.length; i < ilen; ++i) {
+ metaData[i] = metaData[i] || me.createMetaData(i);
+ }
+
+ meta.dataset = meta.dataset || me.createMetaDataset();
+ },
+
+ addElementAndReset: function(index) {
+ var element = this.createMetaData(index);
+ this.getMeta().data.splice(index, 0, element);
+ this.updateElement(element, index, true);
+ },
+
+ buildOrUpdateElements: function() {
+ var me = this;
+ var dataset = me.getDataset();
+ var data = dataset.data || (dataset.data = []);
+
+ // In order to correctly handle data addition/deletion animation (an thus simulate
+ // real-time charts), we need to monitor these data modifications and synchronize
+ // the internal meta data accordingly.
+ if (me._data !== data) {
+ if (me._data) {
+ // This case happens when the user replaced the data array instance.
+ unlistenArrayEvents(me._data, me);
+ }
+
+ listenArrayEvents(data, me);
+ me._data = data;
+ }
+
+ // Re-sync meta data in case the user replaced the data array or if we missed
+ // any updates and so make sure that we handle number of datapoints changing.
+ me.resyncElements();
+ },
+
+ update: helpers.noop,
+
+ transition: function(easingValue) {
+ var meta = this.getMeta();
+ var elements = meta.data || [];
+ var ilen = elements.length;
+ var i = 0;
+
+ for (; i < ilen; ++i) {
+ elements[i].transition(easingValue);
+ }
+
+ if (meta.dataset) {
+ meta.dataset.transition(easingValue);
+ }
+ },
+
+ draw: function() {
+ var meta = this.getMeta();
+ var elements = meta.data || [];
+ var ilen = elements.length;
+ var i = 0;
+
+ if (meta.dataset) {
+ meta.dataset.draw();
+ }
+
+ for (; i < ilen; ++i) {
+ elements[i].draw();
+ }
+ },
+
+ removeHoverStyle: function(element, elementOpts) {
+ var dataset = this.chart.data.datasets[element._datasetIndex];
+ var index = element._index;
+ var custom = element.custom || {};
+ var valueOrDefault = helpers.valueAtIndexOrDefault;
+ var model = element._model;
+
+ model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueOrDefault(dataset.backgroundColor, index, elementOpts.backgroundColor);
+ model.borderColor = custom.borderColor ? custom.borderColor : valueOrDefault(dataset.borderColor, index, elementOpts.borderColor);
+ model.borderWidth = custom.borderWidth ? custom.borderWidth : valueOrDefault(dataset.borderWidth, index, elementOpts.borderWidth);
+ },
+
+ setHoverStyle: function(element) {
+ var dataset = this.chart.data.datasets[element._datasetIndex];
+ var index = element._index;
+ var custom = element.custom || {};
+ var valueOrDefault = helpers.valueAtIndexOrDefault;
+ var getHoverColor = helpers.getHoverColor;
+ var model = element._model;
+
+ model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : valueOrDefault(dataset.hoverBackgroundColor, index, getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : valueOrDefault(dataset.hoverBorderColor, index, getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : valueOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
+ },
+
+ /**
+ * @private
+ */
+ resyncElements: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var data = me.getDataset().data;
+ var numMeta = meta.data.length;
+ var numData = data.length;
+
+ if (numData < numMeta) {
+ meta.data.splice(numData, numMeta - numData);
+ } else if (numData > numMeta) {
+ me.insertElements(numMeta, numData - numMeta);
+ }
+ },
+
+ /**
+ * @private
+ */
+ insertElements: function(start, count) {
+ for (var i = 0; i < count; ++i) {
+ this.addElementAndReset(start + i);
+ }
+ },
+
+ /**
+ * @private
+ */
+ onDataPush: function() {
+ this.insertElements(this.getDataset().data.length - 1, arguments.length);
+ },
+
+ /**
+ * @private
+ */
+ onDataPop: function() {
+ this.getMeta().data.pop();
+ },
+
+ /**
+ * @private
+ */
+ onDataShift: function() {
+ this.getMeta().data.shift();
+ },
+
+ /**
+ * @private
+ */
+ onDataSplice: function(start, count) {
+ this.getMeta().data.splice(start, count);
+ this.insertElements(start, arguments.length - 2);
+ },
+
+ /**
+ * @private
+ */
+ onDataUnshift: function() {
+ this.insertElements(0, arguments.length);
+ }
+ });
+
+ Chart.DatasetController.extend = helpers.inherits;
+};
+
+},{"45":45}],25:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+module.exports = {
+ /**
+ * @private
+ */
+ _set: function(scope, values) {
+ return helpers.merge(this[scope] || (this[scope] = {}), values);
+ }
+};
+
+},{"45":45}],26:[function(require,module,exports){
+'use strict';
+
+var color = require(2);
+var helpers = require(45);
+
+function interpolate(start, view, model, ease) {
+ var keys = Object.keys(model);
+ var i, ilen, key, actual, origin, target, type, c0, c1;
+
+ for (i = 0, ilen = keys.length; i < ilen; ++i) {
+ key = keys[i];
+
+ target = model[key];
+
+ // if a value is added to the model after pivot() has been called, the view
+ // doesn't contain it, so let's initialize the view to the target value.
+ if (!view.hasOwnProperty(key)) {
+ view[key] = target;
+ }
+
+ actual = view[key];
+
+ if (actual === target || key[0] === '_') {
+ continue;
+ }
+
+ if (!start.hasOwnProperty(key)) {
+ start[key] = actual;
+ }
+
+ origin = start[key];
+
+ type = typeof target;
+
+ if (type === typeof origin) {
+ if (type === 'string') {
+ c0 = color(origin);
+ if (c0.valid) {
+ c1 = color(target);
+ if (c1.valid) {
+ view[key] = c1.mix(c0, ease).rgbString();
+ continue;
+ }
+ }
+ } else if (type === 'number' && isFinite(origin) && isFinite(target)) {
+ view[key] = origin + (target - origin) * ease;
+ continue;
+ }
+ }
+
+ view[key] = target;
+ }
+}
+
+var Element = function(configuration) {
+ helpers.extend(this, configuration);
+ this.initialize.apply(this, arguments);
+};
+
+helpers.extend(Element.prototype, {
+
+ initialize: function() {
+ this.hidden = false;
+ },
+
+ pivot: function() {
+ var me = this;
+ if (!me._view) {
+ me._view = helpers.clone(me._model);
+ }
+ me._start = {};
+ return me;
+ },
+
+ transition: function(ease) {
+ var me = this;
+ var model = me._model;
+ var start = me._start;
+ var view = me._view;
+
+ // No animation -> No Transition
+ if (!model || ease === 1) {
+ me._view = model;
+ me._start = null;
+ return me;
+ }
+
+ if (!view) {
+ view = me._view = {};
+ }
+
+ if (!start) {
+ start = me._start = {};
+ }
+
+ interpolate(start, view, model, ease);
+
+ return me;
+ },
+
+ tooltipPosition: function() {
+ return {
+ x: this._model.x,
+ y: this._model.y
+ };
+ },
+
+ hasValue: function() {
+ return helpers.isNumber(this._model.x) && helpers.isNumber(this._model.y);
+ }
+});
+
+Element.extend = helpers.inherits;
+
+module.exports = Element;
+
+},{"2":2,"45":45}],27:[function(require,module,exports){
+/* global window: false */
+/* global document: false */
+'use strict';
+
+var color = require(2);
+var defaults = require(25);
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ // -- Basic js utility methods
+
+ helpers.configMerge = function(/* objects ... */) {
+ return helpers.merge(helpers.clone(arguments[0]), [].slice.call(arguments, 1), {
+ merger: function(key, target, source, options) {
+ var tval = target[key] || {};
+ var sval = source[key];
+
+ if (key === 'scales') {
+ // scale config merging is complex. Add our own function here for that
+ target[key] = helpers.scaleMerge(tval, sval);
+ } else if (key === 'scale') {
+ // used in polar area & radar charts since there is only one scale
+ target[key] = helpers.merge(tval, [Chart.scaleService.getScaleDefaults(sval.type), sval]);
+ } else {
+ helpers._merger(key, target, source, options);
+ }
+ }
+ });
+ };
+
+ helpers.scaleMerge = function(/* objects ... */) {
+ return helpers.merge(helpers.clone(arguments[0]), [].slice.call(arguments, 1), {
+ merger: function(key, target, source, options) {
+ if (key === 'xAxes' || key === 'yAxes') {
+ var slen = source[key].length;
+ var i, type, scale;
+
+ if (!target[key]) {
+ target[key] = [];
+ }
+
+ for (i = 0; i < slen; ++i) {
+ scale = source[key][i];
+ type = helpers.valueOrDefault(scale.type, key === 'xAxes' ? 'category' : 'linear');
+
+ if (i >= target[key].length) {
+ target[key].push({});
+ }
+
+ if (!target[key][i].type || (scale.type && scale.type !== target[key][i].type)) {
+ // new/untyped scale or type changed: let's apply the new defaults
+ // then merge source scale to correctly overwrite the defaults.
+ helpers.merge(target[key][i], [Chart.scaleService.getScaleDefaults(type), scale]);
+ } else {
+ // scales type are the same
+ helpers.merge(target[key][i], scale);
+ }
+ }
+ } else {
+ helpers._merger(key, target, source, options);
+ }
+ }
+ });
+ };
+
+ helpers.where = function(collection, filterCallback) {
+ if (helpers.isArray(collection) && Array.prototype.filter) {
+ return collection.filter(filterCallback);
+ }
+ var filtered = [];
+
+ helpers.each(collection, function(item) {
+ if (filterCallback(item)) {
+ filtered.push(item);
+ }
+ });
+
+ return filtered;
+ };
+ helpers.findIndex = Array.prototype.findIndex ?
+ function(array, callback, scope) {
+ return array.findIndex(callback, scope);
+ } :
+ function(array, callback, scope) {
+ scope = scope === undefined ? array : scope;
+ for (var i = 0, ilen = array.length; i < ilen; ++i) {
+ if (callback.call(scope, array[i], i, array)) {
+ return i;
+ }
+ }
+ return -1;
+ };
+ helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) {
+ // Default to start of the array
+ if (helpers.isNullOrUndef(startIndex)) {
+ startIndex = -1;
+ }
+ for (var i = startIndex + 1; i < arrayToSearch.length; i++) {
+ var currentItem = arrayToSearch[i];
+ if (filterCallback(currentItem)) {
+ return currentItem;
+ }
+ }
+ };
+ helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) {
+ // Default to end of the array
+ if (helpers.isNullOrUndef(startIndex)) {
+ startIndex = arrayToSearch.length;
+ }
+ for (var i = startIndex - 1; i >= 0; i--) {
+ var currentItem = arrayToSearch[i];
+ if (filterCallback(currentItem)) {
+ return currentItem;
+ }
+ }
+ };
+
+ // -- Math methods
+ helpers.isNumber = function(n) {
+ return !isNaN(parseFloat(n)) && isFinite(n);
+ };
+ helpers.almostEquals = function(x, y, epsilon) {
+ return Math.abs(x - y) < epsilon;
+ };
+ helpers.almostWhole = function(x, epsilon) {
+ var rounded = Math.round(x);
+ return (((rounded - epsilon) < x) && ((rounded + epsilon) > x));
+ };
+ helpers.max = function(array) {
+ return array.reduce(function(max, value) {
+ if (!isNaN(value)) {
+ return Math.max(max, value);
+ }
+ return max;
+ }, Number.NEGATIVE_INFINITY);
+ };
+ helpers.min = function(array) {
+ return array.reduce(function(min, value) {
+ if (!isNaN(value)) {
+ return Math.min(min, value);
+ }
+ return min;
+ }, Number.POSITIVE_INFINITY);
+ };
+ helpers.sign = Math.sign ?
+ function(x) {
+ return Math.sign(x);
+ } :
+ function(x) {
+ x = +x; // convert to a number
+ if (x === 0 || isNaN(x)) {
+ return x;
+ }
+ return x > 0 ? 1 : -1;
+ };
+ helpers.log10 = Math.log10 ?
+ function(x) {
+ return Math.log10(x);
+ } :
+ function(x) {
+ return Math.log(x) / Math.LN10;
+ };
+ helpers.toRadians = function(degrees) {
+ return degrees * (Math.PI / 180);
+ };
+ helpers.toDegrees = function(radians) {
+ return radians * (180 / Math.PI);
+ };
+ // Gets the angle from vertical upright to the point about a centre.
+ helpers.getAngleFromPoint = function(centrePoint, anglePoint) {
+ var distanceFromXCenter = anglePoint.x - centrePoint.x;
+ var distanceFromYCenter = anglePoint.y - centrePoint.y;
+ var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);
+
+ var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter);
+
+ if (angle < (-0.5 * Math.PI)) {
+ angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2]
+ }
+
+ return {
+ angle: angle,
+ distance: radialDistanceFromCenter
+ };
+ };
+ helpers.distanceBetweenPoints = function(pt1, pt2) {
+ return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));
+ };
+ helpers.aliasPixel = function(pixelWidth) {
+ return (pixelWidth % 2 === 0) ? 0 : 0.5;
+ };
+ helpers.splineCurve = function(firstPoint, middlePoint, afterPoint, t) {
+ // Props to Rob Spencer at scaled innovation for his post on splining between points
+ // http://scaledinnovation.com/analytics/splines/aboutSplines.html
+
+ // This function must also respect "skipped" points
+
+ var previous = firstPoint.skip ? middlePoint : firstPoint;
+ var current = middlePoint;
+ var next = afterPoint.skip ? middlePoint : afterPoint;
+
+ var d01 = Math.sqrt(Math.pow(current.x - previous.x, 2) + Math.pow(current.y - previous.y, 2));
+ var d12 = Math.sqrt(Math.pow(next.x - current.x, 2) + Math.pow(next.y - current.y, 2));
+
+ var s01 = d01 / (d01 + d12);
+ var s12 = d12 / (d01 + d12);
+
+ // If all points are the same, s01 & s02 will be inf
+ s01 = isNaN(s01) ? 0 : s01;
+ s12 = isNaN(s12) ? 0 : s12;
+
+ var fa = t * s01; // scaling factor for triangle Ta
+ var fb = t * s12;
+
+ return {
+ previous: {
+ x: current.x - fa * (next.x - previous.x),
+ y: current.y - fa * (next.y - previous.y)
+ },
+ next: {
+ x: current.x + fb * (next.x - previous.x),
+ y: current.y + fb * (next.y - previous.y)
+ }
+ };
+ };
+ helpers.EPSILON = Number.EPSILON || 1e-14;
+ helpers.splineCurveMonotone = function(points) {
+ // This function calculates Bézier control points in a similar way than |splineCurve|,
+ // but preserves monotonicity of the provided data and ensures no local extremums are added
+ // between the dataset discrete points due to the interpolation.
+ // See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
+
+ var pointsWithTangents = (points || []).map(function(point) {
+ return {
+ model: point._model,
+ deltaK: 0,
+ mK: 0
+ };
+ });
+
+ // Calculate slopes (deltaK) and initialize tangents (mK)
+ var pointsLen = pointsWithTangents.length;
+ var i, pointBefore, pointCurrent, pointAfter;
+ for (i = 0; i < pointsLen; ++i) {
+ pointCurrent = pointsWithTangents[i];
+ if (pointCurrent.model.skip) {
+ continue;
+ }
+
+ pointBefore = i > 0 ? pointsWithTangents[i - 1] : null;
+ pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;
+ if (pointAfter && !pointAfter.model.skip) {
+ var slopeDeltaX = (pointAfter.model.x - pointCurrent.model.x);
+
+ // In the case of two points that appear at the same x pixel, slopeDeltaX is 0
+ pointCurrent.deltaK = slopeDeltaX !== 0 ? (pointAfter.model.y - pointCurrent.model.y) / slopeDeltaX : 0;
+ }
+
+ if (!pointBefore || pointBefore.model.skip) {
+ pointCurrent.mK = pointCurrent.deltaK;
+ } else if (!pointAfter || pointAfter.model.skip) {
+ pointCurrent.mK = pointBefore.deltaK;
+ } else if (this.sign(pointBefore.deltaK) !== this.sign(pointCurrent.deltaK)) {
+ pointCurrent.mK = 0;
+ } else {
+ pointCurrent.mK = (pointBefore.deltaK + pointCurrent.deltaK) / 2;
+ }
+ }
+
+ // Adjust tangents to ensure monotonic properties
+ var alphaK, betaK, tauK, squaredMagnitude;
+ for (i = 0; i < pointsLen - 1; ++i) {
+ pointCurrent = pointsWithTangents[i];
+ pointAfter = pointsWithTangents[i + 1];
+ if (pointCurrent.model.skip || pointAfter.model.skip) {
+ continue;
+ }
+
+ if (helpers.almostEquals(pointCurrent.deltaK, 0, this.EPSILON)) {
+ pointCurrent.mK = pointAfter.mK = 0;
+ continue;
+ }
+
+ alphaK = pointCurrent.mK / pointCurrent.deltaK;
+ betaK = pointAfter.mK / pointCurrent.deltaK;
+ squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2);
+ if (squaredMagnitude <= 9) {
+ continue;
+ }
+
+ tauK = 3 / Math.sqrt(squaredMagnitude);
+ pointCurrent.mK = alphaK * tauK * pointCurrent.deltaK;
+ pointAfter.mK = betaK * tauK * pointCurrent.deltaK;
+ }
+
+ // Compute control points
+ var deltaX;
+ for (i = 0; i < pointsLen; ++i) {
+ pointCurrent = pointsWithTangents[i];
+ if (pointCurrent.model.skip) {
+ continue;
+ }
+
+ pointBefore = i > 0 ? pointsWithTangents[i - 1] : null;
+ pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;
+ if (pointBefore && !pointBefore.model.skip) {
+ deltaX = (pointCurrent.model.x - pointBefore.model.x) / 3;
+ pointCurrent.model.controlPointPreviousX = pointCurrent.model.x - deltaX;
+ pointCurrent.model.controlPointPreviousY = pointCurrent.model.y - deltaX * pointCurrent.mK;
+ }
+ if (pointAfter && !pointAfter.model.skip) {
+ deltaX = (pointAfter.model.x - pointCurrent.model.x) / 3;
+ pointCurrent.model.controlPointNextX = pointCurrent.model.x + deltaX;
+ pointCurrent.model.controlPointNextY = pointCurrent.model.y + deltaX * pointCurrent.mK;
+ }
+ }
+ };
+ helpers.nextItem = function(collection, index, loop) {
+ if (loop) {
+ return index >= collection.length - 1 ? collection[0] : collection[index + 1];
+ }
+ return index >= collection.length - 1 ? collection[collection.length - 1] : collection[index + 1];
+ };
+ helpers.previousItem = function(collection, index, loop) {
+ if (loop) {
+ return index <= 0 ? collection[collection.length - 1] : collection[index - 1];
+ }
+ return index <= 0 ? collection[0] : collection[index - 1];
+ };
+ // Implementation of the nice number algorithm used in determining where axis labels will go
+ helpers.niceNum = function(range, round) {
+ var exponent = Math.floor(helpers.log10(range));
+ var fraction = range / Math.pow(10, exponent);
+ var niceFraction;
+
+ if (round) {
+ if (fraction < 1.5) {
+ niceFraction = 1;
+ } else if (fraction < 3) {
+ niceFraction = 2;
+ } else if (fraction < 7) {
+ niceFraction = 5;
+ } else {
+ niceFraction = 10;
+ }
+ } else if (fraction <= 1.0) {
+ niceFraction = 1;
+ } else if (fraction <= 2) {
+ niceFraction = 2;
+ } else if (fraction <= 5) {
+ niceFraction = 5;
+ } else {
+ niceFraction = 10;
+ }
+
+ return niceFraction * Math.pow(10, exponent);
+ };
+ // Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
+ helpers.requestAnimFrame = (function() {
+ if (typeof window === 'undefined') {
+ return function(callback) {
+ callback();
+ };
+ }
+ return window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function(callback) {
+ return window.setTimeout(callback, 1000 / 60);
+ };
+ }());
+ // -- DOM methods
+ helpers.getRelativePosition = function(evt, chart) {
+ var mouseX, mouseY;
+ var e = evt.originalEvent || evt;
+ var canvas = evt.currentTarget || evt.srcElement;
+ var boundingRect = canvas.getBoundingClientRect();
+
+ var touches = e.touches;
+ if (touches && touches.length > 0) {
+ mouseX = touches[0].clientX;
+ mouseY = touches[0].clientY;
+
+ } else {
+ mouseX = e.clientX;
+ mouseY = e.clientY;
+ }
+
+ // Scale mouse coordinates into canvas coordinates
+ // by following the pattern laid out by 'jerryj' in the comments of
+ // http://www.html5canvastutorials.com/advanced/html5-canvas-mouse-coordinates/
+ var paddingLeft = parseFloat(helpers.getStyle(canvas, 'padding-left'));
+ var paddingTop = parseFloat(helpers.getStyle(canvas, 'padding-top'));
+ var paddingRight = parseFloat(helpers.getStyle(canvas, 'padding-right'));
+ var paddingBottom = parseFloat(helpers.getStyle(canvas, 'padding-bottom'));
+ var width = boundingRect.right - boundingRect.left - paddingLeft - paddingRight;
+ var height = boundingRect.bottom - boundingRect.top - paddingTop - paddingBottom;
+
+ // We divide by the current device pixel ratio, because the canvas is scaled up by that amount in each direction. However
+ // the backend model is in unscaled coordinates. Since we are going to deal with our model coordinates, we go back here
+ mouseX = Math.round((mouseX - boundingRect.left - paddingLeft) / (width) * canvas.width / chart.currentDevicePixelRatio);
+ mouseY = Math.round((mouseY - boundingRect.top - paddingTop) / (height) * canvas.height / chart.currentDevicePixelRatio);
+
+ return {
+ x: mouseX,
+ y: mouseY
+ };
+
+ };
+
+ // Private helper function to convert max-width/max-height values that may be percentages into a number
+ function parseMaxStyle(styleValue, node, parentProperty) {
+ var valueInPixels;
+ if (typeof styleValue === 'string') {
+ valueInPixels = parseInt(styleValue, 10);
+
+ if (styleValue.indexOf('%') !== -1) {
+ // percentage * size in dimension
+ valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];
+ }
+ } else {
+ valueInPixels = styleValue;
+ }
+
+ return valueInPixels;
+ }
+
+ /**
+ * Returns if the given value contains an effective constraint.
+ * @private
+ */
+ function isConstrainedValue(value) {
+ return value !== undefined && value !== null && value !== 'none';
+ }
+
+ // Private helper to get a constraint dimension
+ // @param domNode : the node to check the constraint on
+ // @param maxStyle : the style that defines the maximum for the direction we are using (maxWidth / maxHeight)
+ // @param percentageProperty : property of parent to use when calculating width as a percentage
+ // @see http://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser
+ function getConstraintDimension(domNode, maxStyle, percentageProperty) {
+ var view = document.defaultView;
+ var parentNode = domNode.parentNode;
+ var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
+ var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
+ var hasCNode = isConstrainedValue(constrainedNode);
+ var hasCContainer = isConstrainedValue(constrainedContainer);
+ var infinity = Number.POSITIVE_INFINITY;
+
+ if (hasCNode || hasCContainer) {
+ return Math.min(
+ hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity,
+ hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity);
+ }
+
+ return 'none';
+ }
+ // returns Number or undefined if no constraint
+ helpers.getConstraintWidth = function(domNode) {
+ return getConstraintDimension(domNode, 'max-width', 'clientWidth');
+ };
+ // returns Number or undefined if no constraint
+ helpers.getConstraintHeight = function(domNode) {
+ return getConstraintDimension(domNode, 'max-height', 'clientHeight');
+ };
+ helpers.getMaximumWidth = function(domNode) {
+ var container = domNode.parentNode;
+ if (!container) {
+ return domNode.clientWidth;
+ }
+
+ var paddingLeft = parseInt(helpers.getStyle(container, 'padding-left'), 10);
+ var paddingRight = parseInt(helpers.getStyle(container, 'padding-right'), 10);
+ var w = container.clientWidth - paddingLeft - paddingRight;
+ var cw = helpers.getConstraintWidth(domNode);
+ return isNaN(cw) ? w : Math.min(w, cw);
+ };
+ helpers.getMaximumHeight = function(domNode) {
+ var container = domNode.parentNode;
+ if (!container) {
+ return domNode.clientHeight;
+ }
+
+ var paddingTop = parseInt(helpers.getStyle(container, 'padding-top'), 10);
+ var paddingBottom = parseInt(helpers.getStyle(container, 'padding-bottom'), 10);
+ var h = container.clientHeight - paddingTop - paddingBottom;
+ var ch = helpers.getConstraintHeight(domNode);
+ return isNaN(ch) ? h : Math.min(h, ch);
+ };
+ helpers.getStyle = function(el, property) {
+ return el.currentStyle ?
+ el.currentStyle[property] :
+ document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
+ };
+ helpers.retinaScale = function(chart, forceRatio) {
+ var pixelRatio = chart.currentDevicePixelRatio = forceRatio || window.devicePixelRatio || 1;
+ if (pixelRatio === 1) {
+ return;
+ }
+
+ var canvas = chart.canvas;
+ var height = chart.height;
+ var width = chart.width;
+
+ canvas.height = height * pixelRatio;
+ canvas.width = width * pixelRatio;
+ chart.ctx.scale(pixelRatio, pixelRatio);
+
+ // If no style has been set on the canvas, the render size is used as display size,
+ // making the chart visually bigger, so let's enforce it to the "correct" values.
+ // See https://github.com/chartjs/Chart.js/issues/3575
+ canvas.style.height = height + 'px';
+ canvas.style.width = width + 'px';
+ };
+ // -- Canvas methods
+ helpers.fontString = function(pixelSize, fontStyle, fontFamily) {
+ return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
+ };
+ helpers.longestText = function(ctx, font, arrayOfThings, cache) {
+ cache = cache || {};
+ var data = cache.data = cache.data || {};
+ var gc = cache.garbageCollect = cache.garbageCollect || [];
+
+ if (cache.font !== font) {
+ data = cache.data = {};
+ gc = cache.garbageCollect = [];
+ cache.font = font;
+ }
+
+ ctx.font = font;
+ var longest = 0;
+ helpers.each(arrayOfThings, function(thing) {
+ // Undefined strings and arrays should not be measured
+ if (thing !== undefined && thing !== null && helpers.isArray(thing) !== true) {
+ longest = helpers.measureText(ctx, data, gc, longest, thing);
+ } else if (helpers.isArray(thing)) {
+ // if it is an array lets measure each element
+ // to do maybe simplify this function a bit so we can do this more recursively?
+ helpers.each(thing, function(nestedThing) {
+ // Undefined strings and arrays should not be measured
+ if (nestedThing !== undefined && nestedThing !== null && !helpers.isArray(nestedThing)) {
+ longest = helpers.measureText(ctx, data, gc, longest, nestedThing);
+ }
+ });
+ }
+ });
+
+ var gcLen = gc.length / 2;
+ if (gcLen > arrayOfThings.length) {
+ for (var i = 0; i < gcLen; i++) {
+ delete data[gc[i]];
+ }
+ gc.splice(0, gcLen);
+ }
+ return longest;
+ };
+ helpers.measureText = function(ctx, data, gc, longest, string) {
+ var textWidth = data[string];
+ if (!textWidth) {
+ textWidth = data[string] = ctx.measureText(string).width;
+ gc.push(string);
+ }
+ if (textWidth > longest) {
+ longest = textWidth;
+ }
+ return longest;
+ };
+ helpers.numberOfLabelLines = function(arrayOfThings) {
+ var numberOfLines = 1;
+ helpers.each(arrayOfThings, function(thing) {
+ if (helpers.isArray(thing)) {
+ if (thing.length > numberOfLines) {
+ numberOfLines = thing.length;
+ }
+ }
+ });
+ return numberOfLines;
+ };
+
+ helpers.color = !color ?
+ function(value) {
+ console.error('Color.js not found!');
+ return value;
+ } :
+ function(value) {
+ /* global CanvasGradient */
+ if (value instanceof CanvasGradient) {
+ value = defaults.global.defaultColor;
+ }
+
+ return color(value);
+ };
+
+ helpers.getHoverColor = function(colorValue) {
+ /* global CanvasPattern */
+ return (colorValue instanceof CanvasPattern) ?
+ colorValue :
+ helpers.color(colorValue).saturate(0.5).darken(0.1).rgbString();
+ };
+};
+
+},{"2":2,"25":25,"45":45}],28:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+/**
+ * Helper function to get relative position for an event
+ * @param {Event|IEvent} event - The event to get the position for
+ * @param {Chart} chart - The chart
+ * @returns {Point} the event position
+ */
+function getRelativePosition(e, chart) {
+ if (e.native) {
+ return {
+ x: e.x,
+ y: e.y
+ };
+ }
+
+ return helpers.getRelativePosition(e, chart);
+}
+
+/**
+ * Helper function to traverse all of the visible elements in the chart
+ * @param chart {chart} the chart
+ * @param handler {Function} the callback to execute for each visible item
+ */
+function parseVisibleItems(chart, handler) {
+ var datasets = chart.data.datasets;
+ var meta, i, j, ilen, jlen;
+
+ for (i = 0, ilen = datasets.length; i < ilen; ++i) {
+ if (!chart.isDatasetVisible(i)) {
+ continue;
+ }
+
+ meta = chart.getDatasetMeta(i);
+ for (j = 0, jlen = meta.data.length; j < jlen; ++j) {
+ var element = meta.data[j];
+ if (!element._view.skip) {
+ handler(element);
+ }
+ }
+ }
+}
+
+/**
+ * Helper function to get the items that intersect the event position
+ * @param items {ChartElement[]} elements to filter
+ * @param position {Point} the point to be nearest to
+ * @return {ChartElement[]} the nearest items
+ */
+function getIntersectItems(chart, position) {
+ var elements = [];
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inRange(position.x, position.y)) {
+ elements.push(element);
+ }
+ });
+
+ return elements;
+}
+
+/**
+ * Helper function to get the items nearest to the event position considering all visible items in teh chart
+ * @param chart {Chart} the chart to look at elements from
+ * @param position {Point} the point to be nearest to
+ * @param intersect {Boolean} if true, only consider items that intersect the position
+ * @param distanceMetric {Function} function to provide the distance between points
+ * @return {ChartElement[]} the nearest items
+ */
+function getNearestItems(chart, position, intersect, distanceMetric) {
+ var minDistance = Number.POSITIVE_INFINITY;
+ var nearestItems = [];
+
+ parseVisibleItems(chart, function(element) {
+ if (intersect && !element.inRange(position.x, position.y)) {
+ return;
+ }
+
+ var center = element.getCenterPoint();
+ var distance = distanceMetric(position, center);
+
+ if (distance < minDistance) {
+ nearestItems = [element];
+ minDistance = distance;
+ } else if (distance === minDistance) {
+ // Can have multiple items at the same distance in which case we sort by size
+ nearestItems.push(element);
+ }
+ });
+
+ return nearestItems;
+}
+
+/**
+ * Get a distance metric function for two points based on the
+ * axis mode setting
+ * @param {String} axis the axis mode. x|y|xy
+ */
+function getDistanceMetricForAxis(axis) {
+ var useX = axis.indexOf('x') !== -1;
+ var useY = axis.indexOf('y') !== -1;
+
+ return function(pt1, pt2) {
+ var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;
+ var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;
+ return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
+ };
+}
+
+function indexMode(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ // Default axis for index mode is 'x' to match old behaviour
+ options.axis = options.axis || 'x';
+ var distanceMetric = getDistanceMetricForAxis(options.axis);
+ var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric);
+ var elements = [];
+
+ if (!items.length) {
+ return [];
+ }
+
+ chart.data.datasets.forEach(function(dataset, datasetIndex) {
+ if (chart.isDatasetVisible(datasetIndex)) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ var element = meta.data[items[0]._index];
+
+ // don't count items that are skipped (null data)
+ if (element && !element._view.skip) {
+ elements.push(element);
+ }
+ }
+ });
+
+ return elements;
+}
+
+/**
+ * @interface IInteractionOptions
+ */
+/**
+ * If true, only consider items that intersect the point
+ * @name IInterfaceOptions#boolean
+ * @type Boolean
+ */
+
+/**
+ * Contains interaction related functions
+ * @namespace Chart.Interaction
+ */
+module.exports = {
+ // Helper function for different modes
+ modes: {
+ single: function(chart, e) {
+ var position = getRelativePosition(e, chart);
+ var elements = [];
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inRange(position.x, position.y)) {
+ elements.push(element);
+ return elements;
+ }
+ });
+
+ return elements.slice(0, 1);
+ },
+
+ /**
+ * @function Chart.Interaction.modes.label
+ * @deprecated since version 2.4.0
+ * @todo remove at version 3
+ * @private
+ */
+ label: indexMode,
+
+ /**
+ * Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something
+ * If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
+ * @function Chart.Interaction.modes.index
+ * @since v2.4.0
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use during interaction
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ index: indexMode,
+
+ /**
+ * Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something
+ * If the options.intersect is false, we find the nearest item and return the items in that dataset
+ * @function Chart.Interaction.modes.dataset
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use during interaction
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ dataset: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ options.axis = options.axis || 'xy';
+ var distanceMetric = getDistanceMetricForAxis(options.axis);
+ var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric);
+
+ if (items.length > 0) {
+ items = chart.getDatasetMeta(items[0]._datasetIndex).data;
+ }
+
+ return items;
+ },
+
+ /**
+ * @function Chart.Interaction.modes.x-axis
+ * @deprecated since version 2.4.0. Use index mode and intersect == true
+ * @todo remove at version 3
+ * @private
+ */
+ 'x-axis': function(chart, e) {
+ return indexMode(chart, e, {intersect: false});
+ },
+
+ /**
+ * Point mode returns all elements that hit test based on the event position
+ * of the event
+ * @function Chart.Interaction.modes.intersect
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ point: function(chart, e) {
+ var position = getRelativePosition(e, chart);
+ return getIntersectItems(chart, position);
+ },
+
+ /**
+ * nearest mode returns the element closest to the point
+ * @function Chart.Interaction.modes.intersect
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ nearest: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ options.axis = options.axis || 'xy';
+ var distanceMetric = getDistanceMetricForAxis(options.axis);
+ var nearestItems = getNearestItems(chart, position, options.intersect, distanceMetric);
+
+ // We have multiple items at the same distance from the event. Now sort by smallest
+ if (nearestItems.length > 1) {
+ nearestItems.sort(function(a, b) {
+ var sizeA = a.getArea();
+ var sizeB = b.getArea();
+ var ret = sizeA - sizeB;
+
+ if (ret === 0) {
+ // if equal sort by dataset index
+ ret = a._datasetIndex - b._datasetIndex;
+ }
+
+ return ret;
+ });
+ }
+
+ // Return only 1 item
+ return nearestItems.slice(0, 1);
+ },
+
+ /**
+ * x mode returns the elements that hit-test at the current x coordinate
+ * @function Chart.Interaction.modes.x
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ x: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ var items = [];
+ var intersectsItem = false;
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inXRange(position.x)) {
+ items.push(element);
+ }
+
+ if (element.inRange(position.x, position.y)) {
+ intersectsItem = true;
+ }
+ });
+
+ // If we want to trigger on an intersect and we don't have any items
+ // that intersect the position, return nothing
+ if (options.intersect && !intersectsItem) {
+ items = [];
+ }
+ return items;
+ },
+
+ /**
+ * y mode returns the elements that hit-test at the current y coordinate
+ * @function Chart.Interaction.modes.y
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ y: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ var items = [];
+ var intersectsItem = false;
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inYRange(position.y)) {
+ items.push(element);
+ }
+
+ if (element.inRange(position.x, position.y)) {
+ intersectsItem = true;
+ }
+ });
+
+ // If we want to trigger on an intersect and we don't have any items
+ // that intersect the position, return nothing
+ if (options.intersect && !intersectsItem) {
+ items = [];
+ }
+ return items;
+ }
+ }
+};
+
+},{"45":45}],29:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+
+defaults._set('global', {
+ responsive: true,
+ responsiveAnimationDuration: 0,
+ maintainAspectRatio: true,
+ events: ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'],
+ hover: {
+ onHover: null,
+ mode: 'nearest',
+ intersect: true,
+ animationDuration: 400
+ },
+ onClick: null,
+ defaultColor: 'rgba(0,0,0,0.1)',
+ defaultFontColor: '#666',
+ defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+ defaultFontSize: 12,
+ defaultFontStyle: 'normal',
+ showLines: true,
+
+ // Element defaults defined in element extensions
+ elements: {},
+
+ // Layout options such as padding
+ layout: {
+ padding: {
+ top: 0,
+ right: 0,
+ bottom: 0,
+ left: 0
+ }
+ }
+});
+
+module.exports = function() {
+
+ // Occupy the global variable of Chart, and create a simple base class
+ var Chart = function(item, config) {
+ this.construct(item, config);
+ return this;
+ };
+
+ Chart.Chart = Chart;
+
+ return Chart;
+};
+
+},{"25":25}],30:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ function filterByPosition(array, position) {
+ return helpers.where(array, function(v) {
+ return v.position === position;
+ });
+ }
+
+ function sortByWeight(array, reverse) {
+ array.forEach(function(v, i) {
+ v._tmpIndex_ = i;
+ return v;
+ });
+ array.sort(function(a, b) {
+ var v0 = reverse ? b : a;
+ var v1 = reverse ? a : b;
+ return v0.weight === v1.weight ?
+ v0._tmpIndex_ - v1._tmpIndex_ :
+ v0.weight - v1.weight;
+ });
+ array.forEach(function(v) {
+ delete v._tmpIndex_;
+ });
+ }
+
+ /**
+ * @interface ILayoutItem
+ * @prop {String} position - The position of the item in the chart layout. Possible values are
+ * 'left', 'top', 'right', 'bottom', and 'chartArea'
+ * @prop {Number} weight - The weight used to sort the item. Higher weights are further away from the chart area
+ * @prop {Boolean} fullWidth - if true, and the item is horizontal, then push vertical boxes down
+ * @prop {Function} isHorizontal - returns true if the layout item is horizontal (ie. top or bottom)
+ * @prop {Function} update - Takes two parameters: width and height. Returns size of item
+ * @prop {Function} getPadding - Returns an object with padding on the edges
+ * @prop {Number} width - Width of item. Must be valid after update()
+ * @prop {Number} height - Height of item. Must be valid after update()
+ * @prop {Number} left - Left edge of the item. Set by layout system and cannot be used in update
+ * @prop {Number} top - Top edge of the item. Set by layout system and cannot be used in update
+ * @prop {Number} right - Right edge of the item. Set by layout system and cannot be used in update
+ * @prop {Number} bottom - Bottom edge of the item. Set by layout system and cannot be used in update
+ */
+
+ // The layout service is very self explanatory. It's responsible for the layout within a chart.
+ // Scales, Legends and Plugins all rely on the layout service and can easily register to be placed anywhere they need
+ // It is this service's responsibility of carrying out that layout.
+ Chart.layoutService = {
+ defaults: {},
+
+ /**
+ * Register a box to a chart.
+ * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
+ * @param {Chart} chart - the chart to use
+ * @param {ILayoutItem} item - the item to add to be layed out
+ */
+ addBox: function(chart, item) {
+ if (!chart.boxes) {
+ chart.boxes = [];
+ }
+
+ // initialize item with default values
+ item.fullWidth = item.fullWidth || false;
+ item.position = item.position || 'top';
+ item.weight = item.weight || 0;
+
+ chart.boxes.push(item);
+ },
+
+ /**
+ * Remove a layoutItem from a chart
+ * @param {Chart} chart - the chart to remove the box from
+ * @param {Object} layoutItem - the item to remove from the layout
+ */
+ removeBox: function(chart, layoutItem) {
+ var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;
+ if (index !== -1) {
+ chart.boxes.splice(index, 1);
+ }
+ },
+
+ /**
+ * Sets (or updates) options on the given `item`.
+ * @param {Chart} chart - the chart in which the item lives (or will be added to)
+ * @param {Object} item - the item to configure with the given options
+ * @param {Object} options - the new item options.
+ */
+ configure: function(chart, item, options) {
+ var props = ['fullWidth', 'position', 'weight'];
+ var ilen = props.length;
+ var i = 0;
+ var prop;
+
+ for (; i < ilen; ++i) {
+ prop = props[i];
+ if (options.hasOwnProperty(prop)) {
+ item[prop] = options[prop];
+ }
+ }
+ },
+
+ /**
+ * Fits boxes of the given chart into the given size by having each box measure itself
+ * then running a fitting algorithm
+ * @param {Chart} chart - the chart
+ * @param {Number} width - the width to fit into
+ * @param {Number} height - the height to fit into
+ */
+ update: function(chart, width, height) {
+ if (!chart) {
+ return;
+ }
+
+ var layoutOptions = chart.options.layout || {};
+ var padding = helpers.options.toPadding(layoutOptions.padding);
+ var leftPadding = padding.left;
+ var rightPadding = padding.right;
+ var topPadding = padding.top;
+ var bottomPadding = padding.bottom;
+
+ var leftBoxes = filterByPosition(chart.boxes, 'left');
+ var rightBoxes = filterByPosition(chart.boxes, 'right');
+ var topBoxes = filterByPosition(chart.boxes, 'top');
+ var bottomBoxes = filterByPosition(chart.boxes, 'bottom');
+ var chartAreaBoxes = filterByPosition(chart.boxes, 'chartArea');
+
+ // Sort boxes by weight. A higher weight is further away from the chart area
+ sortByWeight(leftBoxes, true);
+ sortByWeight(rightBoxes, false);
+ sortByWeight(topBoxes, true);
+ sortByWeight(bottomBoxes, false);
+
+ // Essentially we now have any number of boxes on each of the 4 sides.
+ // Our canvas looks like the following.
+ // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and
+ // B1 is the bottom axis
+ // There are also 4 quadrant-like locations (left to right instead of clockwise) reserved for chart overlays
+ // These locations are single-box locations only, when trying to register a chartArea location that is already taken,
+ // an error will be thrown.
+ //
+ // |----------------------------------------------------|
+ // | T1 (Full Width) |
+ // |----------------------------------------------------|
+ // | | | T2 | |
+ // | |----|-------------------------------------|----|
+ // | | | C1 | | C2 | |
+ // | | |----| |----| |
+ // | | | | |
+ // | L1 | L2 | ChartArea (C0) | R1 |
+ // | | | | |
+ // | | |----| |----| |
+ // | | | C3 | | C4 | |
+ // | |----|-------------------------------------|----|
+ // | | | B1 | |
+ // |----------------------------------------------------|
+ // | B2 (Full Width) |
+ // |----------------------------------------------------|
+ //
+ // What we do to find the best sizing, we do the following
+ // 1. Determine the minimum size of the chart area.
+ // 2. Split the remaining width equally between each vertical axis
+ // 3. Split the remaining height equally between each horizontal axis
+ // 4. Give each layout the maximum size it can be. The layout will return it's minimum size
+ // 5. Adjust the sizes of each axis based on it's minimum reported size.
+ // 6. Refit each axis
+ // 7. Position each axis in the final location
+ // 8. Tell the chart the final location of the chart area
+ // 9. Tell any axes that overlay the chart area the positions of the chart area
+
+ // Step 1
+ var chartWidth = width - leftPadding - rightPadding;
+ var chartHeight = height - topPadding - bottomPadding;
+ var chartAreaWidth = chartWidth / 2; // min 50%
+ var chartAreaHeight = chartHeight / 2; // min 50%
+
+ // Step 2
+ var verticalBoxWidth = (width - chartAreaWidth) / (leftBoxes.length + rightBoxes.length);
+
+ // Step 3
+ var horizontalBoxHeight = (height - chartAreaHeight) / (topBoxes.length + bottomBoxes.length);
+
+ // Step 4
+ var maxChartAreaWidth = chartWidth;
+ var maxChartAreaHeight = chartHeight;
+ var minBoxSizes = [];
+
+ function getMinimumBoxSize(box) {
+ var minSize;
+ var isHorizontal = box.isHorizontal();
+
+ if (isHorizontal) {
+ minSize = box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, horizontalBoxHeight);
+ maxChartAreaHeight -= minSize.height;
+ } else {
+ minSize = box.update(verticalBoxWidth, chartAreaHeight);
+ maxChartAreaWidth -= minSize.width;
+ }
+
+ minBoxSizes.push({
+ horizontal: isHorizontal,
+ minSize: minSize,
+ box: box,
+ });
+ }
+
+ helpers.each(leftBoxes.concat(rightBoxes, topBoxes, bottomBoxes), getMinimumBoxSize);
+
+ // If a horizontal box has padding, we move the left boxes over to avoid ugly charts (see issue #2478)
+ var maxHorizontalLeftPadding = 0;
+ var maxHorizontalRightPadding = 0;
+ var maxVerticalTopPadding = 0;
+ var maxVerticalBottomPadding = 0;
+
+ helpers.each(topBoxes.concat(bottomBoxes), function(horizontalBox) {
+ if (horizontalBox.getPadding) {
+ var boxPadding = horizontalBox.getPadding();
+ maxHorizontalLeftPadding = Math.max(maxHorizontalLeftPadding, boxPadding.left);
+ maxHorizontalRightPadding = Math.max(maxHorizontalRightPadding, boxPadding.right);
+ }
+ });
+
+ helpers.each(leftBoxes.concat(rightBoxes), function(verticalBox) {
+ if (verticalBox.getPadding) {
+ var boxPadding = verticalBox.getPadding();
+ maxVerticalTopPadding = Math.max(maxVerticalTopPadding, boxPadding.top);
+ maxVerticalBottomPadding = Math.max(maxVerticalBottomPadding, boxPadding.bottom);
+ }
+ });
+
+ // At this point, maxChartAreaHeight and maxChartAreaWidth are the size the chart area could
+ // be if the axes are drawn at their minimum sizes.
+ // Steps 5 & 6
+ var totalLeftBoxesWidth = leftPadding;
+ var totalRightBoxesWidth = rightPadding;
+ var totalTopBoxesHeight = topPadding;
+ var totalBottomBoxesHeight = bottomPadding;
+
+ // Function to fit a box
+ function fitBox(box) {
+ var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minBox) {
+ return minBox.box === box;
+ });
+
+ if (minBoxSize) {
+ if (box.isHorizontal()) {
+ var scaleMargin = {
+ left: Math.max(totalLeftBoxesWidth, maxHorizontalLeftPadding),
+ right: Math.max(totalRightBoxesWidth, maxHorizontalRightPadding),
+ top: 0,
+ bottom: 0
+ };
+
+ // Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends
+ // on the margin. Sometimes they need to increase in size slightly
+ box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, chartHeight / 2, scaleMargin);
+ } else {
+ box.update(minBoxSize.minSize.width, maxChartAreaHeight);
+ }
+ }
+ }
+
+ // Update, and calculate the left and right margins for the horizontal boxes
+ helpers.each(leftBoxes.concat(rightBoxes), fitBox);
+
+ helpers.each(leftBoxes, function(box) {
+ totalLeftBoxesWidth += box.width;
+ });
+
+ helpers.each(rightBoxes, function(box) {
+ totalRightBoxesWidth += box.width;
+ });
+
+ // Set the Left and Right margins for the horizontal boxes
+ helpers.each(topBoxes.concat(bottomBoxes), fitBox);
+
+ // Figure out how much margin is on the top and bottom of the vertical boxes
+ helpers.each(topBoxes, function(box) {
+ totalTopBoxesHeight += box.height;
+ });
+
+ helpers.each(bottomBoxes, function(box) {
+ totalBottomBoxesHeight += box.height;
+ });
+
+ function finalFitVerticalBox(box) {
+ var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minSize) {
+ return minSize.box === box;
+ });
+
+ var scaleMargin = {
+ left: 0,
+ right: 0,
+ top: totalTopBoxesHeight,
+ bottom: totalBottomBoxesHeight
+ };
+
+ if (minBoxSize) {
+ box.update(minBoxSize.minSize.width, maxChartAreaHeight, scaleMargin);
+ }
+ }
+
+ // Let the left layout know the final margin
+ helpers.each(leftBoxes.concat(rightBoxes), finalFitVerticalBox);
+
+ // Recalculate because the size of each layout might have changed slightly due to the margins (label rotation for instance)
+ totalLeftBoxesWidth = leftPadding;
+ totalRightBoxesWidth = rightPadding;
+ totalTopBoxesHeight = topPadding;
+ totalBottomBoxesHeight = bottomPadding;
+
+ helpers.each(leftBoxes, function(box) {
+ totalLeftBoxesWidth += box.width;
+ });
+
+ helpers.each(rightBoxes, function(box) {
+ totalRightBoxesWidth += box.width;
+ });
+
+ helpers.each(topBoxes, function(box) {
+ totalTopBoxesHeight += box.height;
+ });
+ helpers.each(bottomBoxes, function(box) {
+ totalBottomBoxesHeight += box.height;
+ });
+
+ // We may be adding some padding to account for rotated x axis labels
+ var leftPaddingAddition = Math.max(maxHorizontalLeftPadding - totalLeftBoxesWidth, 0);
+ totalLeftBoxesWidth += leftPaddingAddition;
+ totalRightBoxesWidth += Math.max(maxHorizontalRightPadding - totalRightBoxesWidth, 0);
+
+ var topPaddingAddition = Math.max(maxVerticalTopPadding - totalTopBoxesHeight, 0);
+ totalTopBoxesHeight += topPaddingAddition;
+ totalBottomBoxesHeight += Math.max(maxVerticalBottomPadding - totalBottomBoxesHeight, 0);
+
+ // Figure out if our chart area changed. This would occur if the dataset layout label rotation
+ // changed due to the application of the margins in step 6. Since we can only get bigger, this is safe to do
+ // without calling `fit` again
+ var newMaxChartAreaHeight = height - totalTopBoxesHeight - totalBottomBoxesHeight;
+ var newMaxChartAreaWidth = width - totalLeftBoxesWidth - totalRightBoxesWidth;
+
+ if (newMaxChartAreaWidth !== maxChartAreaWidth || newMaxChartAreaHeight !== maxChartAreaHeight) {
+ helpers.each(leftBoxes, function(box) {
+ box.height = newMaxChartAreaHeight;
+ });
+
+ helpers.each(rightBoxes, function(box) {
+ box.height = newMaxChartAreaHeight;
+ });
+
+ helpers.each(topBoxes, function(box) {
+ if (!box.fullWidth) {
+ box.width = newMaxChartAreaWidth;
+ }
+ });
+
+ helpers.each(bottomBoxes, function(box) {
+ if (!box.fullWidth) {
+ box.width = newMaxChartAreaWidth;
+ }
+ });
+
+ maxChartAreaHeight = newMaxChartAreaHeight;
+ maxChartAreaWidth = newMaxChartAreaWidth;
+ }
+
+ // Step 7 - Position the boxes
+ var left = leftPadding + leftPaddingAddition;
+ var top = topPadding + topPaddingAddition;
+
+ function placeBox(box) {
+ if (box.isHorizontal()) {
+ box.left = box.fullWidth ? leftPadding : totalLeftBoxesWidth;
+ box.right = box.fullWidth ? width - rightPadding : totalLeftBoxesWidth + maxChartAreaWidth;
+ box.top = top;
+ box.bottom = top + box.height;
+
+ // Move to next point
+ top = box.bottom;
+
+ } else {
+
+ box.left = left;
+ box.right = left + box.width;
+ box.top = totalTopBoxesHeight;
+ box.bottom = totalTopBoxesHeight + maxChartAreaHeight;
+
+ // Move to next point
+ left = box.right;
+ }
+ }
+
+ helpers.each(leftBoxes.concat(topBoxes), placeBox);
+
+ // Account for chart width and height
+ left += maxChartAreaWidth;
+ top += maxChartAreaHeight;
+
+ helpers.each(rightBoxes, placeBox);
+ helpers.each(bottomBoxes, placeBox);
+
+ // Step 8
+ chart.chartArea = {
+ left: totalLeftBoxesWidth,
+ top: totalTopBoxesHeight,
+ right: totalLeftBoxesWidth + maxChartAreaWidth,
+ bottom: totalTopBoxesHeight + maxChartAreaHeight
+ };
+
+ // Step 9
+ helpers.each(chartAreaBoxes, function(box) {
+ box.left = chart.chartArea.left;
+ box.top = chart.chartArea.top;
+ box.right = chart.chartArea.right;
+ box.bottom = chart.chartArea.bottom;
+
+ box.update(maxChartAreaWidth, maxChartAreaHeight);
+ });
+ }
+ };
+};
+
+},{"45":45}],31:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ plugins: {}
+});
+
+module.exports = function(Chart) {
+
+ /**
+ * The plugin service singleton
+ * @namespace Chart.plugins
+ * @since 2.1.0
+ */
+ Chart.plugins = {
+ /**
+ * Globally registered plugins.
+ * @private
+ */
+ _plugins: [],
+
+ /**
+ * This identifier is used to invalidate the descriptors cache attached to each chart
+ * when a global plugin is registered or unregistered. In this case, the cache ID is
+ * incremented and descriptors are regenerated during following API calls.
+ * @private
+ */
+ _cacheId: 0,
+
+ /**
+ * Registers the given plugin(s) if not already registered.
+ * @param {Array|Object} plugins plugin instance(s).
+ */
+ register: function(plugins) {
+ var p = this._plugins;
+ ([]).concat(plugins).forEach(function(plugin) {
+ if (p.indexOf(plugin) === -1) {
+ p.push(plugin);
+ }
+ });
+
+ this._cacheId++;
+ },
+
+ /**
+ * Unregisters the given plugin(s) only if registered.
+ * @param {Array|Object} plugins plugin instance(s).
+ */
+ unregister: function(plugins) {
+ var p = this._plugins;
+ ([]).concat(plugins).forEach(function(plugin) {
+ var idx = p.indexOf(plugin);
+ if (idx !== -1) {
+ p.splice(idx, 1);
+ }
+ });
+
+ this._cacheId++;
+ },
+
+ /**
+ * Remove all registered plugins.
+ * @since 2.1.5
+ */
+ clear: function() {
+ this._plugins = [];
+ this._cacheId++;
+ },
+
+ /**
+ * Returns the number of registered plugins?
+ * @returns {Number}
+ * @since 2.1.5
+ */
+ count: function() {
+ return this._plugins.length;
+ },
+
+ /**
+ * Returns all registered plugin instances.
+ * @returns {Array} array of plugin objects.
+ * @since 2.1.5
+ */
+ getAll: function() {
+ return this._plugins;
+ },
+
+ /**
+ * Calls enabled plugins for `chart` on the specified hook and with the given args.
+ * This method immediately returns as soon as a plugin explicitly returns false. The
+ * returned value can be used, for instance, to interrupt the current action.
+ * @param {Object} chart - The chart instance for which plugins should be called.
+ * @param {String} hook - The name of the plugin method to call (e.g. 'beforeUpdate').
+ * @param {Array} [args] - Extra arguments to apply to the hook call.
+ * @returns {Boolean} false if any of the plugins return false, else returns true.
+ */
+ notify: function(chart, hook, args) {
+ var descriptors = this.descriptors(chart);
+ var ilen = descriptors.length;
+ var i, descriptor, plugin, params, method;
+
+ for (i = 0; i < ilen; ++i) {
+ descriptor = descriptors[i];
+ plugin = descriptor.plugin;
+ method = plugin[hook];
+ if (typeof method === 'function') {
+ params = [chart].concat(args || []);
+ params.push(descriptor.options);
+ if (method.apply(plugin, params) === false) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ },
+
+ /**
+ * Returns descriptors of enabled plugins for the given chart.
+ * @returns {Array} [{ plugin, options }]
+ * @private
+ */
+ descriptors: function(chart) {
+ var cache = chart._plugins || (chart._plugins = {});
+ if (cache.id === this._cacheId) {
+ return cache.descriptors;
+ }
+
+ var plugins = [];
+ var descriptors = [];
+ var config = (chart && chart.config) || {};
+ var options = (config.options && config.options.plugins) || {};
+
+ this._plugins.concat(config.plugins || []).forEach(function(plugin) {
+ var idx = plugins.indexOf(plugin);
+ if (idx !== -1) {
+ return;
+ }
+
+ var id = plugin.id;
+ var opts = options[id];
+ if (opts === false) {
+ return;
+ }
+
+ if (opts === true) {
+ opts = helpers.clone(defaults.global.plugins[id]);
+ }
+
+ plugins.push(plugin);
+ descriptors.push({
+ plugin: plugin,
+ options: opts || {}
+ });
+ });
+
+ cache.descriptors = descriptors;
+ cache.id = this._cacheId;
+ return descriptors;
+ }
+ };
+
+ /**
+ * Plugin extension hooks.
+ * @interface IPlugin
+ * @since 2.1.0
+ */
+ /**
+ * @method IPlugin#beforeInit
+ * @desc Called before initializing `chart`.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#afterInit
+ * @desc Called after `chart` has been initialized and before the first update.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeUpdate
+ * @desc Called before updating `chart`. If any plugin returns `false`, the update
+ * is cancelled (and thus subsequent render(s)) until another `update` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart update.
+ */
+ /**
+ * @method IPlugin#afterUpdate
+ * @desc Called after `chart` has been updated and before rendering. Note that this
+ * hook will not be called if the chart update has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDatasetsUpdate
+ * @desc Called before updating the `chart` datasets. If any plugin returns `false`,
+ * the datasets update is cancelled until another `update` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} false to cancel the datasets update.
+ * @since version 2.1.5
+ */
+ /**
+ * @method IPlugin#afterDatasetsUpdate
+ * @desc Called after the `chart` datasets have been updated. Note that this hook
+ * will not be called if the datasets update has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @since version 2.1.5
+ */
+ /**
+ * @method IPlugin#beforeDatasetUpdate
+ * @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
+ * returns `false`, the datasets update is cancelled until another `update` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetUpdate
+ * @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
+ * that this hook will not be called if the datasets update has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeLayout
+ * @desc Called before laying out `chart`. If any plugin returns `false`,
+ * the layout update is cancelled until another `update` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart layout.
+ */
+ /**
+ * @method IPlugin#afterLayout
+ * @desc Called after the `chart` has been layed out. Note that this hook will not
+ * be called if the layout update has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeRender
+ * @desc Called before rendering `chart`. If any plugin returns `false`,
+ * the rendering is cancelled until another `render` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart rendering.
+ */
+ /**
+ * @method IPlugin#afterRender
+ * @desc Called after the `chart` has been fully rendered (and animation completed). Note
+ * that this hook will not be called if the rendering has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDraw
+ * @desc Called before drawing `chart` at every animation frame specified by the given
+ * easing value. If any plugin returns `false`, the frame drawing is cancelled until
+ * another `render` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart drawing.
+ */
+ /**
+ * @method IPlugin#afterDraw
+ * @desc Called after the `chart` has been drawn for the specific easing value. Note
+ * that this hook will not be called if the drawing has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDatasetsDraw
+ * @desc Called before drawing the `chart` datasets. If any plugin returns `false`,
+ * the datasets drawing is cancelled until another `render` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetsDraw
+ * @desc Called after the `chart` datasets have been drawn. Note that this hook
+ * will not be called if the datasets drawing has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDatasetDraw
+ * @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
+ * are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
+ * is cancelled until another `render` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetDraw
+ * @desc Called after the `chart` datasets at the given `args.index` have been drawn
+ * (datasets are drawn in the reverse order). Note that this hook will not be called
+ * if the datasets drawing has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeTooltipDraw
+ * @desc Called before drawing the `tooltip`. If any plugin returns `false`,
+ * the tooltip drawing is cancelled until another `render` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.tooltip - The tooltip.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart tooltip drawing.
+ */
+ /**
+ * @method IPlugin#afterTooltipDraw
+ * @desc Called after drawing the `tooltip`. Note that this hook will not
+ * be called if the tooltip drawing has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.tooltip - The tooltip.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeEvent
+ * @desc Called before processing the specified `event`. If any plugin returns `false`,
+ * the event will be discarded.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {IEvent} event - The event object.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#afterEvent
+ * @desc Called after the `event` has been consumed. Note that this hook
+ * will not be called if the `event` has been previously discarded.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {IEvent} event - The event object.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#resize
+ * @desc Called after the chart as been resized.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} size - The new canvas display size (eq. canvas.style width & height).
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#destroy
+ * @desc Called after the chart as been destroyed.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+
+ /**
+ * Provided for backward compatibility, use Chart.plugins instead
+ * @namespace Chart.pluginService
+ * @deprecated since version 2.1.5
+ * @todo remove at version 3
+ * @private
+ */
+ Chart.pluginService = Chart.plugins;
+
+ /**
+ * Provided for backward compatibility, inheriting from Chart.PlugingBase has no
+ * effect, instead simply create/register plugins via plain JavaScript objects.
+ * @interface Chart.PluginBase
+ * @deprecated since version 2.5.0
+ * @todo remove at version 3
+ * @private
+ */
+ Chart.PluginBase = Element.extend({});
+};
+
+},{"25":25,"26":26,"45":45}],32:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+var Ticks = require(34);
+
+defaults._set('scale', {
+ display: true,
+ position: 'left',
+ offset: false,
+
+ // grid line settings
+ gridLines: {
+ display: true,
+ color: 'rgba(0, 0, 0, 0.1)',
+ lineWidth: 1,
+ drawBorder: true,
+ drawOnChartArea: true,
+ drawTicks: true,
+ tickMarkLength: 10,
+ zeroLineWidth: 1,
+ zeroLineColor: 'rgba(0,0,0,0.25)',
+ zeroLineBorderDash: [],
+ zeroLineBorderDashOffset: 0.0,
+ offsetGridLines: false,
+ borderDash: [],
+ borderDashOffset: 0.0
+ },
+
+ // scale label
+ scaleLabel: {
+ // display property
+ display: false,
+
+ // actual label
+ labelString: '',
+
+ // line height
+ lineHeight: 1.2,
+
+ // top/bottom padding
+ padding: {
+ top: 4,
+ bottom: 4
+ }
+ },
+
+ // label settings
+ ticks: {
+ beginAtZero: false,
+ minRotation: 0,
+ maxRotation: 50,
+ mirror: false,
+ padding: 0,
+ reverse: false,
+ display: true,
+ autoSkip: true,
+ autoSkipPadding: 0,
+ labelOffset: 0,
+ // We pass through arrays to be rendered as multiline labels, we convert Others to strings here.
+ callback: Ticks.formatters.values,
+ minor: {},
+ major: {}
+ }
+});
+
+function labelsFromTicks(ticks) {
+ var labels = [];
+ var i, ilen;
+
+ for (i = 0, ilen = ticks.length; i < ilen; ++i) {
+ labels.push(ticks[i].label);
+ }
+
+ return labels;
+}
+
+function getLineValue(scale, index, offsetGridLines) {
+ var lineValue = scale.getPixelForTick(index);
+
+ if (offsetGridLines) {
+ if (index === 0) {
+ lineValue -= (scale.getPixelForTick(1) - lineValue) / 2;
+ } else {
+ lineValue -= (lineValue - scale.getPixelForTick(index - 1)) / 2;
+ }
+ }
+ return lineValue;
+}
+
+module.exports = function(Chart) {
+
+ function computeTextSize(context, tick, font) {
+ return helpers.isArray(tick) ?
+ helpers.longestText(context, font, tick) :
+ context.measureText(tick).width;
+ }
+
+ function parseFontOptions(options) {
+ var valueOrDefault = helpers.valueOrDefault;
+ var globalDefaults = defaults.global;
+ var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
+ var style = valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle);
+ var family = valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily);
+
+ return {
+ size: size,
+ style: style,
+ family: family,
+ font: helpers.fontString(size, style, family)
+ };
+ }
+
+ function parseLineHeight(options) {
+ return helpers.options.toLineHeight(
+ helpers.valueOrDefault(options.lineHeight, 1.2),
+ helpers.valueOrDefault(options.fontSize, defaults.global.defaultFontSize));
+ }
+
+ Chart.Scale = Element.extend({
+ /**
+ * Get the padding needed for the scale
+ * @method getPadding
+ * @private
+ * @returns {Padding} the necessary padding
+ */
+ getPadding: function() {
+ var me = this;
+ return {
+ left: me.paddingLeft || 0,
+ top: me.paddingTop || 0,
+ right: me.paddingRight || 0,
+ bottom: me.paddingBottom || 0
+ };
+ },
+
+ /**
+ * Returns the scale tick objects ({label, major})
+ * @since 2.7
+ */
+ getTicks: function() {
+ return this._ticks;
+ },
+
+ // These methods are ordered by lifecyle. Utilities then follow.
+ // Any function defined here is inherited by all scale types.
+ // Any function can be extended by the scale type
+
+ mergeTicksOptions: function() {
+ var ticks = this.options.ticks;
+ if (ticks.minor === false) {
+ ticks.minor = {
+ display: false
+ };
+ }
+ if (ticks.major === false) {
+ ticks.major = {
+ display: false
+ };
+ }
+ for (var key in ticks) {
+ if (key !== 'major' && key !== 'minor') {
+ if (typeof ticks.minor[key] === 'undefined') {
+ ticks.minor[key] = ticks[key];
+ }
+ if (typeof ticks.major[key] === 'undefined') {
+ ticks.major[key] = ticks[key];
+ }
+ }
+ }
+ },
+ beforeUpdate: function() {
+ helpers.callback(this.options.beforeUpdate, [this]);
+ },
+ update: function(maxWidth, maxHeight, margins) {
+ var me = this;
+ var i, ilen, labels, label, ticks, tick;
+
+ // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
+ me.beforeUpdate();
+
+ // Absorb the master measurements
+ me.maxWidth = maxWidth;
+ me.maxHeight = maxHeight;
+ me.margins = helpers.extend({
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, margins);
+ me.longestTextCache = me.longestTextCache || {};
+
+ // Dimensions
+ me.beforeSetDimensions();
+ me.setDimensions();
+ me.afterSetDimensions();
+
+ // Data min/max
+ me.beforeDataLimits();
+ me.determineDataLimits();
+ me.afterDataLimits();
+
+ // Ticks - `this.ticks` is now DEPRECATED!
+ // Internal ticks are now stored as objects in the PRIVATE `this._ticks` member
+ // and must not be accessed directly from outside this class. `this.ticks` being
+ // around for long time and not marked as private, we can't change its structure
+ // without unexpected breaking changes. If you need to access the scale ticks,
+ // use scale.getTicks() instead.
+
+ me.beforeBuildTicks();
+
+ // New implementations should return an array of objects but for BACKWARD COMPAT,
+ // we still support no return (`this.ticks` internally set by calling this method).
+ ticks = me.buildTicks() || [];
+
+ me.afterBuildTicks();
+
+ me.beforeTickToLabelConversion();
+
+ // New implementations should return the formatted tick labels but for BACKWARD
+ // COMPAT, we still support no return (`this.ticks` internally changed by calling
+ // this method and supposed to contain only string values).
+ labels = me.convertTicksToLabels(ticks) || me.ticks;
+
+ me.afterTickToLabelConversion();
+
+ me.ticks = labels; // BACKWARD COMPATIBILITY
+
+ // IMPORTANT: from this point, we consider that `this.ticks` will NEVER change!
+
+ // BACKWARD COMPAT: synchronize `_ticks` with labels (so potentially `this.ticks`)
+ for (i = 0, ilen = labels.length; i < ilen; ++i) {
+ label = labels[i];
+ tick = ticks[i];
+ if (!tick) {
+ ticks.push(tick = {
+ label: label,
+ major: false
+ });
+ } else {
+ tick.label = label;
+ }
+ }
+
+ me._ticks = ticks;
+
+ // Tick Rotation
+ me.beforeCalculateTickRotation();
+ me.calculateTickRotation();
+ me.afterCalculateTickRotation();
+ // Fit
+ me.beforeFit();
+ me.fit();
+ me.afterFit();
+ //
+ me.afterUpdate();
+
+ return me.minSize;
+
+ },
+ afterUpdate: function() {
+ helpers.callback(this.options.afterUpdate, [this]);
+ },
+
+ //
+
+ beforeSetDimensions: function() {
+ helpers.callback(this.options.beforeSetDimensions, [this]);
+ },
+ setDimensions: function() {
+ var me = this;
+ // Set the unconstrained dimension before label rotation
+ if (me.isHorizontal()) {
+ // Reset position before calculating rotation
+ me.width = me.maxWidth;
+ me.left = 0;
+ me.right = me.width;
+ } else {
+ me.height = me.maxHeight;
+
+ // Reset position before calculating rotation
+ me.top = 0;
+ me.bottom = me.height;
+ }
+
+ // Reset padding
+ me.paddingLeft = 0;
+ me.paddingTop = 0;
+ me.paddingRight = 0;
+ me.paddingBottom = 0;
+ },
+ afterSetDimensions: function() {
+ helpers.callback(this.options.afterSetDimensions, [this]);
+ },
+
+ // Data limits
+ beforeDataLimits: function() {
+ helpers.callback(this.options.beforeDataLimits, [this]);
+ },
+ determineDataLimits: helpers.noop,
+ afterDataLimits: function() {
+ helpers.callback(this.options.afterDataLimits, [this]);
+ },
+
+ //
+ beforeBuildTicks: function() {
+ helpers.callback(this.options.beforeBuildTicks, [this]);
+ },
+ buildTicks: helpers.noop,
+ afterBuildTicks: function() {
+ helpers.callback(this.options.afterBuildTicks, [this]);
+ },
+
+ beforeTickToLabelConversion: function() {
+ helpers.callback(this.options.beforeTickToLabelConversion, [this]);
+ },
+ convertTicksToLabels: function() {
+ var me = this;
+ // Convert ticks to strings
+ var tickOpts = me.options.ticks;
+ me.ticks = me.ticks.map(tickOpts.userCallback || tickOpts.callback, this);
+ },
+ afterTickToLabelConversion: function() {
+ helpers.callback(this.options.afterTickToLabelConversion, [this]);
+ },
+
+ //
+
+ beforeCalculateTickRotation: function() {
+ helpers.callback(this.options.beforeCalculateTickRotation, [this]);
+ },
+ calculateTickRotation: function() {
+ var me = this;
+ var context = me.ctx;
+ var tickOpts = me.options.ticks;
+ var labels = labelsFromTicks(me._ticks);
+
+ // Get the width of each grid by calculating the difference
+ // between x offsets between 0 and 1.
+ var tickFont = parseFontOptions(tickOpts);
+ context.font = tickFont.font;
+
+ var labelRotation = tickOpts.minRotation || 0;
+
+ if (labels.length && me.options.display && me.isHorizontal()) {
+ var originalLabelWidth = helpers.longestText(context, tickFont.font, labels, me.longestTextCache);
+ var labelWidth = originalLabelWidth;
+ var cosRotation, sinRotation;
+
+ // Allow 3 pixels x2 padding either side for label readability
+ var tickWidth = me.getPixelForTick(1) - me.getPixelForTick(0) - 6;
+
+ // Max label rotation can be set or default to 90 - also act as a loop counter
+ while (labelWidth > tickWidth && labelRotation < tickOpts.maxRotation) {
+ var angleRadians = helpers.toRadians(labelRotation);
+ cosRotation = Math.cos(angleRadians);
+ sinRotation = Math.sin(angleRadians);
+
+ if (sinRotation * originalLabelWidth > me.maxHeight) {
+ // go back one step
+ labelRotation--;
+ break;
+ }
+
+ labelRotation++;
+ labelWidth = cosRotation * originalLabelWidth;
+ }
+ }
+
+ me.labelRotation = labelRotation;
+ },
+ afterCalculateTickRotation: function() {
+ helpers.callback(this.options.afterCalculateTickRotation, [this]);
+ },
+
+ //
+
+ beforeFit: function() {
+ helpers.callback(this.options.beforeFit, [this]);
+ },
+ fit: function() {
+ var me = this;
+ // Reset
+ var minSize = me.minSize = {
+ width: 0,
+ height: 0
+ };
+
+ var labels = labelsFromTicks(me._ticks);
+
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ var scaleLabelOpts = opts.scaleLabel;
+ var gridLineOpts = opts.gridLines;
+ var display = opts.display;
+ var isHorizontal = me.isHorizontal();
+
+ var tickFont = parseFontOptions(tickOpts);
+ var tickMarkLength = opts.gridLines.tickMarkLength;
+
+ // Width
+ if (isHorizontal) {
+ // subtract the margins to line up with the chartArea if we are a full width scale
+ minSize.width = me.isFullWidth() ? me.maxWidth - me.margins.left - me.margins.right : me.maxWidth;
+ } else {
+ minSize.width = display && gridLineOpts.drawTicks ? tickMarkLength : 0;
+ }
+
+ // height
+ if (isHorizontal) {
+ minSize.height = display && gridLineOpts.drawTicks ? tickMarkLength : 0;
+ } else {
+ minSize.height = me.maxHeight; // fill all the height
+ }
+
+ // Are we showing a title for the scale?
+ if (scaleLabelOpts.display && display) {
+ var scaleLabelLineHeight = parseLineHeight(scaleLabelOpts);
+ var scaleLabelPadding = helpers.options.toPadding(scaleLabelOpts.padding);
+ var deltaHeight = scaleLabelLineHeight + scaleLabelPadding.height;
+
+ if (isHorizontal) {
+ minSize.height += deltaHeight;
+ } else {
+ minSize.width += deltaHeight;
+ }
+ }
+
+ // Don't bother fitting the ticks if we are not showing them
+ if (tickOpts.display && display) {
+ var largestTextWidth = helpers.longestText(me.ctx, tickFont.font, labels, me.longestTextCache);
+ var tallestLabelHeightInLines = helpers.numberOfLabelLines(labels);
+ var lineSpace = tickFont.size * 0.5;
+ var tickPadding = me.options.ticks.padding;
+
+ if (isHorizontal) {
+ // A horizontal axis is more constrained by the height.
+ me.longestLabelWidth = largestTextWidth;
+
+ var angleRadians = helpers.toRadians(me.labelRotation);
+ var cosRotation = Math.cos(angleRadians);
+ var sinRotation = Math.sin(angleRadians);
+
+ // TODO - improve this calculation
+ var labelHeight = (sinRotation * largestTextWidth)
+ + (tickFont.size * tallestLabelHeightInLines)
+ + (lineSpace * (tallestLabelHeightInLines - 1))
+ + lineSpace; // padding
+
+ minSize.height = Math.min(me.maxHeight, minSize.height + labelHeight + tickPadding);
+
+ me.ctx.font = tickFont.font;
+ var firstLabelWidth = computeTextSize(me.ctx, labels[0], tickFont.font);
+ var lastLabelWidth = computeTextSize(me.ctx, labels[labels.length - 1], tickFont.font);
+
+ // Ensure that our ticks are always inside the canvas. When rotated, ticks are right aligned
+ // which means that the right padding is dominated by the font height
+ if (me.labelRotation !== 0) {
+ me.paddingLeft = opts.position === 'bottom' ? (cosRotation * firstLabelWidth) + 3 : (cosRotation * lineSpace) + 3; // add 3 px to move away from canvas edges
+ me.paddingRight = opts.position === 'bottom' ? (cosRotation * lineSpace) + 3 : (cosRotation * lastLabelWidth) + 3;
+ } else {
+ me.paddingLeft = firstLabelWidth / 2 + 3; // add 3 px to move away from canvas edges
+ me.paddingRight = lastLabelWidth / 2 + 3;
+ }
+ } else {
+ // A vertical axis is more constrained by the width. Labels are the
+ // dominant factor here, so get that length first and account for padding
+ if (tickOpts.mirror) {
+ largestTextWidth = 0;
+ } else {
+ // use lineSpace for consistency with horizontal axis
+ // tickPadding is not implemented for horizontal
+ largestTextWidth += tickPadding + lineSpace;
+ }
+
+ minSize.width = Math.min(me.maxWidth, minSize.width + largestTextWidth);
+
+ me.paddingTop = tickFont.size / 2;
+ me.paddingBottom = tickFont.size / 2;
+ }
+ }
+
+ me.handleMargins();
+
+ me.width = minSize.width;
+ me.height = minSize.height;
+ },
+
+ /**
+ * Handle margins and padding interactions
+ * @private
+ */
+ handleMargins: function() {
+ var me = this;
+ if (me.margins) {
+ me.paddingLeft = Math.max(me.paddingLeft - me.margins.left, 0);
+ me.paddingTop = Math.max(me.paddingTop - me.margins.top, 0);
+ me.paddingRight = Math.max(me.paddingRight - me.margins.right, 0);
+ me.paddingBottom = Math.max(me.paddingBottom - me.margins.bottom, 0);
+ }
+ },
+
+ afterFit: function() {
+ helpers.callback(this.options.afterFit, [this]);
+ },
+
+ // Shared Methods
+ isHorizontal: function() {
+ return this.options.position === 'top' || this.options.position === 'bottom';
+ },
+ isFullWidth: function() {
+ return (this.options.fullWidth);
+ },
+
+ // Get the correct value. NaN bad inputs, If the value type is object get the x or y based on whether we are horizontal or not
+ getRightValue: function(rawValue) {
+ // Null and undefined values first
+ if (helpers.isNullOrUndef(rawValue)) {
+ return NaN;
+ }
+ // isNaN(object) returns true, so make sure NaN is checking for a number; Discard Infinite values
+ if (typeof rawValue === 'number' && !isFinite(rawValue)) {
+ return NaN;
+ }
+ // If it is in fact an object, dive in one more level
+ if (rawValue) {
+ if (this.isHorizontal()) {
+ if (rawValue.x !== undefined) {
+ return this.getRightValue(rawValue.x);
+ }
+ } else if (rawValue.y !== undefined) {
+ return this.getRightValue(rawValue.y);
+ }
+ }
+
+ // Value is good, return it
+ return rawValue;
+ },
+
+ /**
+ * Used to get the value to display in the tooltip for the data at the given index
+ * @param index
+ * @param datasetIndex
+ */
+ getLabelForIndex: helpers.noop,
+
+ /**
+ * Returns the location of the given data point. Value can either be an index or a numerical value
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ * @param value
+ * @param index
+ * @param datasetIndex
+ */
+ getPixelForValue: helpers.noop,
+
+ /**
+ * Used to get the data value from a given pixel. This is the inverse of getPixelForValue
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ * @param pixel
+ */
+ getValueForPixel: helpers.noop,
+
+ /**
+ * Returns the location of the tick at the given index
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
+ getPixelForTick: function(index) {
+ var me = this;
+ var offset = me.options.offset;
+ if (me.isHorizontal()) {
+ var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
+ var tickWidth = innerWidth / Math.max((me._ticks.length - (offset ? 0 : 1)), 1);
+ var pixel = (tickWidth * index) + me.paddingLeft;
+
+ if (offset) {
+ pixel += tickWidth / 2;
+ }
+
+ var finalVal = me.left + Math.round(pixel);
+ finalVal += me.isFullWidth() ? me.margins.left : 0;
+ return finalVal;
+ }
+ var innerHeight = me.height - (me.paddingTop + me.paddingBottom);
+ return me.top + (index * (innerHeight / (me._ticks.length - 1)));
+ },
+
+ /**
+ * Utility for getting the pixel location of a percentage of scale
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
+ getPixelForDecimal: function(decimal) {
+ var me = this;
+ if (me.isHorizontal()) {
+ var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
+ var valueOffset = (innerWidth * decimal) + me.paddingLeft;
+
+ var finalVal = me.left + Math.round(valueOffset);
+ finalVal += me.isFullWidth() ? me.margins.left : 0;
+ return finalVal;
+ }
+ return me.top + (decimal * me.height);
+ },
+
+ /**
+ * Returns the pixel for the minimum chart value
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
+ getBasePixel: function() {
+ return this.getPixelForValue(this.getBaseValue());
+ },
+
+ getBaseValue: function() {
+ var me = this;
+ var min = me.min;
+ var max = me.max;
+
+ return me.beginAtZero ? 0 :
+ min < 0 && max < 0 ? max :
+ min > 0 && max > 0 ? min :
+ 0;
+ },
+
+ /**
+ * Returns a subset of ticks to be plotted to avoid overlapping labels.
+ * @private
+ */
+ _autoSkip: function(ticks) {
+ var skipRatio;
+ var me = this;
+ var isHorizontal = me.isHorizontal();
+ var optionTicks = me.options.ticks.minor;
+ var tickCount = ticks.length;
+ var labelRotationRadians = helpers.toRadians(me.labelRotation);
+ var cosRotation = Math.cos(labelRotationRadians);
+ var longestRotatedLabel = me.longestLabelWidth * cosRotation;
+ var result = [];
+ var i, tick, shouldSkip;
+
+ // figure out the maximum number of gridlines to show
+ var maxTicks;
+ if (optionTicks.maxTicksLimit) {
+ maxTicks = optionTicks.maxTicksLimit;
+ }
+
+ if (isHorizontal) {
+ skipRatio = false;
+
+ if ((longestRotatedLabel + optionTicks.autoSkipPadding) * tickCount > (me.width - (me.paddingLeft + me.paddingRight))) {
+ skipRatio = 1 + Math.floor(((longestRotatedLabel + optionTicks.autoSkipPadding) * tickCount) / (me.width - (me.paddingLeft + me.paddingRight)));
+ }
+
+ // if they defined a max number of optionTicks,
+ // increase skipRatio until that number is met
+ if (maxTicks && tickCount > maxTicks) {
+ skipRatio = Math.max(skipRatio, Math.floor(tickCount / maxTicks));
+ }
+ }
+
+ for (i = 0; i < tickCount; i++) {
+ tick = ticks[i];
+
+ // Since we always show the last tick,we need may need to hide the last shown one before
+ shouldSkip = (skipRatio > 1 && i % skipRatio > 0) || (i % skipRatio === 0 && i + skipRatio >= tickCount);
+ if (shouldSkip && i !== tickCount - 1) {
+ // leave tick in place but make sure it's not displayed (#4635)
+ delete tick.label;
+ }
+ result.push(tick);
+ }
+ return result;
+ },
+
+ // Actually draw the scale on the canvas
+ // @param {rectangle} chartArea : the area of the chart to draw full grid lines on
+ draw: function(chartArea) {
+ var me = this;
+ var options = me.options;
+ if (!options.display) {
+ return;
+ }
+
+ var context = me.ctx;
+ var globalDefaults = defaults.global;
+ var optionTicks = options.ticks.minor;
+ var optionMajorTicks = options.ticks.major || optionTicks;
+ var gridLines = options.gridLines;
+ var scaleLabel = options.scaleLabel;
+
+ var isRotated = me.labelRotation !== 0;
+ var isHorizontal = me.isHorizontal();
+
+ var ticks = optionTicks.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
+ var tickFontColor = helpers.valueOrDefault(optionTicks.fontColor, globalDefaults.defaultFontColor);
+ var tickFont = parseFontOptions(optionTicks);
+ var majorTickFontColor = helpers.valueOrDefault(optionMajorTicks.fontColor, globalDefaults.defaultFontColor);
+ var majorTickFont = parseFontOptions(optionMajorTicks);
+
+ var tl = gridLines.drawTicks ? gridLines.tickMarkLength : 0;
+
+ var scaleLabelFontColor = helpers.valueOrDefault(scaleLabel.fontColor, globalDefaults.defaultFontColor);
+ var scaleLabelFont = parseFontOptions(scaleLabel);
+ var scaleLabelPadding = helpers.options.toPadding(scaleLabel.padding);
+ var labelRotationRadians = helpers.toRadians(me.labelRotation);
+
+ var itemsToDraw = [];
+
+ var xTickStart = options.position === 'right' ? me.left : me.right - tl;
+ var xTickEnd = options.position === 'right' ? me.left + tl : me.right;
+ var yTickStart = options.position === 'bottom' ? me.top : me.bottom - tl;
+ var yTickEnd = options.position === 'bottom' ? me.top + tl : me.bottom;
+
+ helpers.each(ticks, function(tick, index) {
+ // autoskipper skipped this tick (#4635)
+ if (helpers.isNullOrUndef(tick.label)) {
+ return;
+ }
+
+ var label = tick.label;
+ var lineWidth, lineColor, borderDash, borderDashOffset;
+ if (index === me.zeroLineIndex && options.offset === gridLines.offsetGridLines) {
+ // Draw the first index specially
+ lineWidth = gridLines.zeroLineWidth;
+ lineColor = gridLines.zeroLineColor;
+ borderDash = gridLines.zeroLineBorderDash;
+ borderDashOffset = gridLines.zeroLineBorderDashOffset;
+ } else {
+ lineWidth = helpers.valueAtIndexOrDefault(gridLines.lineWidth, index);
+ lineColor = helpers.valueAtIndexOrDefault(gridLines.color, index);
+ borderDash = helpers.valueOrDefault(gridLines.borderDash, globalDefaults.borderDash);
+ borderDashOffset = helpers.valueOrDefault(gridLines.borderDashOffset, globalDefaults.borderDashOffset);
+ }
+
+ // Common properties
+ var tx1, ty1, tx2, ty2, x1, y1, x2, y2, labelX, labelY;
+ var textAlign = 'middle';
+ var textBaseline = 'middle';
+ var tickPadding = optionTicks.padding;
+
+ if (isHorizontal) {
+ var labelYOffset = tl + tickPadding;
+
+ if (options.position === 'bottom') {
+ // bottom
+ textBaseline = !isRotated ? 'top' : 'middle';
+ textAlign = !isRotated ? 'center' : 'right';
+ labelY = me.top + labelYOffset;
+ } else {
+ // top
+ textBaseline = !isRotated ? 'bottom' : 'middle';
+ textAlign = !isRotated ? 'center' : 'left';
+ labelY = me.bottom - labelYOffset;
+ }
+
+ var xLineValue = getLineValue(me, index, gridLines.offsetGridLines && ticks.length > 1);
+ if (xLineValue < me.left) {
+ lineColor = 'rgba(0,0,0,0)';
+ }
+ xLineValue += helpers.aliasPixel(lineWidth);
+
+ labelX = me.getPixelForTick(index) + optionTicks.labelOffset; // x values for optionTicks (need to consider offsetLabel option)
+
+ tx1 = tx2 = x1 = x2 = xLineValue;
+ ty1 = yTickStart;
+ ty2 = yTickEnd;
+ y1 = chartArea.top;
+ y2 = chartArea.bottom;
+ } else {
+ var isLeft = options.position === 'left';
+ var labelXOffset;
+
+ if (optionTicks.mirror) {
+ textAlign = isLeft ? 'left' : 'right';
+ labelXOffset = tickPadding;
+ } else {
+ textAlign = isLeft ? 'right' : 'left';
+ labelXOffset = tl + tickPadding;
+ }
+
+ labelX = isLeft ? me.right - labelXOffset : me.left + labelXOffset;
+
+ var yLineValue = getLineValue(me, index, gridLines.offsetGridLines && ticks.length > 1);
+ if (yLineValue < me.top) {
+ lineColor = 'rgba(0,0,0,0)';
+ }
+ yLineValue += helpers.aliasPixel(lineWidth);
+
+ labelY = me.getPixelForTick(index) + optionTicks.labelOffset;
+
+ tx1 = xTickStart;
+ tx2 = xTickEnd;
+ x1 = chartArea.left;
+ x2 = chartArea.right;
+ ty1 = ty2 = y1 = y2 = yLineValue;
+ }
+
+ itemsToDraw.push({
+ tx1: tx1,
+ ty1: ty1,
+ tx2: tx2,
+ ty2: ty2,
+ x1: x1,
+ y1: y1,
+ x2: x2,
+ y2: y2,
+ labelX: labelX,
+ labelY: labelY,
+ glWidth: lineWidth,
+ glColor: lineColor,
+ glBorderDash: borderDash,
+ glBorderDashOffset: borderDashOffset,
+ rotation: -1 * labelRotationRadians,
+ label: label,
+ major: tick.major,
+ textBaseline: textBaseline,
+ textAlign: textAlign
+ });
+ });
+
+ // Draw all of the tick labels, tick marks, and grid lines at the correct places
+ helpers.each(itemsToDraw, function(itemToDraw) {
+ if (gridLines.display) {
+ context.save();
+ context.lineWidth = itemToDraw.glWidth;
+ context.strokeStyle = itemToDraw.glColor;
+ if (context.setLineDash) {
+ context.setLineDash(itemToDraw.glBorderDash);
+ context.lineDashOffset = itemToDraw.glBorderDashOffset;
+ }
+
+ context.beginPath();
+
+ if (gridLines.drawTicks) {
+ context.moveTo(itemToDraw.tx1, itemToDraw.ty1);
+ context.lineTo(itemToDraw.tx2, itemToDraw.ty2);
+ }
+
+ if (gridLines.drawOnChartArea) {
+ context.moveTo(itemToDraw.x1, itemToDraw.y1);
+ context.lineTo(itemToDraw.x2, itemToDraw.y2);
+ }
+
+ context.stroke();
+ context.restore();
+ }
+
+ if (optionTicks.display) {
+ // Make sure we draw text in the correct color and font
+ context.save();
+ context.translate(itemToDraw.labelX, itemToDraw.labelY);
+ context.rotate(itemToDraw.rotation);
+ context.font = itemToDraw.major ? majorTickFont.font : tickFont.font;
+ context.fillStyle = itemToDraw.major ? majorTickFontColor : tickFontColor;
+ context.textBaseline = itemToDraw.textBaseline;
+ context.textAlign = itemToDraw.textAlign;
+
+ var label = itemToDraw.label;
+ if (helpers.isArray(label)) {
+ for (var i = 0, y = 0; i < label.length; ++i) {
+ // We just make sure the multiline element is a string here..
+ context.fillText('' + label[i], 0, y);
+ // apply same lineSpacing as calculated @ L#320
+ y += (tickFont.size * 1.5);
+ }
+ } else {
+ context.fillText(label, 0, 0);
+ }
+ context.restore();
+ }
+ });
+
+ if (scaleLabel.display) {
+ // Draw the scale label
+ var scaleLabelX;
+ var scaleLabelY;
+ var rotation = 0;
+ var halfLineHeight = parseLineHeight(scaleLabel) / 2;
+
+ if (isHorizontal) {
+ scaleLabelX = me.left + ((me.right - me.left) / 2); // midpoint of the width
+ scaleLabelY = options.position === 'bottom'
+ ? me.bottom - halfLineHeight - scaleLabelPadding.bottom
+ : me.top + halfLineHeight + scaleLabelPadding.top;
+ } else {
+ var isLeft = options.position === 'left';
+ scaleLabelX = isLeft
+ ? me.left + halfLineHeight + scaleLabelPadding.top
+ : me.right - halfLineHeight - scaleLabelPadding.top;
+ scaleLabelY = me.top + ((me.bottom - me.top) / 2);
+ rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;
+ }
+
+ context.save();
+ context.translate(scaleLabelX, scaleLabelY);
+ context.rotate(rotation);
+ context.textAlign = 'center';
+ context.textBaseline = 'middle';
+ context.fillStyle = scaleLabelFontColor; // render in correct colour
+ context.font = scaleLabelFont.font;
+ context.fillText(scaleLabel.labelString, 0, 0);
+ context.restore();
+ }
+
+ if (gridLines.drawBorder) {
+ // Draw the line at the edge of the axis
+ context.lineWidth = helpers.valueAtIndexOrDefault(gridLines.lineWidth, 0);
+ context.strokeStyle = helpers.valueAtIndexOrDefault(gridLines.color, 0);
+ var x1 = me.left;
+ var x2 = me.right;
+ var y1 = me.top;
+ var y2 = me.bottom;
+
+ var aliasPixel = helpers.aliasPixel(context.lineWidth);
+ if (isHorizontal) {
+ y1 = y2 = options.position === 'top' ? me.bottom : me.top;
+ y1 += aliasPixel;
+ y2 += aliasPixel;
+ } else {
+ x1 = x2 = options.position === 'left' ? me.right : me.left;
+ x1 += aliasPixel;
+ x2 += aliasPixel;
+ }
+
+ context.beginPath();
+ context.moveTo(x1, y1);
+ context.lineTo(x2, y2);
+ context.stroke();
+ }
+ }
+ });
+};
+
+},{"25":25,"26":26,"34":34,"45":45}],33:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ Chart.scaleService = {
+ // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then
+ // use the new chart options to grab the correct scale
+ constructors: {},
+ // Use a registration function so that we can move to an ES6 map when we no longer need to support
+ // old browsers
+
+ // Scale config defaults
+ defaults: {},
+ registerScaleType: function(type, scaleConstructor, scaleDefaults) {
+ this.constructors[type] = scaleConstructor;
+ this.defaults[type] = helpers.clone(scaleDefaults);
+ },
+ getScaleConstructor: function(type) {
+ return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined;
+ },
+ getScaleDefaults: function(type) {
+ // Return the scale defaults merged with the global settings so that we always use the latest ones
+ return this.defaults.hasOwnProperty(type) ? helpers.merge({}, [defaults.scale, this.defaults[type]]) : {};
+ },
+ updateScaleDefaults: function(type, additions) {
+ var me = this;
+ if (me.defaults.hasOwnProperty(type)) {
+ me.defaults[type] = helpers.extend(me.defaults[type], additions);
+ }
+ },
+ addScalesToLayout: function(chart) {
+ // Adds each scale to the chart.boxes array to be sized accordingly
+ helpers.each(chart.scales, function(scale) {
+ // Set ILayoutItem parameters for backwards compatibility
+ scale.fullWidth = scale.options.fullWidth;
+ scale.position = scale.options.position;
+ scale.weight = scale.options.weight;
+ Chart.layoutService.addBox(chart, scale);
+ });
+ }
+ };
+};
+
+},{"25":25,"45":45}],34:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+/**
+ * Namespace to hold static tick generation functions
+ * @namespace Chart.Ticks
+ */
+module.exports = {
+ /**
+ * Namespace to hold generators for different types of ticks
+ * @namespace Chart.Ticks.generators
+ */
+ generators: {
+ /**
+ * Interface for the options provided to the numeric tick generator
+ * @interface INumericTickGenerationOptions
+ */
+ /**
+ * The maximum number of ticks to display
+ * @name INumericTickGenerationOptions#maxTicks
+ * @type Number
+ */
+ /**
+ * The distance between each tick.
+ * @name INumericTickGenerationOptions#stepSize
+ * @type Number
+ * @optional
+ */
+ /**
+ * Forced minimum for the ticks. If not specified, the minimum of the data range is used to calculate the tick minimum
+ * @name INumericTickGenerationOptions#min
+ * @type Number
+ * @optional
+ */
+ /**
+ * The maximum value of the ticks. If not specified, the maximum of the data range is used to calculate the tick maximum
+ * @name INumericTickGenerationOptions#max
+ * @type Number
+ * @optional
+ */
+
+ /**
+ * Generate a set of linear ticks
+ * @method Chart.Ticks.generators.linear
+ * @param generationOptions {INumericTickGenerationOptions} the options used to generate the ticks
+ * @param dataRange {IRange} the range of the data
+ * @returns {Array<Number>} array of tick values
+ */
+ linear: function(generationOptions, dataRange) {
+ var ticks = [];
+ // To get a "nice" value for the tick spacing, we will use the appropriately named
+ // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
+ // for details.
+
+ var spacing;
+ if (generationOptions.stepSize && generationOptions.stepSize > 0) {
+ spacing = generationOptions.stepSize;
+ } else {
+ var niceRange = helpers.niceNum(dataRange.max - dataRange.min, false);
+ spacing = helpers.niceNum(niceRange / (generationOptions.maxTicks - 1), true);
+ }
+ var niceMin = Math.floor(dataRange.min / spacing) * spacing;
+ var niceMax = Math.ceil(dataRange.max / spacing) * spacing;
+
+ // If min, max and stepSize is set and they make an evenly spaced scale use it.
+ if (generationOptions.min && generationOptions.max && generationOptions.stepSize) {
+ // If very close to our whole number, use it.
+ if (helpers.almostWhole((generationOptions.max - generationOptions.min) / generationOptions.stepSize, spacing / 1000)) {
+ niceMin = generationOptions.min;
+ niceMax = generationOptions.max;
+ }
+ }
+
+ var numSpaces = (niceMax - niceMin) / spacing;
+ // If very close to our rounded value, use it.
+ if (helpers.almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) {
+ numSpaces = Math.round(numSpaces);
+ } else {
+ numSpaces = Math.ceil(numSpaces);
+ }
+
+ // Put the values into the ticks array
+ ticks.push(generationOptions.min !== undefined ? generationOptions.min : niceMin);
+ for (var j = 1; j < numSpaces; ++j) {
+ ticks.push(niceMin + (j * spacing));
+ }
+ ticks.push(generationOptions.max !== undefined ? generationOptions.max : niceMax);
+
+ return ticks;
+ },
+
+ /**
+ * Generate a set of logarithmic ticks
+ * @method Chart.Ticks.generators.logarithmic
+ * @param generationOptions {INumericTickGenerationOptions} the options used to generate the ticks
+ * @param dataRange {IRange} the range of the data
+ * @returns {Array<Number>} array of tick values
+ */
+ logarithmic: function(generationOptions, dataRange) {
+ var ticks = [];
+ var valueOrDefault = helpers.valueOrDefault;
+
+ // Figure out what the max number of ticks we can support it is based on the size of
+ // the axis area. For now, we say that the minimum tick spacing in pixels must be 50
+ // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
+ // the graph
+ var tickVal = valueOrDefault(generationOptions.min, Math.pow(10, Math.floor(helpers.log10(dataRange.min))));
+
+ var endExp = Math.floor(helpers.log10(dataRange.max));
+ var endSignificand = Math.ceil(dataRange.max / Math.pow(10, endExp));
+ var exp, significand;
+
+ if (tickVal === 0) {
+ exp = Math.floor(helpers.log10(dataRange.minNotZero));
+ significand = Math.floor(dataRange.minNotZero / Math.pow(10, exp));
+
+ ticks.push(tickVal);
+ tickVal = significand * Math.pow(10, exp);
+ } else {
+ exp = Math.floor(helpers.log10(tickVal));
+ significand = Math.floor(tickVal / Math.pow(10, exp));
+ }
+
+ do {
+ ticks.push(tickVal);
+
+ ++significand;
+ if (significand === 10) {
+ significand = 1;
+ ++exp;
+ }
+
+ tickVal = significand * Math.pow(10, exp);
+ } while (exp < endExp || (exp === endExp && significand < endSignificand));
+
+ var lastTick = valueOrDefault(generationOptions.max, tickVal);
+ ticks.push(lastTick);
+
+ return ticks;
+ }
+ },
+
+ /**
+ * Namespace to hold formatters for different types of ticks
+ * @namespace Chart.Ticks.formatters
+ */
+ formatters: {
+ /**
+ * Formatter for value labels
+ * @method Chart.Ticks.formatters.values
+ * @param value the value to display
+ * @return {String|Array} the label to display
+ */
+ values: function(value) {
+ return helpers.isArray(value) ? value : '' + value;
+ },
+
+ /**
+ * Formatter for linear numeric ticks
+ * @method Chart.Ticks.formatters.linear
+ * @param tickValue {Number} the value to be formatted
+ * @param index {Number} the position of the tickValue parameter in the ticks array
+ * @param ticks {Array<Number>} the list of ticks being converted
+ * @return {String} string representation of the tickValue parameter
+ */
+ linear: function(tickValue, index, ticks) {
+ // If we have lots of ticks, don't use the ones
+ var delta = ticks.length > 3 ? ticks[2] - ticks[1] : ticks[1] - ticks[0];
+
+ // If we have a number like 2.5 as the delta, figure out how many decimal places we need
+ if (Math.abs(delta) > 1) {
+ if (tickValue !== Math.floor(tickValue)) {
+ // not an integer
+ delta = tickValue - Math.floor(tickValue);
+ }
+ }
+
+ var logDelta = helpers.log10(Math.abs(delta));
+ var tickString = '';
+
+ if (tickValue !== 0) {
+ var numDecimal = -1 * Math.floor(logDelta);
+ numDecimal = Math.max(Math.min(numDecimal, 20), 0); // toFixed has a max of 20 decimal places
+ tickString = tickValue.toFixed(numDecimal);
+ } else {
+ tickString = '0'; // never show decimal places for 0
+ }
+
+ return tickString;
+ },
+
+ logarithmic: function(tickValue, index, ticks) {
+ var remain = tickValue / (Math.pow(10, Math.floor(helpers.log10(tickValue))));
+
+ if (tickValue === 0) {
+ return '0';
+ } else if (remain === 1 || remain === 2 || remain === 5 || index === 0 || index === ticks.length - 1) {
+ return tickValue.toExponential();
+ }
+ return '';
+ }
+ }
+};
+
+},{"45":45}],35:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ tooltips: {
+ enabled: true,
+ custom: null,
+ mode: 'nearest',
+ position: 'average',
+ intersect: true,
+ backgroundColor: 'rgba(0,0,0,0.8)',
+ titleFontStyle: 'bold',
+ titleSpacing: 2,
+ titleMarginBottom: 6,
+ titleFontColor: '#fff',
+ titleAlign: 'left',
+ bodySpacing: 2,
+ bodyFontColor: '#fff',
+ bodyAlign: 'left',
+ footerFontStyle: 'bold',
+ footerSpacing: 2,
+ footerMarginTop: 6,
+ footerFontColor: '#fff',
+ footerAlign: 'left',
+ yPadding: 6,
+ xPadding: 6,
+ caretPadding: 2,
+ caretSize: 5,
+ cornerRadius: 6,
+ multiKeyBackground: '#fff',
+ displayColors: true,
+ borderColor: 'rgba(0,0,0,0)',
+ borderWidth: 0,
+ callbacks: {
+ // Args are: (tooltipItems, data)
+ beforeTitle: helpers.noop,
+ title: function(tooltipItems, data) {
+ // Pick first xLabel for now
+ var title = '';
+ var labels = data.labels;
+ var labelCount = labels ? labels.length : 0;
+
+ if (tooltipItems.length > 0) {
+ var item = tooltipItems[0];
+
+ if (item.xLabel) {
+ title = item.xLabel;
+ } else if (labelCount > 0 && item.index < labelCount) {
+ title = labels[item.index];
+ }
+ }
+
+ return title;
+ },
+ afterTitle: helpers.noop,
+
+ // Args are: (tooltipItems, data)
+ beforeBody: helpers.noop,
+
+ // Args are: (tooltipItem, data)
+ beforeLabel: helpers.noop,
+ label: function(tooltipItem, data) {
+ var label = data.datasets[tooltipItem.datasetIndex].label || '';
+
+ if (label) {
+ label += ': ';
+ }
+ label += tooltipItem.yLabel;
+ return label;
+ },
+ labelColor: function(tooltipItem, chart) {
+ var meta = chart.getDatasetMeta(tooltipItem.datasetIndex);
+ var activeElement = meta.data[tooltipItem.index];
+ var view = activeElement._view;
+ return {
+ borderColor: view.borderColor,
+ backgroundColor: view.backgroundColor
+ };
+ },
+ labelTextColor: function() {
+ return this._options.bodyFontColor;
+ },
+ afterLabel: helpers.noop,
+
+ // Args are: (tooltipItems, data)
+ afterBody: helpers.noop,
+
+ // Args are: (tooltipItems, data)
+ beforeFooter: helpers.noop,
+ footer: helpers.noop,
+ afterFooter: helpers.noop
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ /**
+ * Helper method to merge the opacity into a color
+ */
+ function mergeOpacity(colorString, opacity) {
+ var color = helpers.color(colorString);
+ return color.alpha(opacity * color.alpha()).rgbaString();
+ }
+
+ // Helper to push or concat based on if the 2nd parameter is an array or not
+ function pushOrConcat(base, toPush) {
+ if (toPush) {
+ if (helpers.isArray(toPush)) {
+ // base = base.concat(toPush);
+ Array.prototype.push.apply(base, toPush);
+ } else {
+ base.push(toPush);
+ }
+ }
+
+ return base;
+ }
+
+ // Private helper to create a tooltip item model
+ // @param element : the chart element (point, arc, bar) to create the tooltip item for
+ // @return : new tooltip item
+ function createTooltipItem(element) {
+ var xScale = element._xScale;
+ var yScale = element._yScale || element._scale; // handle radar || polarArea charts
+ var index = element._index;
+ var datasetIndex = element._datasetIndex;
+
+ return {
+ xLabel: xScale ? xScale.getLabelForIndex(index, datasetIndex) : '',
+ yLabel: yScale ? yScale.getLabelForIndex(index, datasetIndex) : '',
+ index: index,
+ datasetIndex: datasetIndex,
+ x: element._model.x,
+ y: element._model.y
+ };
+ }
+
+ /**
+ * Helper to get the reset model for the tooltip
+ * @param tooltipOpts {Object} the tooltip options
+ */
+ function getBaseModel(tooltipOpts) {
+ var globalDefaults = defaults.global;
+ var valueOrDefault = helpers.valueOrDefault;
+
+ return {
+ // Positioning
+ xPadding: tooltipOpts.xPadding,
+ yPadding: tooltipOpts.yPadding,
+ xAlign: tooltipOpts.xAlign,
+ yAlign: tooltipOpts.yAlign,
+
+ // Body
+ bodyFontColor: tooltipOpts.bodyFontColor,
+ _bodyFontFamily: valueOrDefault(tooltipOpts.bodyFontFamily, globalDefaults.defaultFontFamily),
+ _bodyFontStyle: valueOrDefault(tooltipOpts.bodyFontStyle, globalDefaults.defaultFontStyle),
+ _bodyAlign: tooltipOpts.bodyAlign,
+ bodyFontSize: valueOrDefault(tooltipOpts.bodyFontSize, globalDefaults.defaultFontSize),
+ bodySpacing: tooltipOpts.bodySpacing,
+
+ // Title
+ titleFontColor: tooltipOpts.titleFontColor,
+ _titleFontFamily: valueOrDefault(tooltipOpts.titleFontFamily, globalDefaults.defaultFontFamily),
+ _titleFontStyle: valueOrDefault(tooltipOpts.titleFontStyle, globalDefaults.defaultFontStyle),
+ titleFontSize: valueOrDefault(tooltipOpts.titleFontSize, globalDefaults.defaultFontSize),
+ _titleAlign: tooltipOpts.titleAlign,
+ titleSpacing: tooltipOpts.titleSpacing,
+ titleMarginBottom: tooltipOpts.titleMarginBottom,
+
+ // Footer
+ footerFontColor: tooltipOpts.footerFontColor,
+ _footerFontFamily: valueOrDefault(tooltipOpts.footerFontFamily, globalDefaults.defaultFontFamily),
+ _footerFontStyle: valueOrDefault(tooltipOpts.footerFontStyle, globalDefaults.defaultFontStyle),
+ footerFontSize: valueOrDefault(tooltipOpts.footerFontSize, globalDefaults.defaultFontSize),
+ _footerAlign: tooltipOpts.footerAlign,
+ footerSpacing: tooltipOpts.footerSpacing,
+ footerMarginTop: tooltipOpts.footerMarginTop,
+
+ // Appearance
+ caretSize: tooltipOpts.caretSize,
+ cornerRadius: tooltipOpts.cornerRadius,
+ backgroundColor: tooltipOpts.backgroundColor,
+ opacity: 0,
+ legendColorBackground: tooltipOpts.multiKeyBackground,
+ displayColors: tooltipOpts.displayColors,
+ borderColor: tooltipOpts.borderColor,
+ borderWidth: tooltipOpts.borderWidth
+ };
+ }
+
+ /**
+ * Get the size of the tooltip
+ */
+ function getTooltipSize(tooltip, model) {
+ var ctx = tooltip._chart.ctx;
+
+ var height = model.yPadding * 2; // Tooltip Padding
+ var width = 0;
+
+ // Count of all lines in the body
+ var body = model.body;
+ var combinedBodyLength = body.reduce(function(count, bodyItem) {
+ return count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length;
+ }, 0);
+ combinedBodyLength += model.beforeBody.length + model.afterBody.length;
+
+ var titleLineCount = model.title.length;
+ var footerLineCount = model.footer.length;
+ var titleFontSize = model.titleFontSize;
+ var bodyFontSize = model.bodyFontSize;
+ var footerFontSize = model.footerFontSize;
+
+ height += titleLineCount * titleFontSize; // Title Lines
+ height += titleLineCount ? (titleLineCount - 1) * model.titleSpacing : 0; // Title Line Spacing
+ height += titleLineCount ? model.titleMarginBottom : 0; // Title's bottom Margin
+ height += combinedBodyLength * bodyFontSize; // Body Lines
+ height += combinedBodyLength ? (combinedBodyLength - 1) * model.bodySpacing : 0; // Body Line Spacing
+ height += footerLineCount ? model.footerMarginTop : 0; // Footer Margin
+ height += footerLineCount * (footerFontSize); // Footer Lines
+ height += footerLineCount ? (footerLineCount - 1) * model.footerSpacing : 0; // Footer Line Spacing
+
+ // Title width
+ var widthPadding = 0;
+ var maxLineWidth = function(line) {
+ width = Math.max(width, ctx.measureText(line).width + widthPadding);
+ };
+
+ ctx.font = helpers.fontString(titleFontSize, model._titleFontStyle, model._titleFontFamily);
+ helpers.each(model.title, maxLineWidth);
+
+ // Body width
+ ctx.font = helpers.fontString(bodyFontSize, model._bodyFontStyle, model._bodyFontFamily);
+ helpers.each(model.beforeBody.concat(model.afterBody), maxLineWidth);
+
+ // Body lines may include some extra width due to the color box
+ widthPadding = model.displayColors ? (bodyFontSize + 2) : 0;
+ helpers.each(body, function(bodyItem) {
+ helpers.each(bodyItem.before, maxLineWidth);
+ helpers.each(bodyItem.lines, maxLineWidth);
+ helpers.each(bodyItem.after, maxLineWidth);
+ });
+
+ // Reset back to 0
+ widthPadding = 0;
+
+ // Footer width
+ ctx.font = helpers.fontString(footerFontSize, model._footerFontStyle, model._footerFontFamily);
+ helpers.each(model.footer, maxLineWidth);
+
+ // Add padding
+ width += 2 * model.xPadding;
+
+ return {
+ width: width,
+ height: height
+ };
+ }
+
+ /**
+ * Helper to get the alignment of a tooltip given the size
+ */
+ function determineAlignment(tooltip, size) {
+ var model = tooltip._model;
+ var chart = tooltip._chart;
+ var chartArea = tooltip._chart.chartArea;
+ var xAlign = 'center';
+ var yAlign = 'center';
+
+ if (model.y < size.height) {
+ yAlign = 'top';
+ } else if (model.y > (chart.height - size.height)) {
+ yAlign = 'bottom';
+ }
+
+ var lf, rf; // functions to determine left, right alignment
+ var olf, orf; // functions to determine if left/right alignment causes tooltip to go outside chart
+ var yf; // function to get the y alignment if the tooltip goes outside of the left or right edges
+ var midX = (chartArea.left + chartArea.right) / 2;
+ var midY = (chartArea.top + chartArea.bottom) / 2;
+
+ if (yAlign === 'center') {
+ lf = function(x) {
+ return x <= midX;
+ };
+ rf = function(x) {
+ return x > midX;
+ };
+ } else {
+ lf = function(x) {
+ return x <= (size.width / 2);
+ };
+ rf = function(x) {
+ return x >= (chart.width - (size.width / 2));
+ };
+ }
+
+ olf = function(x) {
+ return x + size.width > chart.width;
+ };
+ orf = function(x) {
+ return x - size.width < 0;
+ };
+ yf = function(y) {
+ return y <= midY ? 'top' : 'bottom';
+ };
+
+ if (lf(model.x)) {
+ xAlign = 'left';
+
+ // Is tooltip too wide and goes over the right side of the chart.?
+ if (olf(model.x)) {
+ xAlign = 'center';
+ yAlign = yf(model.y);
+ }
+ } else if (rf(model.x)) {
+ xAlign = 'right';
+
+ // Is tooltip too wide and goes outside left edge of canvas?
+ if (orf(model.x)) {
+ xAlign = 'center';
+ yAlign = yf(model.y);
+ }
+ }
+
+ var opts = tooltip._options;
+ return {
+ xAlign: opts.xAlign ? opts.xAlign : xAlign,
+ yAlign: opts.yAlign ? opts.yAlign : yAlign
+ };
+ }
+
+ /**
+ * @Helper to get the location a tooltip needs to be placed at given the initial position (via the vm) and the size and alignment
+ */
+ function getBackgroundPoint(vm, size, alignment) {
+ // Background Position
+ var x = vm.x;
+ var y = vm.y;
+
+ var caretSize = vm.caretSize;
+ var caretPadding = vm.caretPadding;
+ var cornerRadius = vm.cornerRadius;
+ var xAlign = alignment.xAlign;
+ var yAlign = alignment.yAlign;
+ var paddingAndSize = caretSize + caretPadding;
+ var radiusAndPadding = cornerRadius + caretPadding;
+
+ if (xAlign === 'right') {
+ x -= size.width;
+ } else if (xAlign === 'center') {
+ x -= (size.width / 2);
+ }
+
+ if (yAlign === 'top') {
+ y += paddingAndSize;
+ } else if (yAlign === 'bottom') {
+ y -= size.height + paddingAndSize;
+ } else {
+ y -= (size.height / 2);
+ }
+
+ if (yAlign === 'center') {
+ if (xAlign === 'left') {
+ x += paddingAndSize;
+ } else if (xAlign === 'right') {
+ x -= paddingAndSize;
+ }
+ } else if (xAlign === 'left') {
+ x -= radiusAndPadding;
+ } else if (xAlign === 'right') {
+ x += radiusAndPadding;
+ }
+
+ return {
+ x: x,
+ y: y
+ };
+ }
+
+ Chart.Tooltip = Element.extend({
+ initialize: function() {
+ this._model = getBaseModel(this._options);
+ this._lastActive = [];
+ },
+
+ // Get the title
+ // Args are: (tooltipItem, data)
+ getTitle: function() {
+ var me = this;
+ var opts = me._options;
+ var callbacks = opts.callbacks;
+
+ var beforeTitle = callbacks.beforeTitle.apply(me, arguments);
+ var title = callbacks.title.apply(me, arguments);
+ var afterTitle = callbacks.afterTitle.apply(me, arguments);
+
+ var lines = [];
+ lines = pushOrConcat(lines, beforeTitle);
+ lines = pushOrConcat(lines, title);
+ lines = pushOrConcat(lines, afterTitle);
+
+ return lines;
+ },
+
+ // Args are: (tooltipItem, data)
+ getBeforeBody: function() {
+ var lines = this._options.callbacks.beforeBody.apply(this, arguments);
+ return helpers.isArray(lines) ? lines : lines !== undefined ? [lines] : [];
+ },
+
+ // Args are: (tooltipItem, data)
+ getBody: function(tooltipItems, data) {
+ var me = this;
+ var callbacks = me._options.callbacks;
+ var bodyItems = [];
+
+ helpers.each(tooltipItems, function(tooltipItem) {
+ var bodyItem = {
+ before: [],
+ lines: [],
+ after: []
+ };
+ pushOrConcat(bodyItem.before, callbacks.beforeLabel.call(me, tooltipItem, data));
+ pushOrConcat(bodyItem.lines, callbacks.label.call(me, tooltipItem, data));
+ pushOrConcat(bodyItem.after, callbacks.afterLabel.call(me, tooltipItem, data));
+
+ bodyItems.push(bodyItem);
+ });
+
+ return bodyItems;
+ },
+
+ // Args are: (tooltipItem, data)
+ getAfterBody: function() {
+ var lines = this._options.callbacks.afterBody.apply(this, arguments);
+ return helpers.isArray(lines) ? lines : lines !== undefined ? [lines] : [];
+ },
+
+ // Get the footer and beforeFooter and afterFooter lines
+ // Args are: (tooltipItem, data)
+ getFooter: function() {
+ var me = this;
+ var callbacks = me._options.callbacks;
+
+ var beforeFooter = callbacks.beforeFooter.apply(me, arguments);
+ var footer = callbacks.footer.apply(me, arguments);
+ var afterFooter = callbacks.afterFooter.apply(me, arguments);
+
+ var lines = [];
+ lines = pushOrConcat(lines, beforeFooter);
+ lines = pushOrConcat(lines, footer);
+ lines = pushOrConcat(lines, afterFooter);
+
+ return lines;
+ },
+
+ update: function(changed) {
+ var me = this;
+ var opts = me._options;
+
+ // Need to regenerate the model because its faster than using extend and it is necessary due to the optimization in Chart.Element.transition
+ // that does _view = _model if ease === 1. This causes the 2nd tooltip update to set properties in both the view and model at the same time
+ // which breaks any animations.
+ var existingModel = me._model;
+ var model = me._model = getBaseModel(opts);
+ var active = me._active;
+
+ var data = me._data;
+
+ // In the case where active.length === 0 we need to keep these at existing values for good animations
+ var alignment = {
+ xAlign: existingModel.xAlign,
+ yAlign: existingModel.yAlign
+ };
+ var backgroundPoint = {
+ x: existingModel.x,
+ y: existingModel.y
+ };
+ var tooltipSize = {
+ width: existingModel.width,
+ height: existingModel.height
+ };
+ var tooltipPosition = {
+ x: existingModel.caretX,
+ y: existingModel.caretY
+ };
+
+ var i, len;
+
+ if (active.length) {
+ model.opacity = 1;
+
+ var labelColors = [];
+ var labelTextColors = [];
+ tooltipPosition = Chart.Tooltip.positioners[opts.position].call(me, active, me._eventPosition);
+
+ var tooltipItems = [];
+ for (i = 0, len = active.length; i < len; ++i) {
+ tooltipItems.push(createTooltipItem(active[i]));
+ }
+
+ // If the user provided a filter function, use it to modify the tooltip items
+ if (opts.filter) {
+ tooltipItems = tooltipItems.filter(function(a) {
+ return opts.filter(a, data);
+ });
+ }
+
+ // If the user provided a sorting function, use it to modify the tooltip items
+ if (opts.itemSort) {
+ tooltipItems = tooltipItems.sort(function(a, b) {
+ return opts.itemSort(a, b, data);
+ });
+ }
+
+ // Determine colors for boxes
+ helpers.each(tooltipItems, function(tooltipItem) {
+ labelColors.push(opts.callbacks.labelColor.call(me, tooltipItem, me._chart));
+ labelTextColors.push(opts.callbacks.labelTextColor.call(me, tooltipItem, me._chart));
+ });
+
+
+ // Build the Text Lines
+ model.title = me.getTitle(tooltipItems, data);
+ model.beforeBody = me.getBeforeBody(tooltipItems, data);
+ model.body = me.getBody(tooltipItems, data);
+ model.afterBody = me.getAfterBody(tooltipItems, data);
+ model.footer = me.getFooter(tooltipItems, data);
+
+ // Initial positioning and colors
+ model.x = Math.round(tooltipPosition.x);
+ model.y = Math.round(tooltipPosition.y);
+ model.caretPadding = opts.caretPadding;
+ model.labelColors = labelColors;
+ model.labelTextColors = labelTextColors;
+
+ // data points
+ model.dataPoints = tooltipItems;
+
+ // We need to determine alignment of the tooltip
+ tooltipSize = getTooltipSize(this, model);
+ alignment = determineAlignment(this, tooltipSize);
+ // Final Size and Position
+ backgroundPoint = getBackgroundPoint(model, tooltipSize, alignment);
+ } else {
+ model.opacity = 0;
+ }
+
+ model.xAlign = alignment.xAlign;
+ model.yAlign = alignment.yAlign;
+ model.x = backgroundPoint.x;
+ model.y = backgroundPoint.y;
+ model.width = tooltipSize.width;
+ model.height = tooltipSize.height;
+
+ // Point where the caret on the tooltip points to
+ model.caretX = tooltipPosition.x;
+ model.caretY = tooltipPosition.y;
+
+ me._model = model;
+
+ if (changed && opts.custom) {
+ opts.custom.call(me, model);
+ }
+
+ return me;
+ },
+ drawCaret: function(tooltipPoint, size) {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+ var caretPosition = this.getCaretPosition(tooltipPoint, size, vm);
+
+ ctx.lineTo(caretPosition.x1, caretPosition.y1);
+ ctx.lineTo(caretPosition.x2, caretPosition.y2);
+ ctx.lineTo(caretPosition.x3, caretPosition.y3);
+ },
+ getCaretPosition: function(tooltipPoint, size, vm) {
+ var x1, x2, x3, y1, y2, y3;
+ var caretSize = vm.caretSize;
+ var cornerRadius = vm.cornerRadius;
+ var xAlign = vm.xAlign;
+ var yAlign = vm.yAlign;
+ var ptX = tooltipPoint.x;
+ var ptY = tooltipPoint.y;
+ var width = size.width;
+ var height = size.height;
+
+ if (yAlign === 'center') {
+ y2 = ptY + (height / 2);
+
+ if (xAlign === 'left') {
+ x1 = ptX;
+ x2 = x1 - caretSize;
+ x3 = x1;
+
+ y1 = y2 + caretSize;
+ y3 = y2 - caretSize;
+ } else {
+ x1 = ptX + width;
+ x2 = x1 + caretSize;
+ x3 = x1;
+
+ y1 = y2 - caretSize;
+ y3 = y2 + caretSize;
+ }
+ } else {
+ if (xAlign === 'left') {
+ x2 = ptX + cornerRadius + (caretSize);
+ x1 = x2 - caretSize;
+ x3 = x2 + caretSize;
+ } else if (xAlign === 'right') {
+ x2 = ptX + width - cornerRadius - caretSize;
+ x1 = x2 - caretSize;
+ x3 = x2 + caretSize;
+ } else {
+ x2 = ptX + (width / 2);
+ x1 = x2 - caretSize;
+ x3 = x2 + caretSize;
+ }
+ if (yAlign === 'top') {
+ y1 = ptY;
+ y2 = y1 - caretSize;
+ y3 = y1;
+ } else {
+ y1 = ptY + height;
+ y2 = y1 + caretSize;
+ y3 = y1;
+ // invert drawing order
+ var tmp = x3;
+ x3 = x1;
+ x1 = tmp;
+ }
+ }
+ return {x1: x1, x2: x2, x3: x3, y1: y1, y2: y2, y3: y3};
+ },
+ drawTitle: function(pt, vm, ctx, opacity) {
+ var title = vm.title;
+
+ if (title.length) {
+ ctx.textAlign = vm._titleAlign;
+ ctx.textBaseline = 'top';
+
+ var titleFontSize = vm.titleFontSize;
+ var titleSpacing = vm.titleSpacing;
+
+ ctx.fillStyle = mergeOpacity(vm.titleFontColor, opacity);
+ ctx.font = helpers.fontString(titleFontSize, vm._titleFontStyle, vm._titleFontFamily);
+
+ var i, len;
+ for (i = 0, len = title.length; i < len; ++i) {
+ ctx.fillText(title[i], pt.x, pt.y);
+ pt.y += titleFontSize + titleSpacing; // Line Height and spacing
+
+ if (i + 1 === title.length) {
+ pt.y += vm.titleMarginBottom - titleSpacing; // If Last, add margin, remove spacing
+ }
+ }
+ }
+ },
+ drawBody: function(pt, vm, ctx, opacity) {
+ var bodyFontSize = vm.bodyFontSize;
+ var bodySpacing = vm.bodySpacing;
+ var body = vm.body;
+
+ ctx.textAlign = vm._bodyAlign;
+ ctx.textBaseline = 'top';
+ ctx.font = helpers.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
+
+ // Before Body
+ var xLinePadding = 0;
+ var fillLineOfText = function(line) {
+ ctx.fillText(line, pt.x + xLinePadding, pt.y);
+ pt.y += bodyFontSize + bodySpacing;
+ };
+
+ // Before body lines
+ ctx.fillStyle = mergeOpacity(vm.bodyFontColor, opacity);
+ helpers.each(vm.beforeBody, fillLineOfText);
+
+ var drawColorBoxes = vm.displayColors;
+ xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0;
+
+ // Draw body lines now
+ helpers.each(body, function(bodyItem, i) {
+ var textColor = mergeOpacity(vm.labelTextColors[i], opacity);
+ ctx.fillStyle = textColor;
+ helpers.each(bodyItem.before, fillLineOfText);
+
+ helpers.each(bodyItem.lines, function(line) {
+ // Draw Legend-like boxes if needed
+ if (drawColorBoxes) {
+ // Fill a white rect so that colours merge nicely if the opacity is < 1
+ ctx.fillStyle = mergeOpacity(vm.legendColorBackground, opacity);
+ ctx.fillRect(pt.x, pt.y, bodyFontSize, bodyFontSize);
+
+ // Border
+ ctx.lineWidth = 1;
+ ctx.strokeStyle = mergeOpacity(vm.labelColors[i].borderColor, opacity);
+ ctx.strokeRect(pt.x, pt.y, bodyFontSize, bodyFontSize);
+
+ // Inner square
+ ctx.fillStyle = mergeOpacity(vm.labelColors[i].backgroundColor, opacity);
+ ctx.fillRect(pt.x + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2);
+ ctx.fillStyle = textColor;
+ }
+
+ fillLineOfText(line);
+ });
+
+ helpers.each(bodyItem.after, fillLineOfText);
+ });
+
+ // Reset back to 0 for after body
+ xLinePadding = 0;
+
+ // After body lines
+ helpers.each(vm.afterBody, fillLineOfText);
+ pt.y -= bodySpacing; // Remove last body spacing
+ },
+ drawFooter: function(pt, vm, ctx, opacity) {
+ var footer = vm.footer;
+
+ if (footer.length) {
+ pt.y += vm.footerMarginTop;
+
+ ctx.textAlign = vm._footerAlign;
+ ctx.textBaseline = 'top';
+
+ ctx.fillStyle = mergeOpacity(vm.footerFontColor, opacity);
+ ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
+
+ helpers.each(footer, function(line) {
+ ctx.fillText(line, pt.x, pt.y);
+ pt.y += vm.footerFontSize + vm.footerSpacing;
+ });
+ }
+ },
+ drawBackground: function(pt, vm, ctx, tooltipSize, opacity) {
+ ctx.fillStyle = mergeOpacity(vm.backgroundColor, opacity);
+ ctx.strokeStyle = mergeOpacity(vm.borderColor, opacity);
+ ctx.lineWidth = vm.borderWidth;
+ var xAlign = vm.xAlign;
+ var yAlign = vm.yAlign;
+ var x = pt.x;
+ var y = pt.y;
+ var width = tooltipSize.width;
+ var height = tooltipSize.height;
+ var radius = vm.cornerRadius;
+
+ ctx.beginPath();
+ ctx.moveTo(x + radius, y);
+ if (yAlign === 'top') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x + width - radius, y);
+ ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
+ if (yAlign === 'center' && xAlign === 'right') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x + width, y + height - radius);
+ ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
+ if (yAlign === 'bottom') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x + radius, y + height);
+ ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
+ if (yAlign === 'center' && xAlign === 'left') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x, y + radius);
+ ctx.quadraticCurveTo(x, y, x + radius, y);
+ ctx.closePath();
+
+ ctx.fill();
+
+ if (vm.borderWidth > 0) {
+ ctx.stroke();
+ }
+ },
+ draw: function() {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+
+ if (vm.opacity === 0) {
+ return;
+ }
+
+ var tooltipSize = {
+ width: vm.width,
+ height: vm.height
+ };
+ var pt = {
+ x: vm.x,
+ y: vm.y
+ };
+
+ // IE11/Edge does not like very small opacities, so snap to 0
+ var opacity = Math.abs(vm.opacity < 1e-3) ? 0 : vm.opacity;
+
+ // Truthy/falsey value for empty tooltip
+ var hasTooltipContent = vm.title.length || vm.beforeBody.length || vm.body.length || vm.afterBody.length || vm.footer.length;
+
+ if (this._options.enabled && hasTooltipContent) {
+ // Draw Background
+ this.drawBackground(pt, vm, ctx, tooltipSize, opacity);
+
+ // Draw Title, Body, and Footer
+ pt.x += vm.xPadding;
+ pt.y += vm.yPadding;
+
+ // Titles
+ this.drawTitle(pt, vm, ctx, opacity);
+
+ // Body
+ this.drawBody(pt, vm, ctx, opacity);
+
+ // Footer
+ this.drawFooter(pt, vm, ctx, opacity);
+ }
+ },
+
+ /**
+ * Handle an event
+ * @private
+ * @param {IEvent} event - The event to handle
+ * @returns {Boolean} true if the tooltip changed
+ */
+ handleEvent: function(e) {
+ var me = this;
+ var options = me._options;
+ var changed = false;
+
+ me._lastActive = me._lastActive || [];
+
+ // Find Active Elements for tooltips
+ if (e.type === 'mouseout') {
+ me._active = [];
+ } else {
+ me._active = me._chart.getElementsAtEventForMode(e, options.mode, options);
+ }
+
+ // Remember Last Actives
+ changed = !helpers.arrayEquals(me._active, me._lastActive);
+
+ // If tooltip didn't change, do not handle the target event
+ if (!changed) {
+ return false;
+ }
+
+ me._lastActive = me._active;
+
+ if (options.enabled || options.custom) {
+ me._eventPosition = {
+ x: e.x,
+ y: e.y
+ };
+
+ var model = me._model;
+ me.update(true);
+ me.pivot();
+
+ // See if our tooltip position changed
+ changed |= (model.x !== me._model.x) || (model.y !== me._model.y);
+ }
+
+ return changed;
+ }
+ });
+
+ /**
+ * @namespace Chart.Tooltip.positioners
+ */
+ Chart.Tooltip.positioners = {
+ /**
+ * Average mode places the tooltip at the average position of the elements shown
+ * @function Chart.Tooltip.positioners.average
+ * @param elements {ChartElement[]} the elements being displayed in the tooltip
+ * @returns {Point} tooltip position
+ */
+ average: function(elements) {
+ if (!elements.length) {
+ return false;
+ }
+
+ var i, len;
+ var x = 0;
+ var y = 0;
+ var count = 0;
+
+ for (i = 0, len = elements.length; i < len; ++i) {
+ var el = elements[i];
+ if (el && el.hasValue()) {
+ var pos = el.tooltipPosition();
+ x += pos.x;
+ y += pos.y;
+ ++count;
+ }
+ }
+
+ return {
+ x: Math.round(x / count),
+ y: Math.round(y / count)
+ };
+ },
+
+ /**
+ * Gets the tooltip position nearest of the item nearest to the event position
+ * @function Chart.Tooltip.positioners.nearest
+ * @param elements {Chart.Element[]} the tooltip elements
+ * @param eventPosition {Point} the position of the event in canvas coordinates
+ * @returns {Point} the tooltip position
+ */
+ nearest: function(elements, eventPosition) {
+ var x = eventPosition.x;
+ var y = eventPosition.y;
+ var minDistance = Number.POSITIVE_INFINITY;
+ var i, len, nearestElement;
+
+ for (i = 0, len = elements.length; i < len; ++i) {
+ var el = elements[i];
+ if (el && el.hasValue()) {
+ var center = el.getCenterPoint();
+ var d = helpers.distanceBetweenPoints(eventPosition, center);
+
+ if (d < minDistance) {
+ minDistance = d;
+ nearestElement = el;
+ }
+ }
+ }
+
+ if (nearestElement) {
+ var tp = nearestElement.tooltipPosition();
+ x = tp.x;
+ y = tp.y;
+ }
+
+ return {
+ x: x,
+ y: y
+ };
+ }
+ };
+};
+
+},{"25":25,"26":26,"45":45}],36:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ elements: {
+ arc: {
+ backgroundColor: defaults.global.defaultColor,
+ borderColor: '#fff',
+ borderWidth: 2
+ }
+ }
+});
+
+module.exports = Element.extend({
+ inLabelRange: function(mouseX) {
+ var vm = this._view;
+
+ if (vm) {
+ return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2));
+ }
+ return false;
+ },
+
+ inRange: function(chartX, chartY) {
+ var vm = this._view;
+
+ if (vm) {
+ var pointRelativePosition = helpers.getAngleFromPoint(vm, {x: chartX, y: chartY});
+ var angle = pointRelativePosition.angle;
+ var distance = pointRelativePosition.distance;
+
+ // Sanitise angle range
+ var startAngle = vm.startAngle;
+ var endAngle = vm.endAngle;
+ while (endAngle < startAngle) {
+ endAngle += 2.0 * Math.PI;
+ }
+ while (angle > endAngle) {
+ angle -= 2.0 * Math.PI;
+ }
+ while (angle < startAngle) {
+ angle += 2.0 * Math.PI;
+ }
+
+ // Check if within the range of the open/close angle
+ var betweenAngles = (angle >= startAngle && angle <= endAngle);
+ var withinRadius = (distance >= vm.innerRadius && distance <= vm.outerRadius);
+
+ return (betweenAngles && withinRadius);
+ }
+ return false;
+ },
+
+ getCenterPoint: function() {
+ var vm = this._view;
+ var halfAngle = (vm.startAngle + vm.endAngle) / 2;
+ var halfRadius = (vm.innerRadius + vm.outerRadius) / 2;
+ return {
+ x: vm.x + Math.cos(halfAngle) * halfRadius,
+ y: vm.y + Math.sin(halfAngle) * halfRadius
+ };
+ },
+
+ getArea: function() {
+ var vm = this._view;
+ return Math.PI * ((vm.endAngle - vm.startAngle) / (2 * Math.PI)) * (Math.pow(vm.outerRadius, 2) - Math.pow(vm.innerRadius, 2));
+ },
+
+ tooltipPosition: function() {
+ var vm = this._view;
+ var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2);
+ var rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius;
+
+ return {
+ x: vm.x + (Math.cos(centreAngle) * rangeFromCentre),
+ y: vm.y + (Math.sin(centreAngle) * rangeFromCentre)
+ };
+ },
+
+ draw: function() {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+ var sA = vm.startAngle;
+ var eA = vm.endAngle;
+
+ ctx.beginPath();
+
+ ctx.arc(vm.x, vm.y, vm.outerRadius, sA, eA);
+ ctx.arc(vm.x, vm.y, vm.innerRadius, eA, sA, true);
+
+ ctx.closePath();
+ ctx.strokeStyle = vm.borderColor;
+ ctx.lineWidth = vm.borderWidth;
+
+ ctx.fillStyle = vm.backgroundColor;
+
+ ctx.fill();
+ ctx.lineJoin = 'bevel';
+
+ if (vm.borderWidth) {
+ ctx.stroke();
+ }
+ }
+});
+
+},{"25":25,"26":26,"45":45}],37:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+var globalDefaults = defaults.global;
+
+defaults._set('global', {
+ elements: {
+ line: {
+ tension: 0.4,
+ backgroundColor: globalDefaults.defaultColor,
+ borderWidth: 3,
+ borderColor: globalDefaults.defaultColor,
+ borderCapStyle: 'butt',
+ borderDash: [],
+ borderDashOffset: 0.0,
+ borderJoinStyle: 'miter',
+ capBezierPoints: true,
+ fill: true, // do we fill in the area between the line and its base axis
+ }
+ }
+});
+
+module.exports = Element.extend({
+ draw: function() {
+ var me = this;
+ var vm = me._view;
+ var ctx = me._chart.ctx;
+ var spanGaps = vm.spanGaps;
+ var points = me._children.slice(); // clone array
+ var globalOptionLineElements = globalDefaults.elements.line;
+ var lastDrawnIndex = -1;
+ var index, current, previous, currentVM;
+
+ // If we are looping, adding the first point again
+ if (me._loop && points.length) {
+ points.push(points[0]);
+ }
+
+ ctx.save();
+
+ // Stroke Line Options
+ ctx.lineCap = vm.borderCapStyle || globalOptionLineElements.borderCapStyle;
+
+ // IE 9 and 10 do not support line dash
+ if (ctx.setLineDash) {
+ ctx.setLineDash(vm.borderDash || globalOptionLineElements.borderDash);
+ }
+
+ ctx.lineDashOffset = vm.borderDashOffset || globalOptionLineElements.borderDashOffset;
+ ctx.lineJoin = vm.borderJoinStyle || globalOptionLineElements.borderJoinStyle;
+ ctx.lineWidth = vm.borderWidth || globalOptionLineElements.borderWidth;
+ ctx.strokeStyle = vm.borderColor || globalDefaults.defaultColor;
+
+ // Stroke Line
+ ctx.beginPath();
+ lastDrawnIndex = -1;
+
+ for (index = 0; index < points.length; ++index) {
+ current = points[index];
+ previous = helpers.previousItem(points, index);
+ currentVM = current._view;
+
+ // First point moves to it's starting position no matter what
+ if (index === 0) {
+ if (!currentVM.skip) {
+ ctx.moveTo(currentVM.x, currentVM.y);
+ lastDrawnIndex = index;
+ }
+ } else {
+ previous = lastDrawnIndex === -1 ? previous : points[lastDrawnIndex];
+
+ if (!currentVM.skip) {
+ if ((lastDrawnIndex !== (index - 1) && !spanGaps) || lastDrawnIndex === -1) {
+ // There was a gap and this is the first point after the gap
+ ctx.moveTo(currentVM.x, currentVM.y);
+ } else {
+ // Line to next point
+ helpers.canvas.lineTo(ctx, previous._view, current._view);
+ }
+ lastDrawnIndex = index;
+ }
+ }
+ }
+
+ ctx.stroke();
+ ctx.restore();
+ }
+});
+
+},{"25":25,"26":26,"45":45}],38:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+var defaultColor = defaults.global.defaultColor;
+
+defaults._set('global', {
+ elements: {
+ point: {
+ radius: 3,
+ pointStyle: 'circle',
+ backgroundColor: defaultColor,
+ borderColor: defaultColor,
+ borderWidth: 1,
+ // Hover
+ hitRadius: 1,
+ hoverRadius: 4,
+ hoverBorderWidth: 1
+ }
+ }
+});
+
+function xRange(mouseX) {
+ var vm = this._view;
+ return vm ? (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)) : false;
+}
+
+function yRange(mouseY) {
+ var vm = this._view;
+ return vm ? (Math.pow(mouseY - vm.y, 2) < Math.pow(vm.radius + vm.hitRadius, 2)) : false;
+}
+
+module.exports = Element.extend({
+ inRange: function(mouseX, mouseY) {
+ var vm = this._view;
+ return vm ? ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(vm.hitRadius + vm.radius, 2)) : false;
+ },
+
+ inLabelRange: xRange,
+ inXRange: xRange,
+ inYRange: yRange,
+
+ getCenterPoint: function() {
+ var vm = this._view;
+ return {
+ x: vm.x,
+ y: vm.y
+ };
+ },
+
+ getArea: function() {
+ return Math.PI * Math.pow(this._view.radius, 2);
+ },
+
+ tooltipPosition: function() {
+ var vm = this._view;
+ return {
+ x: vm.x,
+ y: vm.y,
+ padding: vm.radius + vm.borderWidth
+ };
+ },
+
+ draw: function(chartArea) {
+ var vm = this._view;
+ var model = this._model;
+ var ctx = this._chart.ctx;
+ var pointStyle = vm.pointStyle;
+ var radius = vm.radius;
+ var x = vm.x;
+ var y = vm.y;
+ var color = helpers.color;
+ var errMargin = 1.01; // 1.01 is margin for Accumulated error. (Especially Edge, IE.)
+ var ratio = 0;
+
+ if (vm.skip) {
+ return;
+ }
+
+ ctx.strokeStyle = vm.borderColor || defaultColor;
+ ctx.lineWidth = helpers.valueOrDefault(vm.borderWidth, defaults.global.elements.point.borderWidth);
+ ctx.fillStyle = vm.backgroundColor || defaultColor;
+
+ // Cliping for Points.
+ // going out from inner charArea?
+ if ((chartArea !== undefined) && ((model.x < chartArea.left) || (chartArea.right * errMargin < model.x) || (model.y < chartArea.top) || (chartArea.bottom * errMargin < model.y))) {
+ // Point fade out
+ if (model.x < chartArea.left) {
+ ratio = (x - model.x) / (chartArea.left - model.x);
+ } else if (chartArea.right * errMargin < model.x) {
+ ratio = (model.x - x) / (model.x - chartArea.right);
+ } else if (model.y < chartArea.top) {
+ ratio = (y - model.y) / (chartArea.top - model.y);
+ } else if (chartArea.bottom * errMargin < model.y) {
+ ratio = (model.y - y) / (model.y - chartArea.bottom);
+ }
+ ratio = Math.round(ratio * 100) / 100;
+ ctx.strokeStyle = color(ctx.strokeStyle).alpha(ratio).rgbString();
+ ctx.fillStyle = color(ctx.fillStyle).alpha(ratio).rgbString();
+ }
+
+ helpers.canvas.drawPoint(ctx, pointStyle, radius, x, y);
+ }
+});
+
+},{"25":25,"26":26,"45":45}],39:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+
+defaults._set('global', {
+ elements: {
+ rectangle: {
+ backgroundColor: defaults.global.defaultColor,
+ borderColor: defaults.global.defaultColor,
+ borderSkipped: 'bottom',
+ borderWidth: 0
+ }
+ }
+});
+
+function isVertical(bar) {
+ return bar._view.width !== undefined;
+}
+
+/**
+ * Helper function to get the bounds of the bar regardless of the orientation
+ * @param bar {Chart.Element.Rectangle} the bar
+ * @return {Bounds} bounds of the bar
+ * @private
+ */
+function getBarBounds(bar) {
+ var vm = bar._view;
+ var x1, x2, y1, y2;
+
+ if (isVertical(bar)) {
+ // vertical
+ var halfWidth = vm.width / 2;
+ x1 = vm.x - halfWidth;
+ x2 = vm.x + halfWidth;
+ y1 = Math.min(vm.y, vm.base);
+ y2 = Math.max(vm.y, vm.base);
+ } else {
+ // horizontal bar
+ var halfHeight = vm.height / 2;
+ x1 = Math.min(vm.x, vm.base);
+ x2 = Math.max(vm.x, vm.base);
+ y1 = vm.y - halfHeight;
+ y2 = vm.y + halfHeight;
+ }
+
+ return {
+ left: x1,
+ top: y1,
+ right: x2,
+ bottom: y2
+ };
+}
+
+module.exports = Element.extend({
+ draw: function() {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+ var left, right, top, bottom, signX, signY, borderSkipped;
+ var borderWidth = vm.borderWidth;
+
+ if (!vm.horizontal) {
+ // bar
+ left = vm.x - vm.width / 2;
+ right = vm.x + vm.width / 2;
+ top = vm.y;
+ bottom = vm.base;
+ signX = 1;
+ signY = bottom > top ? 1 : -1;
+ borderSkipped = vm.borderSkipped || 'bottom';
+ } else {
+ // horizontal bar
+ left = vm.base;
+ right = vm.x;
+ top = vm.y - vm.height / 2;
+ bottom = vm.y + vm.height / 2;
+ signX = right > left ? 1 : -1;
+ signY = 1;
+ borderSkipped = vm.borderSkipped || 'left';
+ }
+
+ // Canvas doesn't allow us to stroke inside the width so we can
+ // adjust the sizes to fit if we're setting a stroke on the line
+ if (borderWidth) {
+ // borderWidth shold be less than bar width and bar height.
+ var barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom));
+ borderWidth = borderWidth > barSize ? barSize : borderWidth;
+ var halfStroke = borderWidth / 2;
+ // Adjust borderWidth when bar top position is near vm.base(zero).
+ var borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0);
+ var borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0);
+ var borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0);
+ var borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0);
+ // not become a vertical line?
+ if (borderLeft !== borderRight) {
+ top = borderTop;
+ bottom = borderBottom;
+ }
+ // not become a horizontal line?
+ if (borderTop !== borderBottom) {
+ left = borderLeft;
+ right = borderRight;
+ }
+ }
+
+ ctx.beginPath();
+ ctx.fillStyle = vm.backgroundColor;
+ ctx.strokeStyle = vm.borderColor;
+ ctx.lineWidth = borderWidth;
+
+ // Corner points, from bottom-left to bottom-right clockwise
+ // | 1 2 |
+ // | 0 3 |
+ var corners = [
+ [left, bottom],
+ [left, top],
+ [right, top],
+ [right, bottom]
+ ];
+
+ // Find first (starting) corner with fallback to 'bottom'
+ var borders = ['bottom', 'left', 'top', 'right'];
+ var startCorner = borders.indexOf(borderSkipped, 0);
+ if (startCorner === -1) {
+ startCorner = 0;
+ }
+
+ function cornerAt(index) {
+ return corners[(startCorner + index) % 4];
+ }
+
+ // Draw rectangle from 'startCorner'
+ var corner = cornerAt(0);
+ ctx.moveTo(corner[0], corner[1]);
+
+ for (var i = 1; i < 4; i++) {
+ corner = cornerAt(i);
+ ctx.lineTo(corner[0], corner[1]);
+ }
+
+ ctx.fill();
+ if (borderWidth) {
+ ctx.stroke();
+ }
+ },
+
+ height: function() {
+ var vm = this._view;
+ return vm.base - vm.y;
+ },
+
+ inRange: function(mouseX, mouseY) {
+ var inRange = false;
+
+ if (this._view) {
+ var bounds = getBarBounds(this);
+ inRange = mouseX >= bounds.left && mouseX <= bounds.right && mouseY >= bounds.top && mouseY <= bounds.bottom;
+ }
+
+ return inRange;
+ },
+
+ inLabelRange: function(mouseX, mouseY) {
+ var me = this;
+ if (!me._view) {
+ return false;
+ }
+
+ var inRange = false;
+ var bounds = getBarBounds(me);
+
+ if (isVertical(me)) {
+ inRange = mouseX >= bounds.left && mouseX <= bounds.right;
+ } else {
+ inRange = mouseY >= bounds.top && mouseY <= bounds.bottom;
+ }
+
+ return inRange;
+ },
+
+ inXRange: function(mouseX) {
+ var bounds = getBarBounds(this);
+ return mouseX >= bounds.left && mouseX <= bounds.right;
+ },
+
+ inYRange: function(mouseY) {
+ var bounds = getBarBounds(this);
+ return mouseY >= bounds.top && mouseY <= bounds.bottom;
+ },
+
+ getCenterPoint: function() {
+ var vm = this._view;
+ var x, y;
+ if (isVertical(this)) {
+ x = vm.x;
+ y = (vm.y + vm.base) / 2;
+ } else {
+ x = (vm.x + vm.base) / 2;
+ y = vm.y;
+ }
+
+ return {x: x, y: y};
+ },
+
+ getArea: function() {
+ var vm = this._view;
+ return vm.width * Math.abs(vm.y - vm.base);
+ },
+
+ tooltipPosition: function() {
+ var vm = this._view;
+ return {
+ x: vm.x,
+ y: vm.y
+ };
+ }
+});
+
+},{"25":25,"26":26}],40:[function(require,module,exports){
+'use strict';
+
+module.exports = {};
+module.exports.Arc = require(36);
+module.exports.Line = require(37);
+module.exports.Point = require(38);
+module.exports.Rectangle = require(39);
+
+},{"36":36,"37":37,"38":38,"39":39}],41:[function(require,module,exports){
+'use strict';
+
+var helpers = require(42);
+
+/**
+ * @namespace Chart.helpers.canvas
+ */
+var exports = module.exports = {
+ /**
+ * Clears the entire canvas associated to the given `chart`.
+ * @param {Chart} chart - The chart for which to clear the canvas.
+ */
+ clear: function(chart) {
+ chart.ctx.clearRect(0, 0, chart.width, chart.height);
+ },
+
+ /**
+ * Creates a "path" for a rectangle with rounded corners at position (x, y) with a
+ * given size (width, height) and the same `radius` for all corners.
+ * @param {CanvasRenderingContext2D} ctx - The canvas 2D Context.
+ * @param {Number} x - The x axis of the coordinate for the rectangle starting point.
+ * @param {Number} y - The y axis of the coordinate for the rectangle starting point.
+ * @param {Number} width - The rectangle's width.
+ * @param {Number} height - The rectangle's height.
+ * @param {Number} radius - The rounded amount (in pixels) for the four corners.
+ * @todo handle `radius` as top-left, top-right, bottom-right, bottom-left array/object?
+ */
+ roundedRect: function(ctx, x, y, width, height, radius) {
+ if (radius) {
+ var rx = Math.min(radius, width / 2);
+ var ry = Math.min(radius, height / 2);
+
+ ctx.moveTo(x + rx, y);
+ ctx.lineTo(x + width - rx, y);
+ ctx.quadraticCurveTo(x + width, y, x + width, y + ry);
+ ctx.lineTo(x + width, y + height - ry);
+ ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height);
+ ctx.lineTo(x + rx, y + height);
+ ctx.quadraticCurveTo(x, y + height, x, y + height - ry);
+ ctx.lineTo(x, y + ry);
+ ctx.quadraticCurveTo(x, y, x + rx, y);
+ } else {
+ ctx.rect(x, y, width, height);
+ }
+ },
+
+ drawPoint: function(ctx, style, radius, x, y) {
+ var type, edgeLength, xOffset, yOffset, height, size;
+
+ if (style && typeof style === 'object') {
+ type = style.toString();
+ if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') {
+ ctx.drawImage(style, x - style.width / 2, y - style.height / 2, style.width, style.height);
+ return;
+ }
+ }
+
+ if (isNaN(radius) || radius <= 0) {
+ return;
+ }
+
+ switch (style) {
+ // Default includes circle
+ default:
+ ctx.beginPath();
+ ctx.arc(x, y, radius, 0, Math.PI * 2);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'triangle':
+ ctx.beginPath();
+ edgeLength = 3 * radius / Math.sqrt(3);
+ height = edgeLength * Math.sqrt(3) / 2;
+ ctx.moveTo(x - edgeLength / 2, y + height / 3);
+ ctx.lineTo(x + edgeLength / 2, y + height / 3);
+ ctx.lineTo(x, y - 2 * height / 3);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'rect':
+ size = 1 / Math.SQRT2 * radius;
+ ctx.beginPath();
+ ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
+ ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
+ break;
+ case 'rectRounded':
+ var offset = radius / Math.SQRT2;
+ var leftX = x - offset;
+ var topY = y - offset;
+ var sideSize = Math.SQRT2 * radius;
+ ctx.beginPath();
+ this.roundedRect(ctx, leftX, topY, sideSize, sideSize, radius / 2);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'rectRot':
+ size = 1 / Math.SQRT2 * radius;
+ ctx.beginPath();
+ ctx.moveTo(x - size, y);
+ ctx.lineTo(x, y + size);
+ ctx.lineTo(x + size, y);
+ ctx.lineTo(x, y - size);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'cross':
+ ctx.beginPath();
+ ctx.moveTo(x, y + radius);
+ ctx.lineTo(x, y - radius);
+ ctx.moveTo(x - radius, y);
+ ctx.lineTo(x + radius, y);
+ ctx.closePath();
+ break;
+ case 'crossRot':
+ ctx.beginPath();
+ xOffset = Math.cos(Math.PI / 4) * radius;
+ yOffset = Math.sin(Math.PI / 4) * radius;
+ ctx.moveTo(x - xOffset, y - yOffset);
+ ctx.lineTo(x + xOffset, y + yOffset);
+ ctx.moveTo(x - xOffset, y + yOffset);
+ ctx.lineTo(x + xOffset, y - yOffset);
+ ctx.closePath();
+ break;
+ case 'star':
+ ctx.beginPath();
+ ctx.moveTo(x, y + radius);
+ ctx.lineTo(x, y - radius);
+ ctx.moveTo(x - radius, y);
+ ctx.lineTo(x + radius, y);
+ xOffset = Math.cos(Math.PI / 4) * radius;
+ yOffset = Math.sin(Math.PI / 4) * radius;
+ ctx.moveTo(x - xOffset, y - yOffset);
+ ctx.lineTo(x + xOffset, y + yOffset);
+ ctx.moveTo(x - xOffset, y + yOffset);
+ ctx.lineTo(x + xOffset, y - yOffset);
+ ctx.closePath();
+ break;
+ case 'line':
+ ctx.beginPath();
+ ctx.moveTo(x - radius, y);
+ ctx.lineTo(x + radius, y);
+ ctx.closePath();
+ break;
+ case 'dash':
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ ctx.lineTo(x + radius, y);
+ ctx.closePath();
+ break;
+ }
+
+ ctx.stroke();
+ },
+
+ clipArea: function(ctx, area) {
+ ctx.save();
+ ctx.beginPath();
+ ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);
+ ctx.clip();
+ },
+
+ unclipArea: function(ctx) {
+ ctx.restore();
+ },
+
+ lineTo: function(ctx, previous, target, flip) {
+ if (target.steppedLine) {
+ if ((target.steppedLine === 'after' && !flip) || (target.steppedLine !== 'after' && flip)) {
+ ctx.lineTo(previous.x, target.y);
+ } else {
+ ctx.lineTo(target.x, previous.y);
+ }
+ ctx.lineTo(target.x, target.y);
+ return;
+ }
+
+ if (!target.tension) {
+ ctx.lineTo(target.x, target.y);
+ return;
+ }
+
+ ctx.bezierCurveTo(
+ flip ? previous.controlPointPreviousX : previous.controlPointNextX,
+ flip ? previous.controlPointPreviousY : previous.controlPointNextY,
+ flip ? target.controlPointNextX : target.controlPointPreviousX,
+ flip ? target.controlPointNextY : target.controlPointPreviousY,
+ target.x,
+ target.y);
+ }
+};
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.canvas.clear instead.
+ * @namespace Chart.helpers.clear
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.clear = exports.clear;
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.canvas.roundedRect instead.
+ * @namespace Chart.helpers.drawRoundedRectangle
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.drawRoundedRectangle = function(ctx) {
+ ctx.beginPath();
+ exports.roundedRect.apply(exports, arguments);
+ ctx.closePath();
+};
+
+},{"42":42}],42:[function(require,module,exports){
+'use strict';
+
+/**
+ * @namespace Chart.helpers
+ */
+var helpers = {
+ /**
+ * An empty function that can be used, for example, for optional callback.
+ */
+ noop: function() {},
+
+ /**
+ * Returns a unique id, sequentially generated from a global variable.
+ * @returns {Number}
+ * @function
+ */
+ uid: (function() {
+ var id = 0;
+ return function() {
+ return id++;
+ };
+ }()),
+
+ /**
+ * Returns true if `value` is neither null nor undefined, else returns false.
+ * @param {*} value - The value to test.
+ * @returns {Boolean}
+ * @since 2.7.0
+ */
+ isNullOrUndef: function(value) {
+ return value === null || typeof value === 'undefined';
+ },
+
+ /**
+ * Returns true if `value` is an array, else returns false.
+ * @param {*} value - The value to test.
+ * @returns {Boolean}
+ * @function
+ */
+ isArray: Array.isArray ? Array.isArray : function(value) {
+ return Object.prototype.toString.call(value) === '[object Array]';
+ },
+
+ /**
+ * Returns true if `value` is an object (excluding null), else returns false.
+ * @param {*} value - The value to test.
+ * @returns {Boolean}
+ * @since 2.7.0
+ */
+ isObject: function(value) {
+ return value !== null && Object.prototype.toString.call(value) === '[object Object]';
+ },
+
+ /**
+ * Returns `value` if defined, else returns `defaultValue`.
+ * @param {*} value - The value to return if defined.
+ * @param {*} defaultValue - The value to return if `value` is undefined.
+ * @returns {*}
+ */
+ valueOrDefault: function(value, defaultValue) {
+ return typeof value === 'undefined' ? defaultValue : value;
+ },
+
+ /**
+ * Returns value at the given `index` in array if defined, else returns `defaultValue`.
+ * @param {Array} value - The array to lookup for value at `index`.
+ * @param {Number} index - The index in `value` to lookup for value.
+ * @param {*} defaultValue - The value to return if `value[index]` is undefined.
+ * @returns {*}
+ */
+ valueAtIndexOrDefault: function(value, index, defaultValue) {
+ return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : value, defaultValue);
+ },
+
+ /**
+ * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
+ * value returned by `fn`. If `fn` is not a function, this method returns undefined.
+ * @param {Function} fn - The function to call.
+ * @param {Array|undefined|null} args - The arguments with which `fn` should be called.
+ * @param {Object} [thisArg] - The value of `this` provided for the call to `fn`.
+ * @returns {*}
+ */
+ callback: function(fn, args, thisArg) {
+ if (fn && typeof fn.call === 'function') {
+ return fn.apply(thisArg, args);
+ }
+ },
+
+ /**
+ * Note(SB) for performance sake, this method should only be used when loopable type
+ * is unknown or in none intensive code (not called often and small loopable). Else
+ * it's preferable to use a regular for() loop and save extra function calls.
+ * @param {Object|Array} loopable - The object or array to be iterated.
+ * @param {Function} fn - The function to call for each item.
+ * @param {Object} [thisArg] - The value of `this` provided for the call to `fn`.
+ * @param {Boolean} [reverse] - If true, iterates backward on the loopable.
+ */
+ each: function(loopable, fn, thisArg, reverse) {
+ var i, len, keys;
+ if (helpers.isArray(loopable)) {
+ len = loopable.length;
+ if (reverse) {
+ for (i = len - 1; i >= 0; i--) {
+ fn.call(thisArg, loopable[i], i);
+ }
+ } else {
+ for (i = 0; i < len; i++) {
+ fn.call(thisArg, loopable[i], i);
+ }
+ }
+ } else if (helpers.isObject(loopable)) {
+ keys = Object.keys(loopable);
+ len = keys.length;
+ for (i = 0; i < len; i++) {
+ fn.call(thisArg, loopable[keys[i]], keys[i]);
+ }
+ }
+ },
+
+ /**
+ * Returns true if the `a0` and `a1` arrays have the same content, else returns false.
+ * @see http://stackoverflow.com/a/14853974
+ * @param {Array} a0 - The array to compare
+ * @param {Array} a1 - The array to compare
+ * @returns {Boolean}
+ */
+ arrayEquals: function(a0, a1) {
+ var i, ilen, v0, v1;
+
+ if (!a0 || !a1 || a0.length !== a1.length) {
+ return false;
+ }
+
+ for (i = 0, ilen = a0.length; i < ilen; ++i) {
+ v0 = a0[i];
+ v1 = a1[i];
+
+ if (v0 instanceof Array && v1 instanceof Array) {
+ if (!helpers.arrayEquals(v0, v1)) {
+ return false;
+ }
+ } else if (v0 !== v1) {
+ // NOTE: two different object instances will never be equal: {x:20} != {x:20}
+ return false;
+ }
+ }
+
+ return true;
+ },
+
+ /**
+ * Returns a deep copy of `source` without keeping references on objects and arrays.
+ * @param {*} source - The value to clone.
+ * @returns {*}
+ */
+ clone: function(source) {
+ if (helpers.isArray(source)) {
+ return source.map(helpers.clone);
+ }
+
+ if (helpers.isObject(source)) {
+ var target = {};
+ var keys = Object.keys(source);
+ var klen = keys.length;
+ var k = 0;
+
+ for (; k < klen; ++k) {
+ target[keys[k]] = helpers.clone(source[keys[k]]);
+ }
+
+ return target;
+ }
+
+ return source;
+ },
+
+ /**
+ * The default merger when Chart.helpers.merge is called without merger option.
+ * Note(SB): this method is also used by configMerge and scaleMerge as fallback.
+ * @private
+ */
+ _merger: function(key, target, source, options) {
+ var tval = target[key];
+ var sval = source[key];
+
+ if (helpers.isObject(tval) && helpers.isObject(sval)) {
+ helpers.merge(tval, sval, options);
+ } else {
+ target[key] = helpers.clone(sval);
+ }
+ },
+
+ /**
+ * Merges source[key] in target[key] only if target[key] is undefined.
+ * @private
+ */
+ _mergerIf: function(key, target, source) {
+ var tval = target[key];
+ var sval = source[key];
+
+ if (helpers.isObject(tval) && helpers.isObject(sval)) {
+ helpers.mergeIf(tval, sval);
+ } else if (!target.hasOwnProperty(key)) {
+ target[key] = helpers.clone(sval);
+ }
+ },
+
+ /**
+ * Recursively deep copies `source` properties into `target` with the given `options`.
+ * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
+ * @param {Object} target - The target object in which all sources are merged into.
+ * @param {Object|Array(Object)} source - Object(s) to merge into `target`.
+ * @param {Object} [options] - Merging options:
+ * @param {Function} [options.merger] - The merge method (key, target, source, options)
+ * @returns {Object} The `target` object.
+ */
+ merge: function(target, source, options) {
+ var sources = helpers.isArray(source) ? source : [source];
+ var ilen = sources.length;
+ var merge, i, keys, klen, k;
+
+ if (!helpers.isObject(target)) {
+ return target;
+ }
+
+ options = options || {};
+ merge = options.merger || helpers._merger;
+
+ for (i = 0; i < ilen; ++i) {
+ source = sources[i];
+ if (!helpers.isObject(source)) {
+ continue;
+ }
+
+ keys = Object.keys(source);
+ for (k = 0, klen = keys.length; k < klen; ++k) {
+ merge(keys[k], target, source, options);
+ }
+ }
+
+ return target;
+ },
+
+ /**
+ * Recursively deep copies `source` properties into `target` *only* if not defined in target.
+ * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
+ * @param {Object} target - The target object in which all sources are merged into.
+ * @param {Object|Array(Object)} source - Object(s) to merge into `target`.
+ * @returns {Object} The `target` object.
+ */
+ mergeIf: function(target, source) {
+ return helpers.merge(target, source, {merger: helpers._mergerIf});
+ },
+
+ /**
+ * Applies the contents of two or more objects together into the first object.
+ * @param {Object} target - The target object in which all objects are merged into.
+ * @param {Object} arg1 - Object containing additional properties to merge in target.
+ * @param {Object} argN - Additional objects containing properties to merge in target.
+ * @returns {Object} The `target` object.
+ */
+ extend: function(target) {
+ var setFn = function(value, key) {
+ target[key] = value;
+ };
+ for (var i = 1, ilen = arguments.length; i < ilen; ++i) {
+ helpers.each(arguments[i], setFn);
+ }
+ return target;
+ },
+
+ /**
+ * Basic javascript inheritance based on the model created in Backbone.js
+ */
+ inherits: function(extensions) {
+ var me = this;
+ var ChartElement = (extensions && extensions.hasOwnProperty('constructor')) ? extensions.constructor : function() {
+ return me.apply(this, arguments);
+ };
+
+ var Surrogate = function() {
+ this.constructor = ChartElement;
+ };
+
+ Surrogate.prototype = me.prototype;
+ ChartElement.prototype = new Surrogate();
+ ChartElement.extend = helpers.inherits;
+
+ if (extensions) {
+ helpers.extend(ChartElement.prototype, extensions);
+ }
+
+ ChartElement.__super__ = me.prototype;
+ return ChartElement;
+ }
+};
+
+module.exports = helpers;
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.callback instead.
+ * @function Chart.helpers.callCallback
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.callCallback = helpers.callback;
+
+/**
+ * Provided for backward compatibility, use Array.prototype.indexOf instead.
+ * Array.prototype.indexOf compatibility: Chrome, Opera, Safari, FF1.5+, IE9+
+ * @function Chart.helpers.indexOf
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.indexOf = function(array, item, fromIndex) {
+ return Array.prototype.indexOf.call(array, item, fromIndex);
+};
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.valueOrDefault instead.
+ * @function Chart.helpers.getValueOrDefault
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.getValueOrDefault = helpers.valueOrDefault;
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.valueAtIndexOrDefault instead.
+ * @function Chart.helpers.getValueAtIndexOrDefault
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.getValueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+
+},{}],43:[function(require,module,exports){
+'use strict';
+
+var helpers = require(42);
+
+/**
+ * Easing functions adapted from Robert Penner's easing equations.
+ * @namespace Chart.helpers.easingEffects
+ * @see http://www.robertpenner.com/easing/
+ */
+var effects = {
+ linear: function(t) {
+ return t;
+ },
+
+ easeInQuad: function(t) {
+ return t * t;
+ },
+
+ easeOutQuad: function(t) {
+ return -t * (t - 2);
+ },
+
+ easeInOutQuad: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t;
+ }
+ return -0.5 * ((--t) * (t - 2) - 1);
+ },
+
+ easeInCubic: function(t) {
+ return t * t * t;
+ },
+
+ easeOutCubic: function(t) {
+ return (t = t - 1) * t * t + 1;
+ },
+
+ easeInOutCubic: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t * t;
+ }
+ return 0.5 * ((t -= 2) * t * t + 2);
+ },
+
+ easeInQuart: function(t) {
+ return t * t * t * t;
+ },
+
+ easeOutQuart: function(t) {
+ return -((t = t - 1) * t * t * t - 1);
+ },
+
+ easeInOutQuart: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t * t * t;
+ }
+ return -0.5 * ((t -= 2) * t * t * t - 2);
+ },
+
+ easeInQuint: function(t) {
+ return t * t * t * t * t;
+ },
+
+ easeOutQuint: function(t) {
+ return (t = t - 1) * t * t * t * t + 1;
+ },
+
+ easeInOutQuint: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t * t * t * t;
+ }
+ return 0.5 * ((t -= 2) * t * t * t * t + 2);
+ },
+
+ easeInSine: function(t) {
+ return -Math.cos(t * (Math.PI / 2)) + 1;
+ },
+
+ easeOutSine: function(t) {
+ return Math.sin(t * (Math.PI / 2));
+ },
+
+ easeInOutSine: function(t) {
+ return -0.5 * (Math.cos(Math.PI * t) - 1);
+ },
+
+ easeInExpo: function(t) {
+ return (t === 0) ? 0 : Math.pow(2, 10 * (t - 1));
+ },
+
+ easeOutExpo: function(t) {
+ return (t === 1) ? 1 : -Math.pow(2, -10 * t) + 1;
+ },
+
+ easeInOutExpo: function(t) {
+ if (t === 0) {
+ return 0;
+ }
+ if (t === 1) {
+ return 1;
+ }
+ if ((t /= 0.5) < 1) {
+ return 0.5 * Math.pow(2, 10 * (t - 1));
+ }
+ return 0.5 * (-Math.pow(2, -10 * --t) + 2);
+ },
+
+ easeInCirc: function(t) {
+ if (t >= 1) {
+ return t;
+ }
+ return -(Math.sqrt(1 - t * t) - 1);
+ },
+
+ easeOutCirc: function(t) {
+ return Math.sqrt(1 - (t = t - 1) * t);
+ },
+
+ easeInOutCirc: function(t) {
+ if ((t /= 0.5) < 1) {
+ return -0.5 * (Math.sqrt(1 - t * t) - 1);
+ }
+ return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
+ },
+
+ easeInElastic: function(t) {
+ var s = 1.70158;
+ var p = 0;
+ var a = 1;
+ if (t === 0) {
+ return 0;
+ }
+ if (t === 1) {
+ return 1;
+ }
+ if (!p) {
+ p = 0.3;
+ }
+ if (a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p / (2 * Math.PI) * Math.asin(1 / a);
+ }
+ return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
+ },
+
+ easeOutElastic: function(t) {
+ var s = 1.70158;
+ var p = 0;
+ var a = 1;
+ if (t === 0) {
+ return 0;
+ }
+ if (t === 1) {
+ return 1;
+ }
+ if (!p) {
+ p = 0.3;
+ }
+ if (a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p / (2 * Math.PI) * Math.asin(1 / a);
+ }
+ return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) + 1;
+ },
+
+ easeInOutElastic: function(t) {
+ var s = 1.70158;
+ var p = 0;
+ var a = 1;
+ if (t === 0) {
+ return 0;
+ }
+ if ((t /= 0.5) === 2) {
+ return 1;
+ }
+ if (!p) {
+ p = 0.45;
+ }
+ if (a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p / (2 * Math.PI) * Math.asin(1 / a);
+ }
+ if (t < 1) {
+ return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
+ }
+ return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p) * 0.5 + 1;
+ },
+ easeInBack: function(t) {
+ var s = 1.70158;
+ return t * t * ((s + 1) * t - s);
+ },
+
+ easeOutBack: function(t) {
+ var s = 1.70158;
+ return (t = t - 1) * t * ((s + 1) * t + s) + 1;
+ },
+
+ easeInOutBack: function(t) {
+ var s = 1.70158;
+ if ((t /= 0.5) < 1) {
+ return 0.5 * (t * t * (((s *= (1.525)) + 1) * t - s));
+ }
+ return 0.5 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
+ },
+
+ easeInBounce: function(t) {
+ return 1 - effects.easeOutBounce(1 - t);
+ },
+
+ easeOutBounce: function(t) {
+ if (t < (1 / 2.75)) {
+ return 7.5625 * t * t;
+ }
+ if (t < (2 / 2.75)) {
+ return 7.5625 * (t -= (1.5 / 2.75)) * t + 0.75;
+ }
+ if (t < (2.5 / 2.75)) {
+ return 7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375;
+ }
+ return 7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375;
+ },
+
+ easeInOutBounce: function(t) {
+ if (t < 0.5) {
+ return effects.easeInBounce(t * 2) * 0.5;
+ }
+ return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5;
+ }
+};
+
+module.exports = {
+ effects: effects
+};
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.easing.effects instead.
+ * @function Chart.helpers.easingEffects
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.easingEffects = effects;
+
+},{"42":42}],44:[function(require,module,exports){
+'use strict';
+
+var helpers = require(42);
+
+/**
+ * @alias Chart.helpers.options
+ * @namespace
+ */
+module.exports = {
+ /**
+ * Converts the given line height `value` in pixels for a specific font `size`.
+ * @param {Number|String} value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').
+ * @param {Number} size - The font size (in pixels) used to resolve relative `value`.
+ * @returns {Number} The effective line height in pixels (size * 1.2 if value is invalid).
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
+ * @since 2.7.0
+ */
+ toLineHeight: function(value, size) {
+ var matches = ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);
+ if (!matches || matches[1] === 'normal') {
+ return size * 1.2;
+ }
+
+ value = +matches[2];
+
+ switch (matches[3]) {
+ case 'px':
+ return value;
+ case '%':
+ value /= 100;
+ break;
+ default:
+ break;
+ }
+
+ return size * value;
+ },
+
+ /**
+ * Converts the given value into a padding object with pre-computed width/height.
+ * @param {Number|Object} value - If a number, set the value to all TRBL component,
+ * else, if and object, use defined properties and sets undefined ones to 0.
+ * @returns {Object} The padding values (top, right, bottom, left, width, height)
+ * @since 2.7.0
+ */
+ toPadding: function(value) {
+ var t, r, b, l;
+
+ if (helpers.isObject(value)) {
+ t = +value.top || 0;
+ r = +value.right || 0;
+ b = +value.bottom || 0;
+ l = +value.left || 0;
+ } else {
+ t = r = b = l = +value || 0;
+ }
+
+ return {
+ top: t,
+ right: r,
+ bottom: b,
+ left: l,
+ height: t + b,
+ width: l + r
+ };
+ },
+
+ /**
+ * Evaluates the given `inputs` sequentially and returns the first defined value.
+ * @param {Array[]} inputs - An array of values, falling back to the last value.
+ * @param {Object} [context] - If defined and the current value is a function, the value
+ * is called with `context` as first argument and the result becomes the new input.
+ * @param {Number} [index] - If defined and the current value is an array, the value
+ * at `index` become the new input.
+ * @since 2.7.0
+ */
+ resolve: function(inputs, context, index) {
+ var i, ilen, value;
+
+ for (i = 0, ilen = inputs.length; i < ilen; ++i) {
+ value = inputs[i];
+ if (value === undefined) {
+ continue;
+ }
+ if (context !== undefined && typeof value === 'function') {
+ value = value(context);
+ }
+ if (index !== undefined && helpers.isArray(value)) {
+ value = value[index];
+ }
+ if (value !== undefined) {
+ return value;
+ }
+ }
+ }
+};
+
+},{"42":42}],45:[function(require,module,exports){
+'use strict';
+
+module.exports = require(42);
+module.exports.easing = require(43);
+module.exports.canvas = require(41);
+module.exports.options = require(44);
+
+},{"41":41,"42":42,"43":43,"44":44}],46:[function(require,module,exports){
+/**
+ * Platform fallback implementation (minimal).
+ * @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-319575939
+ */
+
+module.exports = {
+ acquireContext: function(item) {
+ if (item && item.canvas) {
+ // Support for any object associated to a canvas (including a context2d)
+ item = item.canvas;
+ }
+
+ return item && item.getContext('2d') || null;
+ }
+};
+
+},{}],47:[function(require,module,exports){
+/**
+ * Chart.Platform implementation for targeting a web browser
+ */
+
+'use strict';
+
+var helpers = require(45);
+
+var EXPANDO_KEY = '$chartjs';
+var CSS_PREFIX = 'chartjs-';
+var CSS_RENDER_MONITOR = CSS_PREFIX + 'render-monitor';
+var CSS_RENDER_ANIMATION = CSS_PREFIX + 'render-animation';
+var ANIMATION_START_EVENTS = ['animationstart', 'webkitAnimationStart'];
+
+/**
+ * DOM event types -> Chart.js event types.
+ * Note: only events with different types are mapped.
+ * @see https://developer.mozilla.org/en-US/docs/Web/Events
+ */
+var EVENT_TYPES = {
+ touchstart: 'mousedown',
+ touchmove: 'mousemove',
+ touchend: 'mouseup',
+ pointerenter: 'mouseenter',
+ pointerdown: 'mousedown',
+ pointermove: 'mousemove',
+ pointerup: 'mouseup',
+ pointerleave: 'mouseout',
+ pointerout: 'mouseout'
+};
+
+/**
+ * The "used" size is the final value of a dimension property after all calculations have
+ * been performed. This method uses the computed style of `element` but returns undefined
+ * if the computed style is not expressed in pixels. That can happen in some cases where
+ * `element` has a size relative to its parent and this last one is not yet displayed,
+ * for example because of `display: none` on a parent node.
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
+ * @returns {Number} Size in pixels or undefined if unknown.
+ */
+function readUsedSize(element, property) {
+ var value = helpers.getStyle(element, property);
+ var matches = value && value.match(/^(\d+)(\.\d+)?px$/);
+ return matches ? Number(matches[1]) : undefined;
+}
+
+/**
+ * Initializes the canvas style and render size without modifying the canvas display size,
+ * since responsiveness is handled by the controller.resize() method. The config is used
+ * to determine the aspect ratio to apply in case no explicit height has been specified.
+ */
+function initCanvas(canvas, config) {
+ var style = canvas.style;
+
+ // NOTE(SB) canvas.getAttribute('width') !== canvas.width: in the first case it
+ // returns null or '' if no explicit value has been set to the canvas attribute.
+ var renderHeight = canvas.getAttribute('height');
+ var renderWidth = canvas.getAttribute('width');
+
+ // Chart.js modifies some canvas values that we want to restore on destroy
+ canvas[EXPANDO_KEY] = {
+ initial: {
+ height: renderHeight,
+ width: renderWidth,
+ style: {
+ display: style.display,
+ height: style.height,
+ width: style.width
+ }
+ }
+ };
+
+ // Force canvas to display as block to avoid extra space caused by inline
+ // elements, which would interfere with the responsive resize process.
+ // https://github.com/chartjs/Chart.js/issues/2538
+ style.display = style.display || 'block';
+
+ if (renderWidth === null || renderWidth === '') {
+ var displayWidth = readUsedSize(canvas, 'width');
+ if (displayWidth !== undefined) {
+ canvas.width = displayWidth;
+ }
+ }
+
+ if (renderHeight === null || renderHeight === '') {
+ if (canvas.style.height === '') {
+ // If no explicit render height and style height, let's apply the aspect ratio,
+ // which one can be specified by the user but also by charts as default option
+ // (i.e. options.aspectRatio). If not specified, use canvas aspect ratio of 2.
+ canvas.height = canvas.width / (config.options.aspectRatio || 2);
+ } else {
+ var displayHeight = readUsedSize(canvas, 'height');
+ if (displayWidth !== undefined) {
+ canvas.height = displayHeight;
+ }
+ }
+ }
+
+ return canvas;
+}
+
+/**
+ * Detects support for options object argument in addEventListener.
+ * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
+ * @private
+ */
+var supportsEventListenerOptions = (function() {
+ var supports = false;
+ try {
+ var options = Object.defineProperty({}, 'passive', {
+ get: function() {
+ supports = true;
+ }
+ });
+ window.addEventListener('e', null, options);
+ } catch (e) {
+ // continue regardless of error
+ }
+ return supports;
+}());
+
+// Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
+// https://github.com/chartjs/Chart.js/issues/4287
+var eventListenerOptions = supportsEventListenerOptions ? {passive: true} : false;
+
+function addEventListener(node, type, listener) {
+ node.addEventListener(type, listener, eventListenerOptions);
+}
+
+function removeEventListener(node, type, listener) {
+ node.removeEventListener(type, listener, eventListenerOptions);
+}
+
+function createEvent(type, chart, x, y, nativeEvent) {
+ return {
+ type: type,
+ chart: chart,
+ native: nativeEvent || null,
+ x: x !== undefined ? x : null,
+ y: y !== undefined ? y : null,
+ };
+}
+
+function fromNativeEvent(event, chart) {
+ var type = EVENT_TYPES[event.type] || event.type;
+ var pos = helpers.getRelativePosition(event, chart);
+ return createEvent(type, chart, pos.x, pos.y, event);
+}
+
+function throttled(fn, thisArg) {
+ var ticking = false;
+ var args = [];
+
+ return function() {
+ args = Array.prototype.slice.call(arguments);
+ thisArg = thisArg || this;
+
+ if (!ticking) {
+ ticking = true;
+ helpers.requestAnimFrame.call(window, function() {
+ ticking = false;
+ fn.apply(thisArg, args);
+ });
+ }
+ };
+}
+
+// Implementation based on https://github.com/marcj/css-element-queries
+function createResizer(handler) {
+ var resizer = document.createElement('div');
+ var cls = CSS_PREFIX + 'size-monitor';
+ var maxSize = 1000000;
+ var style =
+ 'position:absolute;' +
+ 'left:0;' +
+ 'top:0;' +
+ 'right:0;' +
+ 'bottom:0;' +
+ 'overflow:hidden;' +
+ 'pointer-events:none;' +
+ 'visibility:hidden;' +
+ 'z-index:-1;';
+
+ resizer.style.cssText = style;
+ resizer.className = cls;
+ resizer.innerHTML =
+ '<div class="' + cls + '-expand" style="' + style + '">' +
+ '<div style="' +
+ 'position:absolute;' +
+ 'width:' + maxSize + 'px;' +
+ 'height:' + maxSize + 'px;' +
+ 'left:0;' +
+ 'top:0">' +
+ '</div>' +
+ '</div>' +
+ '<div class="' + cls + '-shrink" style="' + style + '">' +
+ '<div style="' +
+ 'position:absolute;' +
+ 'width:200%;' +
+ 'height:200%;' +
+ 'left:0; ' +
+ 'top:0">' +
+ '</div>' +
+ '</div>';
+
+ var expand = resizer.childNodes[0];
+ var shrink = resizer.childNodes[1];
+
+ resizer._reset = function() {
+ expand.scrollLeft = maxSize;
+ expand.scrollTop = maxSize;
+ shrink.scrollLeft = maxSize;
+ shrink.scrollTop = maxSize;
+ };
+ var onScroll = function() {
+ resizer._reset();
+ handler();
+ };
+
+ addEventListener(expand, 'scroll', onScroll.bind(expand, 'expand'));
+ addEventListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink'));
+
+ return resizer;
+}
+
+// https://davidwalsh.name/detect-node-insertion
+function watchForRender(node, handler) {
+ var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
+ var proxy = expando.renderProxy = function(e) {
+ if (e.animationName === CSS_RENDER_ANIMATION) {
+ handler();
+ }
+ };
+
+ helpers.each(ANIMATION_START_EVENTS, function(type) {
+ addEventListener(node, type, proxy);
+ });
+
+ // #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR class
+ // is removed then added back immediately (same animation frame?). Accessing the
+ // `offsetParent` property will force a reflow and re-evaluate the CSS animation.
+ // https://gist.github.com/paulirish/5d52fb081b3570c81e3a#box-metrics
+ // https://github.com/chartjs/Chart.js/issues/4737
+ expando.reflow = !!node.offsetParent;
+
+ node.classList.add(CSS_RENDER_MONITOR);
+}
+
+function unwatchForRender(node) {
+ var expando = node[EXPANDO_KEY] || {};
+ var proxy = expando.renderProxy;
+
+ if (proxy) {
+ helpers.each(ANIMATION_START_EVENTS, function(type) {
+ removeEventListener(node, type, proxy);
+ });
+
+ delete expando.renderProxy;
+ }
+
+ node.classList.remove(CSS_RENDER_MONITOR);
+}
+
+function addResizeListener(node, listener, chart) {
+ var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
+
+ // Let's keep track of this added resizer and thus avoid DOM query when removing it.
+ var resizer = expando.resizer = createResizer(throttled(function() {
+ if (expando.resizer) {
+ return listener(createEvent('resize', chart));
+ }
+ }));
+
+ // The resizer needs to be attached to the node parent, so we first need to be
+ // sure that `node` is attached to the DOM before injecting the resizer element.
+ watchForRender(node, function() {
+ if (expando.resizer) {
+ var container = node.parentNode;
+ if (container && container !== resizer.parentNode) {
+ container.insertBefore(resizer, container.firstChild);
+ }
+
+ // The container size might have changed, let's reset the resizer state.
+ resizer._reset();
+ }
+ });
+}
+
+function removeResizeListener(node) {
+ var expando = node[EXPANDO_KEY] || {};
+ var resizer = expando.resizer;
+
+ delete expando.resizer;
+ unwatchForRender(node);
+
+ if (resizer && resizer.parentNode) {
+ resizer.parentNode.removeChild(resizer);
+ }
+}
+
+function injectCSS(platform, css) {
+ // http://stackoverflow.com/q/3922139
+ var style = platform._style || document.createElement('style');
+ if (!platform._style) {
+ platform._style = style;
+ css = '/* Chart.js */\n' + css;
+ style.setAttribute('type', 'text/css');
+ document.getElementsByTagName('head')[0].appendChild(style);
+ }
+
+ style.appendChild(document.createTextNode(css));
+}
+
+module.exports = {
+ /**
+ * This property holds whether this platform is enabled for the current environment.
+ * Currently used by platform.js to select the proper implementation.
+ * @private
+ */
+ _enabled: typeof window !== 'undefined' && typeof document !== 'undefined',
+
+ initialize: function() {
+ var keyframes = 'from{opacity:0.99}to{opacity:1}';
+
+ injectCSS(this,
+ // DOM rendering detection
+ // https://davidwalsh.name/detect-node-insertion
+ '@-webkit-keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
+ '@keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
+ '.' + CSS_RENDER_MONITOR + '{' +
+ '-webkit-animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
+ 'animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
+ '}'
+ );
+ },
+
+ acquireContext: function(item, config) {
+ if (typeof item === 'string') {
+ item = document.getElementById(item);
+ } else if (item.length) {
+ // Support for array based queries (such as jQuery)
+ item = item[0];
+ }
+
+ if (item && item.canvas) {
+ // Support for any object associated to a canvas (including a context2d)
+ item = item.canvas;
+ }
+
+ // To prevent canvas fingerprinting, some add-ons undefine the getContext
+ // method, for example: https://github.com/kkapsner/CanvasBlocker
+ // https://github.com/chartjs/Chart.js/issues/2807
+ var context = item && item.getContext && item.getContext('2d');
+
+ // `instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when the item is
+ // inside an iframe or when running in a protected environment. We could guess the
+ // types from their toString() value but let's keep things flexible and assume it's
+ // a sufficient condition if the item has a context2D which has item as `canvas`.
+ // https://github.com/chartjs/Chart.js/issues/3887
+ // https://github.com/chartjs/Chart.js/issues/4102
+ // https://github.com/chartjs/Chart.js/issues/4152
+ if (context && context.canvas === item) {
+ initCanvas(item, config);
+ return context;
+ }
+
+ return null;
+ },
+
+ releaseContext: function(context) {
+ var canvas = context.canvas;
+ if (!canvas[EXPANDO_KEY]) {
+ return;
+ }
+
+ var initial = canvas[EXPANDO_KEY].initial;
+ ['height', 'width'].forEach(function(prop) {
+ var value = initial[prop];
+ if (helpers.isNullOrUndef(value)) {
+ canvas.removeAttribute(prop);
+ } else {
+ canvas.setAttribute(prop, value);
+ }
+ });
+
+ helpers.each(initial.style || {}, function(value, key) {
+ canvas.style[key] = value;
+ });
+
+ // The canvas render size might have been changed (and thus the state stack discarded),
+ // we can't use save() and restore() to restore the initial state. So make sure that at
+ // least the canvas context is reset to the default state by setting the canvas width.
+ // https://www.w3.org/TR/2011/WD-html5-20110525/the-canvas-element.html
+ canvas.width = canvas.width;
+
+ delete canvas[EXPANDO_KEY];
+ },
+
+ addEventListener: function(chart, type, listener) {
+ var canvas = chart.canvas;
+ if (type === 'resize') {
+ // Note: the resize event is not supported on all browsers.
+ addResizeListener(canvas, listener, chart);
+ return;
+ }
+
+ var expando = listener[EXPANDO_KEY] || (listener[EXPANDO_KEY] = {});
+ var proxies = expando.proxies || (expando.proxies = {});
+ var proxy = proxies[chart.id + '_' + type] = function(event) {
+ listener(fromNativeEvent(event, chart));
+ };
+
+ addEventListener(canvas, type, proxy);
+ },
+
+ removeEventListener: function(chart, type, listener) {
+ var canvas = chart.canvas;
+ if (type === 'resize') {
+ // Note: the resize event is not supported on all browsers.
+ removeResizeListener(canvas, listener);
+ return;
+ }
+
+ var expando = listener[EXPANDO_KEY] || {};
+ var proxies = expando.proxies || {};
+ var proxy = proxies[chart.id + '_' + type];
+ if (!proxy) {
+ return;
+ }
+
+ removeEventListener(canvas, type, proxy);
+ }
+};
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use EventTarget.addEventListener instead.
+ * EventTarget.addEventListener compatibility: Chrome, Opera 7, Safari, FF1.5+, IE9+
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
+ * @function Chart.helpers.addEvent
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.addEvent = addEventListener;
+
+/**
+ * Provided for backward compatibility, use EventTarget.removeEventListener instead.
+ * EventTarget.removeEventListener compatibility: Chrome, Opera 7, Safari, FF1.5+, IE9+
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
+ * @function Chart.helpers.removeEvent
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.removeEvent = removeEventListener;
+
+},{"45":45}],48:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+var basic = require(46);
+var dom = require(47);
+
+// @TODO Make possible to select another platform at build time.
+var implementation = dom._enabled ? dom : basic;
+
+/**
+ * @namespace Chart.platform
+ * @see https://chartjs.gitbooks.io/proposals/content/Platform.html
+ * @since 2.4.0
+ */
+module.exports = helpers.extend({
+ /**
+ * @since 2.7.0
+ */
+ initialize: function() {},
+
+ /**
+ * Called at chart construction time, returns a context2d instance implementing
+ * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
+ * @param {*} item - The native item from which to acquire context (platform specific)
+ * @param {Object} options - The chart options
+ * @returns {CanvasRenderingContext2D} context2d instance
+ */
+ acquireContext: function() {},
+
+ /**
+ * Called at chart destruction time, releases any resources associated to the context
+ * previously returned by the acquireContext() method.
+ * @param {CanvasRenderingContext2D} context - The context2d instance
+ * @returns {Boolean} true if the method succeeded, else false
+ */
+ releaseContext: function() {},
+
+ /**
+ * Registers the specified listener on the given chart.
+ * @param {Chart} chart - Chart from which to listen for event
+ * @param {String} type - The ({@link IEvent}) type to listen for
+ * @param {Function} listener - Receives a notification (an object that implements
+ * the {@link IEvent} interface) when an event of the specified type occurs.
+ */
+ addEventListener: function() {},
+
+ /**
+ * Removes the specified listener previously registered with addEventListener.
+ * @param {Chart} chart -Chart from which to remove the listener
+ * @param {String} type - The ({@link IEvent}) type to remove
+ * @param {Function} listener - The listener function to remove from the event target.
+ */
+ removeEventListener: function() {}
+
+}, implementation);
+
+/**
+ * @interface IPlatform
+ * Allows abstracting platform dependencies away from the chart
+ * @borrows Chart.platform.acquireContext as acquireContext
+ * @borrows Chart.platform.releaseContext as releaseContext
+ * @borrows Chart.platform.addEventListener as addEventListener
+ * @borrows Chart.platform.removeEventListener as removeEventListener
+ */
+
+/**
+ * @interface IEvent
+ * @prop {String} type - The event type name, possible values are:
+ * 'contextmenu', 'mouseenter', 'mousedown', 'mousemove', 'mouseup', 'mouseout',
+ * 'click', 'dblclick', 'keydown', 'keypress', 'keyup' and 'resize'
+ * @prop {*} native - The original native event (null for emulated events, e.g. 'resize')
+ * @prop {Number} x - The mouse x position, relative to the canvas (null for incompatible events)
+ * @prop {Number} y - The mouse y position, relative to the canvas (null for incompatible events)
+ */
+
+},{"45":45,"46":46,"47":47}],49:[function(require,module,exports){
+/**
+ * Plugin based on discussion from the following Chart.js issues:
+ * @see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
+ * @see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897
+ */
+
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('global', {
+ plugins: {
+ filler: {
+ propagate: true
+ }
+ }
+});
+
+module.exports = function() {
+
+ var mappers = {
+ dataset: function(source) {
+ var index = source.fill;
+ var chart = source.chart;
+ var meta = chart.getDatasetMeta(index);
+ var visible = meta && chart.isDatasetVisible(index);
+ var points = (visible && meta.dataset._children) || [];
+ var length = points.length || 0;
+
+ return !length ? null : function(point, i) {
+ return (i < length && points[i]._view) || null;
+ };
+ },
+
+ boundary: function(source) {
+ var boundary = source.boundary;
+ var x = boundary ? boundary.x : null;
+ var y = boundary ? boundary.y : null;
+
+ return function(point) {
+ return {
+ x: x === null ? point.x : x,
+ y: y === null ? point.y : y,
+ };
+ };
+ }
+ };
+
+ // @todo if (fill[0] === '#')
+ function decodeFill(el, index, count) {
+ var model = el._model || {};
+ var fill = model.fill;
+ var target;
+
+ if (fill === undefined) {
+ fill = !!model.backgroundColor;
+ }
+
+ if (fill === false || fill === null) {
+ return false;
+ }
+
+ if (fill === true) {
+ return 'origin';
+ }
+
+ target = parseFloat(fill, 10);
+ if (isFinite(target) && Math.floor(target) === target) {
+ if (fill[0] === '-' || fill[0] === '+') {
+ target = index + target;
+ }
+
+ if (target === index || target < 0 || target >= count) {
+ return false;
+ }
+
+ return target;
+ }
+
+ switch (fill) {
+ // compatibility
+ case 'bottom':
+ return 'start';
+ case 'top':
+ return 'end';
+ case 'zero':
+ return 'origin';
+ // supported boundaries
+ case 'origin':
+ case 'start':
+ case 'end':
+ return fill;
+ // invalid fill values
+ default:
+ return false;
+ }
+ }
+
+ function computeBoundary(source) {
+ var model = source.el._model || {};
+ var scale = source.el._scale || {};
+ var fill = source.fill;
+ var target = null;
+ var horizontal;
+
+ if (isFinite(fill)) {
+ return null;
+ }
+
+ // Backward compatibility: until v3, we still need to support boundary values set on
+ // the model (scaleTop, scaleBottom and scaleZero) because some external plugins and
+ // controllers might still use it (e.g. the Smith chart).
+
+ if (fill === 'start') {
+ target = model.scaleBottom === undefined ? scale.bottom : model.scaleBottom;
+ } else if (fill === 'end') {
+ target = model.scaleTop === undefined ? scale.top : model.scaleTop;
+ } else if (model.scaleZero !== undefined) {
+ target = model.scaleZero;
+ } else if (scale.getBasePosition) {
+ target = scale.getBasePosition();
+ } else if (scale.getBasePixel) {
+ target = scale.getBasePixel();
+ }
+
+ if (target !== undefined && target !== null) {
+ if (target.x !== undefined && target.y !== undefined) {
+ return target;
+ }
+
+ if (typeof target === 'number' && isFinite(target)) {
+ horizontal = scale.isHorizontal();
+ return {
+ x: horizontal ? target : null,
+ y: horizontal ? null : target
+ };
+ }
+ }
+
+ return null;
+ }
+
+ function resolveTarget(sources, index, propagate) {
+ var source = sources[index];
+ var fill = source.fill;
+ var visited = [index];
+ var target;
+
+ if (!propagate) {
+ return fill;
+ }
+
+ while (fill !== false && visited.indexOf(fill) === -1) {
+ if (!isFinite(fill)) {
+ return fill;
+ }
+
+ target = sources[fill];
+ if (!target) {
+ return false;
+ }
+
+ if (target.visible) {
+ return fill;
+ }
+
+ visited.push(fill);
+ fill = target.fill;
+ }
+
+ return false;
+ }
+
+ function createMapper(source) {
+ var fill = source.fill;
+ var type = 'dataset';
+
+ if (fill === false) {
+ return null;
+ }
+
+ if (!isFinite(fill)) {
+ type = 'boundary';
+ }
+
+ return mappers[type](source);
+ }
+
+ function isDrawable(point) {
+ return point && !point.skip;
+ }
+
+ function drawArea(ctx, curve0, curve1, len0, len1) {
+ var i;
+
+ if (!len0 || !len1) {
+ return;
+ }
+
+ // building first area curve (normal)
+ ctx.moveTo(curve0[0].x, curve0[0].y);
+ for (i = 1; i < len0; ++i) {
+ helpers.canvas.lineTo(ctx, curve0[i - 1], curve0[i]);
+ }
+
+ // joining the two area curves
+ ctx.lineTo(curve1[len1 - 1].x, curve1[len1 - 1].y);
+
+ // building opposite area curve (reverse)
+ for (i = len1 - 1; i > 0; --i) {
+ helpers.canvas.lineTo(ctx, curve1[i], curve1[i - 1], true);
+ }
+ }
+
+ function doFill(ctx, points, mapper, view, color, loop) {
+ var count = points.length;
+ var span = view.spanGaps;
+ var curve0 = [];
+ var curve1 = [];
+ var len0 = 0;
+ var len1 = 0;
+ var i, ilen, index, p0, p1, d0, d1;
+
+ ctx.beginPath();
+
+ for (i = 0, ilen = (count + !!loop); i < ilen; ++i) {
+ index = i % count;
+ p0 = points[index]._view;
+ p1 = mapper(p0, index, view);
+ d0 = isDrawable(p0);
+ d1 = isDrawable(p1);
+
+ if (d0 && d1) {
+ len0 = curve0.push(p0);
+ len1 = curve1.push(p1);
+ } else if (len0 && len1) {
+ if (!span) {
+ drawArea(ctx, curve0, curve1, len0, len1);
+ len0 = len1 = 0;
+ curve0 = [];
+ curve1 = [];
+ } else {
+ if (d0) {
+ curve0.push(p0);
+ }
+ if (d1) {
+ curve1.push(p1);
+ }
+ }
+ }
+ }
+
+ drawArea(ctx, curve0, curve1, len0, len1);
+
+ ctx.closePath();
+ ctx.fillStyle = color;
+ ctx.fill();
+ }
+
+ return {
+ id: 'filler',
+
+ afterDatasetsUpdate: function(chart, options) {
+ var count = (chart.data.datasets || []).length;
+ var propagate = options.propagate;
+ var sources = [];
+ var meta, i, el, source;
+
+ for (i = 0; i < count; ++i) {
+ meta = chart.getDatasetMeta(i);
+ el = meta.dataset;
+ source = null;
+
+ if (el && el._model && el instanceof elements.Line) {
+ source = {
+ visible: chart.isDatasetVisible(i),
+ fill: decodeFill(el, i, count),
+ chart: chart,
+ el: el
+ };
+ }
+
+ meta.$filler = source;
+ sources.push(source);
+ }
+
+ for (i = 0; i < count; ++i) {
+ source = sources[i];
+ if (!source) {
+ continue;
+ }
+
+ source.fill = resolveTarget(sources, i, propagate);
+ source.boundary = computeBoundary(source);
+ source.mapper = createMapper(source);
+ }
+ },
+
+ beforeDatasetDraw: function(chart, args) {
+ var meta = args.meta.$filler;
+ if (!meta) {
+ return;
+ }
+
+ var ctx = chart.ctx;
+ var el = meta.el;
+ var view = el._view;
+ var points = el._children || [];
+ var mapper = meta.mapper;
+ var color = view.backgroundColor || defaults.global.defaultColor;
+
+ if (mapper && color && points.length) {
+ helpers.canvas.clipArea(ctx, chart.chartArea);
+ doFill(ctx, points, mapper, view, color, el._loop);
+ helpers.canvas.unclipArea(ctx);
+ }
+ }
+ };
+};
+
+},{"25":25,"40":40,"45":45}],50:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ legend: {
+ display: true,
+ position: 'top',
+ fullWidth: true,
+ reverse: false,
+ weight: 1000,
+
+ // a callback that will handle
+ onClick: function(e, legendItem) {
+ var index = legendItem.datasetIndex;
+ var ci = this.chart;
+ var meta = ci.getDatasetMeta(index);
+
+ // See controller.isDatasetVisible comment
+ meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
+
+ // We hid a dataset ... rerender the chart
+ ci.update();
+ },
+
+ onHover: null,
+
+ labels: {
+ boxWidth: 40,
+ padding: 10,
+ // Generates labels shown in the legend
+ // Valid properties to return:
+ // text : text to display
+ // fillStyle : fill of coloured box
+ // strokeStyle: stroke of coloured box
+ // hidden : if this legend item refers to a hidden item
+ // lineCap : cap style for line
+ // lineDash
+ // lineDashOffset :
+ // lineJoin :
+ // lineWidth :
+ generateLabels: function(chart) {
+ var data = chart.data;
+ return helpers.isArray(data.datasets) ? data.datasets.map(function(dataset, i) {
+ return {
+ text: dataset.label,
+ fillStyle: (!helpers.isArray(dataset.backgroundColor) ? dataset.backgroundColor : dataset.backgroundColor[0]),
+ hidden: !chart.isDatasetVisible(i),
+ lineCap: dataset.borderCapStyle,
+ lineDash: dataset.borderDash,
+ lineDashOffset: dataset.borderDashOffset,
+ lineJoin: dataset.borderJoinStyle,
+ lineWidth: dataset.borderWidth,
+ strokeStyle: dataset.borderColor,
+ pointStyle: dataset.pointStyle,
+
+ // Below is extra data used for toggling the datasets
+ datasetIndex: i
+ };
+ }, this) : [];
+ }
+ }
+ },
+
+ legendCallback: function(chart) {
+ var text = [];
+ text.push('<ul class="' + chart.id + '-legend">');
+ for (var i = 0; i < chart.data.datasets.length; i++) {
+ text.push('<li><span style="background-color:' + chart.data.datasets[i].backgroundColor + '"></span>');
+ if (chart.data.datasets[i].label) {
+ text.push(chart.data.datasets[i].label);
+ }
+ text.push('</li>');
+ }
+ text.push('</ul>');
+ return text.join('');
+ }
+});
+
+module.exports = function(Chart) {
+
+ var layout = Chart.layoutService;
+ var noop = helpers.noop;
+
+ /**
+ * Helper function to get the box width based on the usePointStyle option
+ * @param labelopts {Object} the label options on the legend
+ * @param fontSize {Number} the label font size
+ * @return {Number} width of the color box area
+ */
+ function getBoxWidth(labelOpts, fontSize) {
+ return labelOpts.usePointStyle ?
+ fontSize * Math.SQRT2 :
+ labelOpts.boxWidth;
+ }
+
+ Chart.Legend = Element.extend({
+
+ initialize: function(config) {
+ helpers.extend(this, config);
+
+ // Contains hit boxes for each dataset (in dataset order)
+ this.legendHitBoxes = [];
+
+ // Are we in doughnut mode which has a different data type
+ this.doughnutMode = false;
+ },
+
+ // These methods are ordered by lifecycle. Utilities then follow.
+ // Any function defined here is inherited by all legend types.
+ // Any function can be extended by the legend type
+
+ beforeUpdate: noop,
+ update: function(maxWidth, maxHeight, margins) {
+ var me = this;
+
+ // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
+ me.beforeUpdate();
+
+ // Absorb the master measurements
+ me.maxWidth = maxWidth;
+ me.maxHeight = maxHeight;
+ me.margins = margins;
+
+ // Dimensions
+ me.beforeSetDimensions();
+ me.setDimensions();
+ me.afterSetDimensions();
+ // Labels
+ me.beforeBuildLabels();
+ me.buildLabels();
+ me.afterBuildLabels();
+
+ // Fit
+ me.beforeFit();
+ me.fit();
+ me.afterFit();
+ //
+ me.afterUpdate();
+
+ return me.minSize;
+ },
+ afterUpdate: noop,
+
+ //
+
+ beforeSetDimensions: noop,
+ setDimensions: function() {
+ var me = this;
+ // Set the unconstrained dimension before label rotation
+ if (me.isHorizontal()) {
+ // Reset position before calculating rotation
+ me.width = me.maxWidth;
+ me.left = 0;
+ me.right = me.width;
+ } else {
+ me.height = me.maxHeight;
+
+ // Reset position before calculating rotation
+ me.top = 0;
+ me.bottom = me.height;
+ }
+
+ // Reset padding
+ me.paddingLeft = 0;
+ me.paddingTop = 0;
+ me.paddingRight = 0;
+ me.paddingBottom = 0;
+
+ // Reset minSize
+ me.minSize = {
+ width: 0,
+ height: 0
+ };
+ },
+ afterSetDimensions: noop,
+
+ //
+
+ beforeBuildLabels: noop,
+ buildLabels: function() {
+ var me = this;
+ var labelOpts = me.options.labels || {};
+ var legendItems = helpers.callback(labelOpts.generateLabels, [me.chart], me) || [];
+
+ if (labelOpts.filter) {
+ legendItems = legendItems.filter(function(item) {
+ return labelOpts.filter(item, me.chart.data);
+ });
+ }
+
+ if (me.options.reverse) {
+ legendItems.reverse();
+ }
+
+ me.legendItems = legendItems;
+ },
+ afterBuildLabels: noop,
+
+ //
+
+ beforeFit: noop,
+ fit: function() {
+ var me = this;
+ var opts = me.options;
+ var labelOpts = opts.labels;
+ var display = opts.display;
+
+ var ctx = me.ctx;
+
+ var globalDefault = defaults.global;
+ var valueOrDefault = helpers.valueOrDefault;
+ var fontSize = valueOrDefault(labelOpts.fontSize, globalDefault.defaultFontSize);
+ var fontStyle = valueOrDefault(labelOpts.fontStyle, globalDefault.defaultFontStyle);
+ var fontFamily = valueOrDefault(labelOpts.fontFamily, globalDefault.defaultFontFamily);
+ var labelFont = helpers.fontString(fontSize, fontStyle, fontFamily);
+
+ // Reset hit boxes
+ var hitboxes = me.legendHitBoxes = [];
+
+ var minSize = me.minSize;
+ var isHorizontal = me.isHorizontal();
+
+ if (isHorizontal) {
+ minSize.width = me.maxWidth; // fill all the width
+ minSize.height = display ? 10 : 0;
+ } else {
+ minSize.width = display ? 10 : 0;
+ minSize.height = me.maxHeight; // fill all the height
+ }
+
+ // Increase sizes here
+ if (display) {
+ ctx.font = labelFont;
+
+ if (isHorizontal) {
+ // Labels
+
+ // Width of each line of legend boxes. Labels wrap onto multiple lines when there are too many to fit on one
+ var lineWidths = me.lineWidths = [0];
+ var totalHeight = me.legendItems.length ? fontSize + (labelOpts.padding) : 0;
+
+ ctx.textAlign = 'left';
+ ctx.textBaseline = 'top';
+
+ helpers.each(me.legendItems, function(legendItem, i) {
+ var boxWidth = getBoxWidth(labelOpts, fontSize);
+ var width = boxWidth + (fontSize / 2) + ctx.measureText(legendItem.text).width;
+
+ if (lineWidths[lineWidths.length - 1] + width + labelOpts.padding >= me.width) {
+ totalHeight += fontSize + (labelOpts.padding);
+ lineWidths[lineWidths.length] = me.left;
+ }
+
+ // Store the hitbox width and height here. Final position will be updated in `draw`
+ hitboxes[i] = {
+ left: 0,
+ top: 0,
+ width: width,
+ height: fontSize
+ };
+
+ lineWidths[lineWidths.length - 1] += width + labelOpts.padding;
+ });
+
+ minSize.height += totalHeight;
+
+ } else {
+ var vPadding = labelOpts.padding;
+ var columnWidths = me.columnWidths = [];
+ var totalWidth = labelOpts.padding;
+ var currentColWidth = 0;
+ var currentColHeight = 0;
+ var itemHeight = fontSize + vPadding;
+
+ helpers.each(me.legendItems, function(legendItem, i) {
+ var boxWidth = getBoxWidth(labelOpts, fontSize);
+ var itemWidth = boxWidth + (fontSize / 2) + ctx.measureText(legendItem.text).width;
+
+ // If too tall, go to new column
+ if (currentColHeight + itemHeight > minSize.height) {
+ totalWidth += currentColWidth + labelOpts.padding;
+ columnWidths.push(currentColWidth); // previous column width
+
+ currentColWidth = 0;
+ currentColHeight = 0;
+ }
+
+ // Get max width
+ currentColWidth = Math.max(currentColWidth, itemWidth);
+ currentColHeight += itemHeight;
+
+ // Store the hitbox width and height here. Final position will be updated in `draw`
+ hitboxes[i] = {
+ left: 0,
+ top: 0,
+ width: itemWidth,
+ height: fontSize
+ };
+ });
+
+ totalWidth += currentColWidth;
+ columnWidths.push(currentColWidth);
+ minSize.width += totalWidth;
+ }
+ }
+
+ me.width = minSize.width;
+ me.height = minSize.height;
+ },
+ afterFit: noop,
+
+ // Shared Methods
+ isHorizontal: function() {
+ return this.options.position === 'top' || this.options.position === 'bottom';
+ },
+
+ // Actually draw the legend on the canvas
+ draw: function() {
+ var me = this;
+ var opts = me.options;
+ var labelOpts = opts.labels;
+ var globalDefault = defaults.global;
+ var lineDefault = globalDefault.elements.line;
+ var legendWidth = me.width;
+ var lineWidths = me.lineWidths;
+
+ if (opts.display) {
+ var ctx = me.ctx;
+ var valueOrDefault = helpers.valueOrDefault;
+ var fontColor = valueOrDefault(labelOpts.fontColor, globalDefault.defaultFontColor);
+ var fontSize = valueOrDefault(labelOpts.fontSize, globalDefault.defaultFontSize);
+ var fontStyle = valueOrDefault(labelOpts.fontStyle, globalDefault.defaultFontStyle);
+ var fontFamily = valueOrDefault(labelOpts.fontFamily, globalDefault.defaultFontFamily);
+ var labelFont = helpers.fontString(fontSize, fontStyle, fontFamily);
+ var cursor;
+
+ // Canvas setup
+ ctx.textAlign = 'left';
+ ctx.textBaseline = 'middle';
+ ctx.lineWidth = 0.5;
+ ctx.strokeStyle = fontColor; // for strikethrough effect
+ ctx.fillStyle = fontColor; // render in correct colour
+ ctx.font = labelFont;
+
+ var boxWidth = getBoxWidth(labelOpts, fontSize);
+ var hitboxes = me.legendHitBoxes;
+
+ // current position
+ var drawLegendBox = function(x, y, legendItem) {
+ if (isNaN(boxWidth) || boxWidth <= 0) {
+ return;
+ }
+
+ // Set the ctx for the box
+ ctx.save();
+
+ ctx.fillStyle = valueOrDefault(legendItem.fillStyle, globalDefault.defaultColor);
+ ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle);
+ ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset);
+ ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle);
+ ctx.lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth);
+ ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, globalDefault.defaultColor);
+ var isLineWidthZero = (valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth) === 0);
+
+ if (ctx.setLineDash) {
+ // IE 9 and 10 do not support line dash
+ ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash));
+ }
+
+ if (opts.labels && opts.labels.usePointStyle) {
+ // Recalculate x and y for drawPoint() because its expecting
+ // x and y to be center of figure (instead of top left)
+ var radius = fontSize * Math.SQRT2 / 2;
+ var offSet = radius / Math.SQRT2;
+ var centerX = x + offSet;
+ var centerY = y + offSet;
+
+ // Draw pointStyle as legend symbol
+ helpers.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY);
+ } else {
+ // Draw box as legend symbol
+ if (!isLineWidthZero) {
+ ctx.strokeRect(x, y, boxWidth, fontSize);
+ }
+ ctx.fillRect(x, y, boxWidth, fontSize);
+ }
+
+ ctx.restore();
+ };
+ var fillText = function(x, y, legendItem, textWidth) {
+ var halfFontSize = fontSize / 2;
+ var xLeft = boxWidth + halfFontSize + x;
+ var yMiddle = y + halfFontSize;
+
+ ctx.fillText(legendItem.text, xLeft, yMiddle);
+
+ if (legendItem.hidden) {
+ // Strikethrough the text if hidden
+ ctx.beginPath();
+ ctx.lineWidth = 2;
+ ctx.moveTo(xLeft, yMiddle);
+ ctx.lineTo(xLeft + textWidth, yMiddle);
+ ctx.stroke();
+ }
+ };
+
+ // Horizontal
+ var isHorizontal = me.isHorizontal();
+ if (isHorizontal) {
+ cursor = {
+ x: me.left + ((legendWidth - lineWidths[0]) / 2),
+ y: me.top + labelOpts.padding,
+ line: 0
+ };
+ } else {
+ cursor = {
+ x: me.left + labelOpts.padding,
+ y: me.top + labelOpts.padding,
+ line: 0
+ };
+ }
+
+ var itemHeight = fontSize + labelOpts.padding;
+ helpers.each(me.legendItems, function(legendItem, i) {
+ var textWidth = ctx.measureText(legendItem.text).width;
+ var width = boxWidth + (fontSize / 2) + textWidth;
+ var x = cursor.x;
+ var y = cursor.y;
+
+ if (isHorizontal) {
+ if (x + width >= legendWidth) {
+ y = cursor.y += itemHeight;
+ cursor.line++;
+ x = cursor.x = me.left + ((legendWidth - lineWidths[cursor.line]) / 2);
+ }
+ } else if (y + itemHeight > me.bottom) {
+ x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding;
+ y = cursor.y = me.top + labelOpts.padding;
+ cursor.line++;
+ }
+
+ drawLegendBox(x, y, legendItem);
+
+ hitboxes[i].left = x;
+ hitboxes[i].top = y;
+
+ // Fill the actual label
+ fillText(x, y, legendItem, textWidth);
+
+ if (isHorizontal) {
+ cursor.x += width + (labelOpts.padding);
+ } else {
+ cursor.y += itemHeight;
+ }
+
+ });
+ }
+ },
+
+ /**
+ * Handle an event
+ * @private
+ * @param {IEvent} event - The event to handle
+ * @return {Boolean} true if a change occured
+ */
+ handleEvent: function(e) {
+ var me = this;
+ var opts = me.options;
+ var type = e.type === 'mouseup' ? 'click' : e.type;
+ var changed = false;
+
+ if (type === 'mousemove') {
+ if (!opts.onHover) {
+ return;
+ }
+ } else if (type === 'click') {
+ if (!opts.onClick) {
+ return;
+ }
+ } else {
+ return;
+ }
+
+ // Chart event already has relative position in it
+ var x = e.x;
+ var y = e.y;
+
+ if (x >= me.left && x <= me.right && y >= me.top && y <= me.bottom) {
+ // See if we are touching one of the dataset boxes
+ var lh = me.legendHitBoxes;
+ for (var i = 0; i < lh.length; ++i) {
+ var hitBox = lh[i];
+
+ if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) {
+ // Touching an element
+ if (type === 'click') {
+ // use e.native for backwards compatibility
+ opts.onClick.call(me, e.native, me.legendItems[i]);
+ changed = true;
+ break;
+ } else if (type === 'mousemove') {
+ // use e.native for backwards compatibility
+ opts.onHover.call(me, e.native, me.legendItems[i]);
+ changed = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return changed;
+ }
+ });
+
+ function createNewLegendAndAttach(chart, legendOpts) {
+ var legend = new Chart.Legend({
+ ctx: chart.ctx,
+ options: legendOpts,
+ chart: chart
+ });
+
+ layout.configure(chart, legend, legendOpts);
+ layout.addBox(chart, legend);
+ chart.legend = legend;
+ }
+
+ return {
+ id: 'legend',
+
+ beforeInit: function(chart) {
+ var legendOpts = chart.options.legend;
+
+ if (legendOpts) {
+ createNewLegendAndAttach(chart, legendOpts);
+ }
+ },
+
+ beforeUpdate: function(chart) {
+ var legendOpts = chart.options.legend;
+ var legend = chart.legend;
+
+ if (legendOpts) {
+ helpers.mergeIf(legendOpts, defaults.global.legend);
+
+ if (legend) {
+ layout.configure(chart, legend, legendOpts);
+ legend.options = legendOpts;
+ } else {
+ createNewLegendAndAttach(chart, legendOpts);
+ }
+ } else if (legend) {
+ layout.removeBox(chart, legend);
+ delete chart.legend;
+ }
+ },
+
+ afterEvent: function(chart, e) {
+ var legend = chart.legend;
+ if (legend) {
+ legend.handleEvent(e);
+ }
+ }
+ };
+};
+
+},{"25":25,"26":26,"45":45}],51:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ title: {
+ display: false,
+ fontStyle: 'bold',
+ fullWidth: true,
+ lineHeight: 1.2,
+ padding: 10,
+ position: 'top',
+ text: '',
+ weight: 2000 // by default greater than legend (1000) to be above
+ }
+});
+
+module.exports = function(Chart) {
+
+ var layout = Chart.layoutService;
+ var noop = helpers.noop;
+
+ Chart.Title = Element.extend({
+ initialize: function(config) {
+ var me = this;
+ helpers.extend(me, config);
+
+ // Contains hit boxes for each dataset (in dataset order)
+ me.legendHitBoxes = [];
+ },
+
+ // These methods are ordered by lifecycle. Utilities then follow.
+
+ beforeUpdate: noop,
+ update: function(maxWidth, maxHeight, margins) {
+ var me = this;
+
+ // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
+ me.beforeUpdate();
+
+ // Absorb the master measurements
+ me.maxWidth = maxWidth;
+ me.maxHeight = maxHeight;
+ me.margins = margins;
+
+ // Dimensions
+ me.beforeSetDimensions();
+ me.setDimensions();
+ me.afterSetDimensions();
+ // Labels
+ me.beforeBuildLabels();
+ me.buildLabels();
+ me.afterBuildLabels();
+
+ // Fit
+ me.beforeFit();
+ me.fit();
+ me.afterFit();
+ //
+ me.afterUpdate();
+
+ return me.minSize;
+
+ },
+ afterUpdate: noop,
+
+ //
+
+ beforeSetDimensions: noop,
+ setDimensions: function() {
+ var me = this;
+ // Set the unconstrained dimension before label rotation
+ if (me.isHorizontal()) {
+ // Reset position before calculating rotation
+ me.width = me.maxWidth;
+ me.left = 0;
+ me.right = me.width;
+ } else {
+ me.height = me.maxHeight;
+
+ // Reset position before calculating rotation
+ me.top = 0;
+ me.bottom = me.height;
+ }
+
+ // Reset padding
+ me.paddingLeft = 0;
+ me.paddingTop = 0;
+ me.paddingRight = 0;
+ me.paddingBottom = 0;
+
+ // Reset minSize
+ me.minSize = {
+ width: 0,
+ height: 0
+ };
+ },
+ afterSetDimensions: noop,
+
+ //
+
+ beforeBuildLabels: noop,
+ buildLabels: noop,
+ afterBuildLabels: noop,
+
+ //
+
+ beforeFit: noop,
+ fit: function() {
+ var me = this;
+ var valueOrDefault = helpers.valueOrDefault;
+ var opts = me.options;
+ var display = opts.display;
+ var fontSize = valueOrDefault(opts.fontSize, defaults.global.defaultFontSize);
+ var minSize = me.minSize;
+ var lineCount = helpers.isArray(opts.text) ? opts.text.length : 1;
+ var lineHeight = helpers.options.toLineHeight(opts.lineHeight, fontSize);
+ var textSize = display ? (lineCount * lineHeight) + (opts.padding * 2) : 0;
+
+ if (me.isHorizontal()) {
+ minSize.width = me.maxWidth; // fill all the width
+ minSize.height = textSize;
+ } else {
+ minSize.width = textSize;
+ minSize.height = me.maxHeight; // fill all the height
+ }
+
+ me.width = minSize.width;
+ me.height = minSize.height;
+
+ },
+ afterFit: noop,
+
+ // Shared Methods
+ isHorizontal: function() {
+ var pos = this.options.position;
+ return pos === 'top' || pos === 'bottom';
+ },
+
+ // Actually draw the title block on the canvas
+ draw: function() {
+ var me = this;
+ var ctx = me.ctx;
+ var valueOrDefault = helpers.valueOrDefault;
+ var opts = me.options;
+ var globalDefaults = defaults.global;
+
+ if (opts.display) {
+ var fontSize = valueOrDefault(opts.fontSize, globalDefaults.defaultFontSize);
+ var fontStyle = valueOrDefault(opts.fontStyle, globalDefaults.defaultFontStyle);
+ var fontFamily = valueOrDefault(opts.fontFamily, globalDefaults.defaultFontFamily);
+ var titleFont = helpers.fontString(fontSize, fontStyle, fontFamily);
+ var lineHeight = helpers.options.toLineHeight(opts.lineHeight, fontSize);
+ var offset = lineHeight / 2 + opts.padding;
+ var rotation = 0;
+ var top = me.top;
+ var left = me.left;
+ var bottom = me.bottom;
+ var right = me.right;
+ var maxWidth, titleX, titleY;
+
+ ctx.fillStyle = valueOrDefault(opts.fontColor, globalDefaults.defaultFontColor); // render in correct colour
+ ctx.font = titleFont;
+
+ // Horizontal
+ if (me.isHorizontal()) {
+ titleX = left + ((right - left) / 2); // midpoint of the width
+ titleY = top + offset;
+ maxWidth = right - left;
+ } else {
+ titleX = opts.position === 'left' ? left + offset : right - offset;
+ titleY = top + ((bottom - top) / 2);
+ maxWidth = bottom - top;
+ rotation = Math.PI * (opts.position === 'left' ? -0.5 : 0.5);
+ }
+
+ ctx.save();
+ ctx.translate(titleX, titleY);
+ ctx.rotate(rotation);
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+
+ var text = opts.text;
+ if (helpers.isArray(text)) {
+ var y = 0;
+ for (var i = 0; i < text.length; ++i) {
+ ctx.fillText(text[i], 0, y, maxWidth);
+ y += lineHeight;
+ }
+ } else {
+ ctx.fillText(text, 0, 0, maxWidth);
+ }
+
+ ctx.restore();
+ }
+ }
+ });
+
+ function createNewTitleBlockAndAttach(chart, titleOpts) {
+ var title = new Chart.Title({
+ ctx: chart.ctx,
+ options: titleOpts,
+ chart: chart
+ });
+
+ layout.configure(chart, title, titleOpts);
+ layout.addBox(chart, title);
+ chart.titleBlock = title;
+ }
+
+ return {
+ id: 'title',
+
+ beforeInit: function(chart) {
+ var titleOpts = chart.options.title;
+
+ if (titleOpts) {
+ createNewTitleBlockAndAttach(chart, titleOpts);
+ }
+ },
+
+ beforeUpdate: function(chart) {
+ var titleOpts = chart.options.title;
+ var titleBlock = chart.titleBlock;
+
+ if (titleOpts) {
+ helpers.mergeIf(titleOpts, defaults.global.title);
+
+ if (titleBlock) {
+ layout.configure(chart, titleBlock, titleOpts);
+ titleBlock.options = titleOpts;
+ } else {
+ createNewTitleBlockAndAttach(chart, titleOpts);
+ }
+ } else if (titleBlock) {
+ Chart.layoutService.removeBox(chart, titleBlock);
+ delete chart.titleBlock;
+ }
+ }
+ };
+};
+
+},{"25":25,"26":26,"45":45}],52:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ // Default config for a category scale
+ var defaultConfig = {
+ position: 'bottom'
+ };
+
+ var DatasetScale = Chart.Scale.extend({
+ /**
+ * Internal function to get the correct labels. If data.xLabels or data.yLabels are defined, use those
+ * else fall back to data.labels
+ * @private
+ */
+ getLabels: function() {
+ var data = this.chart.data;
+ return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
+ },
+
+ determineDataLimits: function() {
+ var me = this;
+ var labels = me.getLabels();
+ me.minIndex = 0;
+ me.maxIndex = labels.length - 1;
+ var findIndex;
+
+ if (me.options.ticks.min !== undefined) {
+ // user specified min value
+ findIndex = labels.indexOf(me.options.ticks.min);
+ me.minIndex = findIndex !== -1 ? findIndex : me.minIndex;
+ }
+
+ if (me.options.ticks.max !== undefined) {
+ // user specified max value
+ findIndex = labels.indexOf(me.options.ticks.max);
+ me.maxIndex = findIndex !== -1 ? findIndex : me.maxIndex;
+ }
+
+ me.min = labels[me.minIndex];
+ me.max = labels[me.maxIndex];
+ },
+
+ buildTicks: function() {
+ var me = this;
+ var labels = me.getLabels();
+ // If we are viewing some subset of labels, slice the original array
+ me.ticks = (me.minIndex === 0 && me.maxIndex === labels.length - 1) ? labels : labels.slice(me.minIndex, me.maxIndex + 1);
+ },
+
+ getLabelForIndex: function(index, datasetIndex) {
+ var me = this;
+ var data = me.chart.data;
+ var isHorizontal = me.isHorizontal();
+
+ if (data.yLabels && !isHorizontal) {
+ return me.getRightValue(data.datasets[datasetIndex].data[index]);
+ }
+ return me.ticks[index - me.minIndex];
+ },
+
+ // Used to get data value locations. Value can either be an index or a numerical value
+ getPixelForValue: function(value, index) {
+ var me = this;
+ var offset = me.options.offset;
+ // 1 is added because we need the length but we have the indexes
+ var offsetAmt = Math.max((me.maxIndex + 1 - me.minIndex - (offset ? 0 : 1)), 1);
+
+ // If value is a data object, then index is the index in the data array,
+ // not the index of the scale. We need to change that.
+ var valueCategory;
+ if (value !== undefined && value !== null) {
+ valueCategory = me.isHorizontal() ? value.x : value.y;
+ }
+ if (valueCategory !== undefined || (value !== undefined && isNaN(index))) {
+ var labels = me.getLabels();
+ value = valueCategory || value;
+ var idx = labels.indexOf(value);
+ index = idx !== -1 ? idx : index;
+ }
+
+ if (me.isHorizontal()) {
+ var valueWidth = me.width / offsetAmt;
+ var widthOffset = (valueWidth * (index - me.minIndex));
+
+ if (offset) {
+ widthOffset += (valueWidth / 2);
+ }
+
+ return me.left + Math.round(widthOffset);
+ }
+ var valueHeight = me.height / offsetAmt;
+ var heightOffset = (valueHeight * (index - me.minIndex));
+
+ if (offset) {
+ heightOffset += (valueHeight / 2);
+ }
+
+ return me.top + Math.round(heightOffset);
+ },
+ getPixelForTick: function(index) {
+ return this.getPixelForValue(this.ticks[index], index + this.minIndex, null);
+ },
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var offset = me.options.offset;
+ var value;
+ var offsetAmt = Math.max((me._ticks.length - (offset ? 0 : 1)), 1);
+ var horz = me.isHorizontal();
+ var valueDimension = (horz ? me.width : me.height) / offsetAmt;
+
+ pixel -= horz ? me.left : me.top;
+
+ if (offset) {
+ pixel -= (valueDimension / 2);
+ }
+
+ if (pixel <= 0) {
+ value = 0;
+ } else {
+ value = Math.round(pixel / valueDimension);
+ }
+
+ return value + me.minIndex;
+ },
+ getBasePixel: function() {
+ return this.bottom;
+ }
+ });
+
+ Chart.scaleService.registerScaleType('category', DatasetScale, defaultConfig);
+
+};
+
+},{}],53:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var defaultConfig = {
+ position: 'left',
+ ticks: {
+ callback: Ticks.formatters.linear
+ }
+ };
+
+ var LinearScale = Chart.LinearScaleBase.extend({
+
+ determineDataLimits: function() {
+ var me = this;
+ var opts = me.options;
+ var chart = me.chart;
+ var data = chart.data;
+ var datasets = data.datasets;
+ var isHorizontal = me.isHorizontal();
+ var DEFAULT_MIN = 0;
+ var DEFAULT_MAX = 1;
+
+ function IDMatches(meta) {
+ return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
+ }
+
+ // First Calculate the range
+ me.min = null;
+ me.max = null;
+
+ var hasStacks = opts.stacked;
+ if (hasStacks === undefined) {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ if (hasStacks) {
+ return;
+ }
+
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) &&
+ meta.stack !== undefined) {
+ hasStacks = true;
+ }
+ });
+ }
+
+ if (opts.stacked || hasStacks) {
+ var valuesPerStack = {};
+
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ var key = [
+ meta.type,
+ // we have a separate stack for stack=undefined datasets when the opts.stacked is undefined
+ ((opts.stacked === undefined && meta.stack === undefined) ? datasetIndex : ''),
+ meta.stack
+ ].join('.');
+
+ if (valuesPerStack[key] === undefined) {
+ valuesPerStack[key] = {
+ positiveValues: [],
+ negativeValues: []
+ };
+ }
+
+ // Store these per type
+ var positiveValues = valuesPerStack[key].positiveValues;
+ var negativeValues = valuesPerStack[key].negativeValues;
+
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ positiveValues[index] = positiveValues[index] || 0;
+ negativeValues[index] = negativeValues[index] || 0;
+
+ if (opts.relativePoints) {
+ positiveValues[index] = 100;
+ } else if (value < 0) {
+ negativeValues[index] += value;
+ } else {
+ positiveValues[index] += value;
+ }
+ });
+ }
+ });
+
+ helpers.each(valuesPerStack, function(valuesForType) {
+ var values = valuesForType.positiveValues.concat(valuesForType.negativeValues);
+ var minVal = helpers.min(values);
+ var maxVal = helpers.max(values);
+ me.min = me.min === null ? minVal : Math.min(me.min, minVal);
+ me.max = me.max === null ? maxVal : Math.max(me.max, maxVal);
+ });
+
+ } else {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ if (me.min === null) {
+ me.min = value;
+ } else if (value < me.min) {
+ me.min = value;
+ }
+
+ if (me.max === null) {
+ me.max = value;
+ } else if (value > me.max) {
+ me.max = value;
+ }
+ });
+ }
+ });
+ }
+
+ me.min = isFinite(me.min) && !isNaN(me.min) ? me.min : DEFAULT_MIN;
+ me.max = isFinite(me.max) && !isNaN(me.max) ? me.max : DEFAULT_MAX;
+
+ // Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
+ this.handleTickRangeOptions();
+ },
+ getTickLimit: function() {
+ var maxTicks;
+ var me = this;
+ var tickOpts = me.options.ticks;
+
+ if (me.isHorizontal()) {
+ maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.width / 50));
+ } else {
+ // The factor of 2 used to scale the font size has been experimentally determined.
+ var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, defaults.global.defaultFontSize);
+ maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.height / (2 * tickFontSize)));
+ }
+
+ return maxTicks;
+ },
+ // Called after the ticks are built. We need
+ handleDirectionalChanges: function() {
+ if (!this.isHorizontal()) {
+ // We are in a vertical orientation. The top value is the highest. So reverse the array
+ this.ticks.reverse();
+ }
+ },
+ getLabelForIndex: function(index, datasetIndex) {
+ return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
+ },
+ // Utils
+ getPixelForValue: function(value) {
+ // This must be called after fit has been run so that
+ // this.left, this.top, this.right, and this.bottom have been defined
+ var me = this;
+ var start = me.start;
+
+ var rightValue = +me.getRightValue(value);
+ var pixel;
+ var range = me.end - start;
+
+ if (me.isHorizontal()) {
+ pixel = me.left + (me.width / range * (rightValue - start));
+ return Math.round(pixel);
+ }
+
+ pixel = me.bottom - (me.height / range * (rightValue - start));
+ return Math.round(pixel);
+ },
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var isHorizontal = me.isHorizontal();
+ var innerDimension = isHorizontal ? me.width : me.height;
+ var offset = (isHorizontal ? pixel - me.left : me.bottom - pixel) / innerDimension;
+ return me.start + ((me.end - me.start) * offset);
+ },
+ getPixelForTick: function(index) {
+ return this.getPixelForValue(this.ticksAsNumbers[index]);
+ }
+ });
+ Chart.scaleService.registerScaleType('linear', LinearScale, defaultConfig);
+
+};
+
+},{"25":25,"34":34,"45":45}],54:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var noop = helpers.noop;
+
+ Chart.LinearScaleBase = Chart.Scale.extend({
+ getRightValue: function(value) {
+ if (typeof value === 'string') {
+ return +value;
+ }
+ return Chart.Scale.prototype.getRightValue.call(this, value);
+ },
+
+ handleTickRangeOptions: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+
+ // If we are forcing it to begin at 0, but 0 will already be rendered on the chart,
+ // do nothing since that would make the chart weird. If the user really wants a weird chart
+ // axis, they can manually override it
+ if (tickOpts.beginAtZero) {
+ var minSign = helpers.sign(me.min);
+ var maxSign = helpers.sign(me.max);
+
+ if (minSign < 0 && maxSign < 0) {
+ // move the top up to 0
+ me.max = 0;
+ } else if (minSign > 0 && maxSign > 0) {
+ // move the bottom down to 0
+ me.min = 0;
+ }
+ }
+
+ var setMin = tickOpts.min !== undefined || tickOpts.suggestedMin !== undefined;
+ var setMax = tickOpts.max !== undefined || tickOpts.suggestedMax !== undefined;
+
+ if (tickOpts.min !== undefined) {
+ me.min = tickOpts.min;
+ } else if (tickOpts.suggestedMin !== undefined) {
+ if (me.min === null) {
+ me.min = tickOpts.suggestedMin;
+ } else {
+ me.min = Math.min(me.min, tickOpts.suggestedMin);
+ }
+ }
+
+ if (tickOpts.max !== undefined) {
+ me.max = tickOpts.max;
+ } else if (tickOpts.suggestedMax !== undefined) {
+ if (me.max === null) {
+ me.max = tickOpts.suggestedMax;
+ } else {
+ me.max = Math.max(me.max, tickOpts.suggestedMax);
+ }
+ }
+
+ if (setMin !== setMax) {
+ // We set the min or the max but not both.
+ // So ensure that our range is good
+ // Inverted or 0 length range can happen when
+ // ticks.min is set, and no datasets are visible
+ if (me.min >= me.max) {
+ if (setMin) {
+ me.max = me.min + 1;
+ } else {
+ me.min = me.max - 1;
+ }
+ }
+ }
+
+ if (me.min === me.max) {
+ me.max++;
+
+ if (!tickOpts.beginAtZero) {
+ me.min--;
+ }
+ }
+ },
+ getTickLimit: noop,
+ handleDirectionalChanges: noop,
+
+ buildTicks: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+
+ // Figure out what the max number of ticks we can support it is based on the size of
+ // the axis area. For now, we say that the minimum tick spacing in pixels must be 50
+ // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
+ // the graph. Make sure we always have at least 2 ticks
+ var maxTicks = me.getTickLimit();
+ maxTicks = Math.max(2, maxTicks);
+
+ var numericGeneratorOptions = {
+ maxTicks: maxTicks,
+ min: tickOpts.min,
+ max: tickOpts.max,
+ stepSize: helpers.valueOrDefault(tickOpts.fixedStepSize, tickOpts.stepSize)
+ };
+ var ticks = me.ticks = Ticks.generators.linear(numericGeneratorOptions, me);
+
+ me.handleDirectionalChanges();
+
+ // At this point, we need to update our max and min given the tick values since we have expanded the
+ // range of the scale
+ me.max = helpers.max(ticks);
+ me.min = helpers.min(ticks);
+
+ if (tickOpts.reverse) {
+ ticks.reverse();
+
+ me.start = me.max;
+ me.end = me.min;
+ } else {
+ me.start = me.min;
+ me.end = me.max;
+ }
+ },
+ convertTicksToLabels: function() {
+ var me = this;
+ me.ticksAsNumbers = me.ticks.slice();
+ me.zeroLineIndex = me.ticks.indexOf(0);
+
+ Chart.Scale.prototype.convertTicksToLabels.call(me);
+ }
+ });
+};
+
+},{"34":34,"45":45}],55:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var defaultConfig = {
+ position: 'left',
+
+ // label settings
+ ticks: {
+ callback: Ticks.formatters.logarithmic
+ }
+ };
+
+ var LogarithmicScale = Chart.Scale.extend({
+ determineDataLimits: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ var chart = me.chart;
+ var data = chart.data;
+ var datasets = data.datasets;
+ var valueOrDefault = helpers.valueOrDefault;
+ var isHorizontal = me.isHorizontal();
+ function IDMatches(meta) {
+ return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
+ }
+
+ // Calculate Range
+ me.min = null;
+ me.max = null;
+ me.minNotZero = null;
+
+ var hasStacks = opts.stacked;
+ if (hasStacks === undefined) {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ if (hasStacks) {
+ return;
+ }
+
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) &&
+ meta.stack !== undefined) {
+ hasStacks = true;
+ }
+ });
+ }
+
+ if (opts.stacked || hasStacks) {
+ var valuesPerStack = {};
+
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ var key = [
+ meta.type,
+ // we have a separate stack for stack=undefined datasets when the opts.stacked is undefined
+ ((opts.stacked === undefined && meta.stack === undefined) ? datasetIndex : ''),
+ meta.stack
+ ].join('.');
+
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ if (valuesPerStack[key] === undefined) {
+ valuesPerStack[key] = [];
+ }
+
+ helpers.each(dataset.data, function(rawValue, index) {
+ var values = valuesPerStack[key];
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ values[index] = values[index] || 0;
+
+ if (opts.relativePoints) {
+ values[index] = 100;
+ } else {
+ // Don't need to split positive and negative since the log scale can't handle a 0 crossing
+ values[index] += value;
+ }
+ });
+ }
+ });
+
+ helpers.each(valuesPerStack, function(valuesForType) {
+ var minVal = helpers.min(valuesForType);
+ var maxVal = helpers.max(valuesForType);
+ me.min = me.min === null ? minVal : Math.min(me.min, minVal);
+ me.max = me.max === null ? maxVal : Math.max(me.max, maxVal);
+ });
+
+ } else {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ if (me.min === null) {
+ me.min = value;
+ } else if (value < me.min) {
+ me.min = value;
+ }
+
+ if (me.max === null) {
+ me.max = value;
+ } else if (value > me.max) {
+ me.max = value;
+ }
+
+ if (value !== 0 && (me.minNotZero === null || value < me.minNotZero)) {
+ me.minNotZero = value;
+ }
+ });
+ }
+ });
+ }
+
+ me.min = valueOrDefault(tickOpts.min, me.min);
+ me.max = valueOrDefault(tickOpts.max, me.max);
+
+ if (me.min === me.max) {
+ if (me.min !== 0 && me.min !== null) {
+ me.min = Math.pow(10, Math.floor(helpers.log10(me.min)) - 1);
+ me.max = Math.pow(10, Math.floor(helpers.log10(me.max)) + 1);
+ } else {
+ me.min = 1;
+ me.max = 10;
+ }
+ }
+ },
+ buildTicks: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+
+ var generationOptions = {
+ min: tickOpts.min,
+ max: tickOpts.max
+ };
+ var ticks = me.ticks = Ticks.generators.logarithmic(generationOptions, me);
+
+ if (!me.isHorizontal()) {
+ // We are in a vertical orientation. The top value is the highest. So reverse the array
+ ticks.reverse();
+ }
+
+ // At this point, we need to update our max and min given the tick values since we have expanded the
+ // range of the scale
+ me.max = helpers.max(ticks);
+ me.min = helpers.min(ticks);
+
+ if (tickOpts.reverse) {
+ ticks.reverse();
+
+ me.start = me.max;
+ me.end = me.min;
+ } else {
+ me.start = me.min;
+ me.end = me.max;
+ }
+ },
+ convertTicksToLabels: function() {
+ this.tickValues = this.ticks.slice();
+
+ Chart.Scale.prototype.convertTicksToLabels.call(this);
+ },
+ // Get the correct tooltip label
+ getLabelForIndex: function(index, datasetIndex) {
+ return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
+ },
+ getPixelForTick: function(index) {
+ return this.getPixelForValue(this.tickValues[index]);
+ },
+ getPixelForValue: function(value) {
+ var me = this;
+ var start = me.start;
+ var newVal = +me.getRightValue(value);
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ var innerDimension, pixel, range;
+
+ if (me.isHorizontal()) {
+ range = helpers.log10(me.end) - helpers.log10(start); // todo: if start === 0
+ if (newVal === 0) {
+ pixel = me.left;
+ } else {
+ innerDimension = me.width;
+ pixel = me.left + (innerDimension / range * (helpers.log10(newVal) - helpers.log10(start)));
+ }
+ } else {
+ // Bottom - top since pixels increase downward on a screen
+ innerDimension = me.height;
+ if (start === 0 && !tickOpts.reverse) {
+ range = helpers.log10(me.end) - helpers.log10(me.minNotZero);
+ if (newVal === start) {
+ pixel = me.bottom;
+ } else if (newVal === me.minNotZero) {
+ pixel = me.bottom - innerDimension * 0.02;
+ } else {
+ pixel = me.bottom - innerDimension * 0.02 - (innerDimension * 0.98 / range * (helpers.log10(newVal) - helpers.log10(me.minNotZero)));
+ }
+ } else if (me.end === 0 && tickOpts.reverse) {
+ range = helpers.log10(me.start) - helpers.log10(me.minNotZero);
+ if (newVal === me.end) {
+ pixel = me.top;
+ } else if (newVal === me.minNotZero) {
+ pixel = me.top + innerDimension * 0.02;
+ } else {
+ pixel = me.top + innerDimension * 0.02 + (innerDimension * 0.98 / range * (helpers.log10(newVal) - helpers.log10(me.minNotZero)));
+ }
+ } else if (newVal === 0) {
+ pixel = tickOpts.reverse ? me.top : me.bottom;
+ } else {
+ range = helpers.log10(me.end) - helpers.log10(start);
+ innerDimension = me.height;
+ pixel = me.bottom - (innerDimension / range * (helpers.log10(newVal) - helpers.log10(start)));
+ }
+ }
+ return pixel;
+ },
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var range = helpers.log10(me.end) - helpers.log10(me.start);
+ var value, innerDimension;
+
+ if (me.isHorizontal()) {
+ innerDimension = me.width;
+ value = me.start * Math.pow(10, (pixel - me.left) * range / innerDimension);
+ } else { // todo: if start === 0
+ innerDimension = me.height;
+ value = Math.pow(10, (me.bottom - pixel) * range / innerDimension) / me.start;
+ }
+ return value;
+ }
+ });
+ Chart.scaleService.registerScaleType('logarithmic', LogarithmicScale, defaultConfig);
+
+};
+
+},{"34":34,"45":45}],56:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var globalDefaults = defaults.global;
+
+ var defaultConfig = {
+ display: true,
+
+ // Boolean - Whether to animate scaling the chart from the centre
+ animate: true,
+ position: 'chartArea',
+
+ angleLines: {
+ display: true,
+ color: 'rgba(0, 0, 0, 0.1)',
+ lineWidth: 1
+ },
+
+ gridLines: {
+ circular: false
+ },
+
+ // label settings
+ ticks: {
+ // Boolean - Show a backdrop to the scale label
+ showLabelBackdrop: true,
+
+ // String - The colour of the label backdrop
+ backdropColor: 'rgba(255,255,255,0.75)',
+
+ // Number - The backdrop padding above & below the label in pixels
+ backdropPaddingY: 2,
+
+ // Number - The backdrop padding to the side of the label in pixels
+ backdropPaddingX: 2,
+
+ callback: Ticks.formatters.linear
+ },
+
+ pointLabels: {
+ // Boolean - if true, show point labels
+ display: true,
+
+ // Number - Point label font size in pixels
+ fontSize: 10,
+
+ // Function - Used to convert point labels
+ callback: function(label) {
+ return label;
+ }
+ }
+ };
+
+ function getValueCount(scale) {
+ var opts = scale.options;
+ return opts.angleLines.display || opts.pointLabels.display ? scale.chart.data.labels.length : 0;
+ }
+
+ function getPointLabelFontOptions(scale) {
+ var pointLabelOptions = scale.options.pointLabels;
+ var fontSize = helpers.valueOrDefault(pointLabelOptions.fontSize, globalDefaults.defaultFontSize);
+ var fontStyle = helpers.valueOrDefault(pointLabelOptions.fontStyle, globalDefaults.defaultFontStyle);
+ var fontFamily = helpers.valueOrDefault(pointLabelOptions.fontFamily, globalDefaults.defaultFontFamily);
+ var font = helpers.fontString(fontSize, fontStyle, fontFamily);
+
+ return {
+ size: fontSize,
+ style: fontStyle,
+ family: fontFamily,
+ font: font
+ };
+ }
+
+ function measureLabelSize(ctx, fontSize, label) {
+ if (helpers.isArray(label)) {
+ return {
+ w: helpers.longestText(ctx, ctx.font, label),
+ h: (label.length * fontSize) + ((label.length - 1) * 1.5 * fontSize)
+ };
+ }
+
+ return {
+ w: ctx.measureText(label).width,
+ h: fontSize
+ };
+ }
+
+ function determineLimits(angle, pos, size, min, max) {
+ if (angle === min || angle === max) {
+ return {
+ start: pos - (size / 2),
+ end: pos + (size / 2)
+ };
+ } else if (angle < min || angle > max) {
+ return {
+ start: pos - size - 5,
+ end: pos
+ };
+ }
+
+ return {
+ start: pos,
+ end: pos + size + 5
+ };
+ }
+
+ /**
+ * Helper function to fit a radial linear scale with point labels
+ */
+ function fitWithPointLabels(scale) {
+ /*
+ * Right, this is really confusing and there is a lot of maths going on here
+ * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
+ *
+ * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
+ *
+ * Solution:
+ *
+ * We assume the radius of the polygon is half the size of the canvas at first
+ * at each index we check if the text overlaps.
+ *
+ * Where it does, we store that angle and that index.
+ *
+ * After finding the largest index and angle we calculate how much we need to remove
+ * from the shape radius to move the point inwards by that x.
+ *
+ * We average the left and right distances to get the maximum shape radius that can fit in the box
+ * along with labels.
+ *
+ * Once we have that, we can find the centre point for the chart, by taking the x text protrusion
+ * on each side, removing that from the size, halving it and adding the left x protrusion width.
+ *
+ * This will mean we have a shape fitted to the canvas, as large as it can be with the labels
+ * and position it in the most space efficient manner
+ *
+ * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
+ */
+
+ var plFont = getPointLabelFontOptions(scale);
+
+ // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
+ // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
+ var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
+ var furthestLimits = {
+ r: scale.width,
+ l: 0,
+ t: scale.height,
+ b: 0
+ };
+ var furthestAngles = {};
+ var i, textSize, pointPosition;
+
+ scale.ctx.font = plFont.font;
+ scale._pointLabelSizes = [];
+
+ var valueCount = getValueCount(scale);
+ for (i = 0; i < valueCount; i++) {
+ pointPosition = scale.getPointPosition(i, largestPossibleRadius);
+ textSize = measureLabelSize(scale.ctx, plFont.size, scale.pointLabels[i] || '');
+ scale._pointLabelSizes[i] = textSize;
+
+ // Add quarter circle to make degree 0 mean top of circle
+ var angleRadians = scale.getIndexAngle(i);
+ var angle = helpers.toDegrees(angleRadians) % 360;
+ var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);
+ var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);
+
+ if (hLimits.start < furthestLimits.l) {
+ furthestLimits.l = hLimits.start;
+ furthestAngles.l = angleRadians;
+ }
+
+ if (hLimits.end > furthestLimits.r) {
+ furthestLimits.r = hLimits.end;
+ furthestAngles.r = angleRadians;
+ }
+
+ if (vLimits.start < furthestLimits.t) {
+ furthestLimits.t = vLimits.start;
+ furthestAngles.t = angleRadians;
+ }
+
+ if (vLimits.end > furthestLimits.b) {
+ furthestLimits.b = vLimits.end;
+ furthestAngles.b = angleRadians;
+ }
+ }
+
+ scale.setReductions(largestPossibleRadius, furthestLimits, furthestAngles);
+ }
+
+ /**
+ * Helper function to fit a radial linear scale with no point labels
+ */
+ function fit(scale) {
+ var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
+ scale.drawingArea = Math.round(largestPossibleRadius);
+ scale.setCenterPoint(0, 0, 0, 0);
+ }
+
+ function getTextAlignForAngle(angle) {
+ if (angle === 0 || angle === 180) {
+ return 'center';
+ } else if (angle < 180) {
+ return 'left';
+ }
+
+ return 'right';
+ }
+
+ function fillText(ctx, text, position, fontSize) {
+ if (helpers.isArray(text)) {
+ var y = position.y;
+ var spacing = 1.5 * fontSize;
+
+ for (var i = 0; i < text.length; ++i) {
+ ctx.fillText(text[i], position.x, y);
+ y += spacing;
+ }
+ } else {
+ ctx.fillText(text, position.x, position.y);
+ }
+ }
+
+ function adjustPointPositionForLabelHeight(angle, textSize, position) {
+ if (angle === 90 || angle === 270) {
+ position.y -= (textSize.h / 2);
+ } else if (angle > 270 || angle < 90) {
+ position.y -= textSize.h;
+ }
+ }
+
+ function drawPointLabels(scale) {
+ var ctx = scale.ctx;
+ var valueOrDefault = helpers.valueOrDefault;
+ var opts = scale.options;
+ var angleLineOpts = opts.angleLines;
+ var pointLabelOpts = opts.pointLabels;
+
+ ctx.lineWidth = angleLineOpts.lineWidth;
+ ctx.strokeStyle = angleLineOpts.color;
+
+ var outerDistance = scale.getDistanceFromCenterForValue(opts.ticks.reverse ? scale.min : scale.max);
+
+ // Point Label Font
+ var plFont = getPointLabelFontOptions(scale);
+
+ ctx.textBaseline = 'top';
+
+ for (var i = getValueCount(scale) - 1; i >= 0; i--) {
+ if (angleLineOpts.display) {
+ var outerPosition = scale.getPointPosition(i, outerDistance);
+ ctx.beginPath();
+ ctx.moveTo(scale.xCenter, scale.yCenter);
+ ctx.lineTo(outerPosition.x, outerPosition.y);
+ ctx.stroke();
+ ctx.closePath();
+ }
+
+ if (pointLabelOpts.display) {
+ // Extra 3px out for some label spacing
+ var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
+
+ // Keep this in loop since we may support array properties here
+ var pointLabelFontColor = valueOrDefault(pointLabelOpts.fontColor, globalDefaults.defaultFontColor);
+ ctx.font = plFont.font;
+ ctx.fillStyle = pointLabelFontColor;
+
+ var angleRadians = scale.getIndexAngle(i);
+ var angle = helpers.toDegrees(angleRadians);
+ ctx.textAlign = getTextAlignForAngle(angle);
+ adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], pointLabelPosition);
+ fillText(ctx, scale.pointLabels[i] || '', pointLabelPosition, plFont.size);
+ }
+ }
+ }
+
+ function drawRadiusLine(scale, gridLineOpts, radius, index) {
+ var ctx = scale.ctx;
+ ctx.strokeStyle = helpers.valueAtIndexOrDefault(gridLineOpts.color, index - 1);
+ ctx.lineWidth = helpers.valueAtIndexOrDefault(gridLineOpts.lineWidth, index - 1);
+
+ if (scale.options.gridLines.circular) {
+ // Draw circular arcs between the points
+ ctx.beginPath();
+ ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2);
+ ctx.closePath();
+ ctx.stroke();
+ } else {
+ // Draw straight lines connecting each index
+ var valueCount = getValueCount(scale);
+
+ if (valueCount === 0) {
+ return;
+ }
+
+ ctx.beginPath();
+ var pointPosition = scale.getPointPosition(0, radius);
+ ctx.moveTo(pointPosition.x, pointPosition.y);
+
+ for (var i = 1; i < valueCount; i++) {
+ pointPosition = scale.getPointPosition(i, radius);
+ ctx.lineTo(pointPosition.x, pointPosition.y);
+ }
+
+ ctx.closePath();
+ ctx.stroke();
+ }
+ }
+
+ function numberOrZero(param) {
+ return helpers.isNumber(param) ? param : 0;
+ }
+
+ var LinearRadialScale = Chart.LinearScaleBase.extend({
+ setDimensions: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ // Set the unconstrained dimension before label rotation
+ me.width = me.maxWidth;
+ me.height = me.maxHeight;
+ me.xCenter = Math.round(me.width / 2);
+ me.yCenter = Math.round(me.height / 2);
+
+ var minSize = helpers.min([me.height, me.width]);
+ var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
+ me.drawingArea = opts.display ? (minSize / 2) - (tickFontSize / 2 + tickOpts.backdropPaddingY) : (minSize / 2);
+ },
+ determineDataLimits: function() {
+ var me = this;
+ var chart = me.chart;
+ var min = Number.POSITIVE_INFINITY;
+ var max = Number.NEGATIVE_INFINITY;
+
+ helpers.each(chart.data.datasets, function(dataset, datasetIndex) {
+ if (chart.isDatasetVisible(datasetIndex)) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ min = Math.min(value, min);
+ max = Math.max(value, max);
+ });
+ }
+ });
+
+ me.min = (min === Number.POSITIVE_INFINITY ? 0 : min);
+ me.max = (max === Number.NEGATIVE_INFINITY ? 0 : max);
+
+ // Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
+ me.handleTickRangeOptions();
+ },
+ getTickLimit: function() {
+ var tickOpts = this.options.ticks;
+ var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
+ return Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(this.drawingArea / (1.5 * tickFontSize)));
+ },
+ convertTicksToLabels: function() {
+ var me = this;
+
+ Chart.LinearScaleBase.prototype.convertTicksToLabels.call(me);
+
+ // Point labels
+ me.pointLabels = me.chart.data.labels.map(me.options.pointLabels.callback, me);
+ },
+ getLabelForIndex: function(index, datasetIndex) {
+ return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
+ },
+ fit: function() {
+ if (this.options.pointLabels.display) {
+ fitWithPointLabels(this);
+ } else {
+ fit(this);
+ }
+ },
+ /**
+ * Set radius reductions and determine new radius and center point
+ * @private
+ */
+ setReductions: function(largestPossibleRadius, furthestLimits, furthestAngles) {
+ var me = this;
+ var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l);
+ var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r);
+ var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t);
+ var radiusReductionBottom = -Math.max(furthestLimits.b - me.height, 0) / Math.cos(furthestAngles.b);
+
+ radiusReductionLeft = numberOrZero(radiusReductionLeft);
+ radiusReductionRight = numberOrZero(radiusReductionRight);
+ radiusReductionTop = numberOrZero(radiusReductionTop);
+ radiusReductionBottom = numberOrZero(radiusReductionBottom);
+
+ me.drawingArea = Math.min(
+ Math.round(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2),
+ Math.round(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2));
+ me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom);
+ },
+ setCenterPoint: function(leftMovement, rightMovement, topMovement, bottomMovement) {
+ var me = this;
+ var maxRight = me.width - rightMovement - me.drawingArea;
+ var maxLeft = leftMovement + me.drawingArea;
+ var maxTop = topMovement + me.drawingArea;
+ var maxBottom = me.height - bottomMovement - me.drawingArea;
+
+ me.xCenter = Math.round(((maxLeft + maxRight) / 2) + me.left);
+ me.yCenter = Math.round(((maxTop + maxBottom) / 2) + me.top);
+ },
+
+ getIndexAngle: function(index) {
+ var angleMultiplier = (Math.PI * 2) / getValueCount(this);
+ var startAngle = this.chart.options && this.chart.options.startAngle ?
+ this.chart.options.startAngle :
+ 0;
+
+ var startAngleRadians = startAngle * Math.PI * 2 / 360;
+
+ // Start from the top instead of right, so remove a quarter of the circle
+ return index * angleMultiplier + startAngleRadians;
+ },
+ getDistanceFromCenterForValue: function(value) {
+ var me = this;
+
+ if (value === null) {
+ return 0; // null always in center
+ }
+
+ // Take into account half font size + the yPadding of the top value
+ var scalingFactor = me.drawingArea / (me.max - me.min);
+ if (me.options.ticks.reverse) {
+ return (me.max - value) * scalingFactor;
+ }
+ return (value - me.min) * scalingFactor;
+ },
+ getPointPosition: function(index, distanceFromCenter) {
+ var me = this;
+ var thisAngle = me.getIndexAngle(index) - (Math.PI / 2);
+ return {
+ x: Math.round(Math.cos(thisAngle) * distanceFromCenter) + me.xCenter,
+ y: Math.round(Math.sin(thisAngle) * distanceFromCenter) + me.yCenter
+ };
+ },
+ getPointPositionForValue: function(index, value) {
+ return this.getPointPosition(index, this.getDistanceFromCenterForValue(value));
+ },
+
+ getBasePosition: function() {
+ var me = this;
+ var min = me.min;
+ var max = me.max;
+
+ return me.getPointPositionForValue(0,
+ me.beginAtZero ? 0 :
+ min < 0 && max < 0 ? max :
+ min > 0 && max > 0 ? min :
+ 0);
+ },
+
+ draw: function() {
+ var me = this;
+ var opts = me.options;
+ var gridLineOpts = opts.gridLines;
+ var tickOpts = opts.ticks;
+ var valueOrDefault = helpers.valueOrDefault;
+
+ if (opts.display) {
+ var ctx = me.ctx;
+ var startAngle = this.getIndexAngle(0);
+
+ // Tick Font
+ var tickFontSize = valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
+ var tickFontStyle = valueOrDefault(tickOpts.fontStyle, globalDefaults.defaultFontStyle);
+ var tickFontFamily = valueOrDefault(tickOpts.fontFamily, globalDefaults.defaultFontFamily);
+ var tickLabelFont = helpers.fontString(tickFontSize, tickFontStyle, tickFontFamily);
+
+ helpers.each(me.ticks, function(label, index) {
+ // Don't draw a centre value (if it is minimum)
+ if (index > 0 || tickOpts.reverse) {
+ var yCenterOffset = me.getDistanceFromCenterForValue(me.ticksAsNumbers[index]);
+
+ // Draw circular lines around the scale
+ if (gridLineOpts.display && index !== 0) {
+ drawRadiusLine(me, gridLineOpts, yCenterOffset, index);
+ }
+
+ if (tickOpts.display) {
+ var tickFontColor = valueOrDefault(tickOpts.fontColor, globalDefaults.defaultFontColor);
+ ctx.font = tickLabelFont;
+
+ ctx.save();
+ ctx.translate(me.xCenter, me.yCenter);
+ ctx.rotate(startAngle);
+
+ if (tickOpts.showLabelBackdrop) {
+ var labelWidth = ctx.measureText(label).width;
+ ctx.fillStyle = tickOpts.backdropColor;
+ ctx.fillRect(
+ -labelWidth / 2 - tickOpts.backdropPaddingX,
+ -yCenterOffset - tickFontSize / 2 - tickOpts.backdropPaddingY,
+ labelWidth + tickOpts.backdropPaddingX * 2,
+ tickFontSize + tickOpts.backdropPaddingY * 2
+ );
+ }
+
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillStyle = tickFontColor;
+ ctx.fillText(label, 0, -yCenterOffset);
+ ctx.restore();
+ }
+ }
+ });
+
+ if (opts.angleLines.display || opts.pointLabels.display) {
+ drawPointLabels(me);
+ }
+ }
+ }
+ });
+ Chart.scaleService.registerScaleType('radialLinear', LinearRadialScale, defaultConfig);
+
+};
+
+},{"25":25,"34":34,"45":45}],57:[function(require,module,exports){
+/* global window: false */
+'use strict';
+
+var moment = require(6);
+moment = typeof moment === 'function' ? moment : window.moment;
+
+var defaults = require(25);
+var helpers = require(45);
+
+// Integer constants are from the ES6 spec.
+var MIN_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
+var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
+
+var INTERVALS = {
+ millisecond: {
+ common: true,
+ size: 1,
+ steps: [1, 2, 5, 10, 20, 50, 100, 250, 500]
+ },
+ second: {
+ common: true,
+ size: 1000,
+ steps: [1, 2, 5, 10, 30]
+ },
+ minute: {
+ common: true,
+ size: 60000,
+ steps: [1, 2, 5, 10, 30]
+ },
+ hour: {
+ common: true,
+ size: 3600000,
+ steps: [1, 2, 3, 6, 12]
+ },
+ day: {
+ common: true,
+ size: 86400000,
+ steps: [1, 2, 5]
+ },
+ week: {
+ common: false,
+ size: 604800000,
+ steps: [1, 2, 3, 4]
+ },
+ month: {
+ common: true,
+ size: 2.628e9,
+ steps: [1, 2, 3]
+ },
+ quarter: {
+ common: false,
+ size: 7.884e9,
+ steps: [1, 2, 3, 4]
+ },
+ year: {
+ common: true,
+ size: 3.154e10
+ }
+};
+
+var UNITS = Object.keys(INTERVALS);
+
+function sorter(a, b) {
+ return a - b;
+}
+
+function arrayUnique(items) {
+ var hash = {};
+ var out = [];
+ var i, ilen, item;
+
+ for (i = 0, ilen = items.length; i < ilen; ++i) {
+ item = items[i];
+ if (!hash[item]) {
+ hash[item] = true;
+ out.push(item);
+ }
+ }
+
+ return out;
+}
+
+/**
+ * Returns an array of {time, pos} objects used to interpolate a specific `time` or position
+ * (`pos`) on the scale, by searching entries before and after the requested value. `pos` is
+ * a decimal between 0 and 1: 0 being the start of the scale (left or top) and 1 the other
+ * extremity (left + width or top + height). Note that it would be more optimized to directly
+ * store pre-computed pixels, but the scale dimensions are not guaranteed at the time we need
+ * to create the lookup table. The table ALWAYS contains at least two items: min and max.
+ *
+ * @param {Number[]} timestamps - timestamps sorted from lowest to highest.
+ * @param {String} distribution - If 'linear', timestamps will be spread linearly along the min
+ * and max range, so basically, the table will contains only two items: {min, 0} and {max, 1}.
+ * If 'series', timestamps will be positioned at the same distance from each other. In this
+ * case, only timestamps that break the time linearity are registered, meaning that in the
+ * best case, all timestamps are linear, the table contains only min and max.
+ */
+function buildLookupTable(timestamps, min, max, distribution) {
+ if (distribution === 'linear' || !timestamps.length) {
+ return [
+ {time: min, pos: 0},
+ {time: max, pos: 1}
+ ];
+ }
+
+ var table = [];
+ var items = [min];
+ var i, ilen, prev, curr, next;
+
+ for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
+ curr = timestamps[i];
+ if (curr > min && curr < max) {
+ items.push(curr);
+ }
+ }
+
+ items.push(max);
+
+ for (i = 0, ilen = items.length; i < ilen; ++i) {
+ next = items[i + 1];
+ prev = items[i - 1];
+ curr = items[i];
+
+ // only add points that breaks the scale linearity
+ if (prev === undefined || next === undefined || Math.round((next + prev) / 2) !== curr) {
+ table.push({time: curr, pos: i / (ilen - 1)});
+ }
+ }
+
+ return table;
+}
+
+// @see adapted from http://www.anujgakhar.com/2014/03/01/binary-search-in-javascript/
+function lookup(table, key, value) {
+ var lo = 0;
+ var hi = table.length - 1;
+ var mid, i0, i1;
+
+ while (lo >= 0 && lo <= hi) {
+ mid = (lo + hi) >> 1;
+ i0 = table[mid - 1] || null;
+ i1 = table[mid];
+
+ if (!i0) {
+ // given value is outside table (before first item)
+ return {lo: null, hi: i1};
+ } else if (i1[key] < value) {
+ lo = mid + 1;
+ } else if (i0[key] > value) {
+ hi = mid - 1;
+ } else {
+ return {lo: i0, hi: i1};
+ }
+ }
+
+ // given value is outside table (after last item)
+ return {lo: i1, hi: null};
+}
+
+/**
+ * Linearly interpolates the given source `value` using the table items `skey` values and
+ * returns the associated `tkey` value. For example, interpolate(table, 'time', 42, 'pos')
+ * returns the position for a timestamp equal to 42. If value is out of bounds, values at
+ * index [0, 1] or [n - 1, n] are used for the interpolation.
+ */
+function interpolate(table, skey, sval, tkey) {
+ var range = lookup(table, skey, sval);
+
+ // Note: the lookup table ALWAYS contains at least 2 items (min and max)
+ var prev = !range.lo ? table[0] : !range.hi ? table[table.length - 2] : range.lo;
+ var next = !range.lo ? table[1] : !range.hi ? table[table.length - 1] : range.hi;
+
+ var span = next[skey] - prev[skey];
+ var ratio = span ? (sval - prev[skey]) / span : 0;
+ var offset = (next[tkey] - prev[tkey]) * ratio;
+
+ return prev[tkey] + offset;
+}
+
+/**
+ * Convert the given value to a moment object using the given time options.
+ * @see http://momentjs.com/docs/#/parsing/
+ */
+function momentify(value, options) {
+ var parser = options.parser;
+ var format = options.parser || options.format;
+
+ if (typeof parser === 'function') {
+ return parser(value);
+ }
+
+ if (typeof value === 'string' && typeof format === 'string') {
+ return moment(value, format);
+ }
+
+ if (!(value instanceof moment)) {
+ value = moment(value);
+ }
+
+ if (value.isValid()) {
+ return value;
+ }
+
+ // Labels are in an incompatible moment format and no `parser` has been provided.
+ // The user might still use the deprecated `format` option to convert his inputs.
+ if (typeof format === 'function') {
+ return format(value);
+ }
+
+ return value;
+}
+
+function parse(input, scale) {
+ if (helpers.isNullOrUndef(input)) {
+ return null;
+ }
+
+ var options = scale.options.time;
+ var value = momentify(scale.getRightValue(input), options);
+ if (!value.isValid()) {
+ return null;
+ }
+
+ if (options.round) {
+ value.startOf(options.round);
+ }
+
+ return value.valueOf();
+}
+
+/**
+ * Returns the number of unit to skip to be able to display up to `capacity` number of ticks
+ * in `unit` for the given `min` / `max` range and respecting the interval steps constraints.
+ */
+function determineStepSize(min, max, unit, capacity) {
+ var range = max - min;
+ var interval = INTERVALS[unit];
+ var milliseconds = interval.size;
+ var steps = interval.steps;
+ var i, ilen, factor;
+
+ if (!steps) {
+ return Math.ceil(range / ((capacity || 1) * milliseconds));
+ }
+
+ for (i = 0, ilen = steps.length; i < ilen; ++i) {
+ factor = steps[i];
+ if (Math.ceil(range / (milliseconds * factor)) <= capacity) {
+ break;
+ }
+ }
+
+ return factor;
+}
+
+/**
+ * Figures out what unit results in an appropriate number of auto-generated ticks
+ */
+function determineUnitForAutoTicks(minUnit, min, max, capacity) {
+ var ilen = UNITS.length;
+ var i, interval, factor;
+
+ for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
+ interval = INTERVALS[UNITS[i]];
+ factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
+
+ if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
+ return UNITS[i];
+ }
+ }
+
+ return UNITS[ilen - 1];
+}
+
+/**
+ * Figures out what unit to format a set of ticks with
+ */
+function determineUnitForFormatting(ticks, minUnit, min, max) {
+ var duration = moment.duration(moment(max).diff(moment(min)));
+ var ilen = UNITS.length;
+ var i, unit;
+
+ for (i = ilen - 1; i >= UNITS.indexOf(minUnit); i--) {
+ unit = UNITS[i];
+ if (INTERVALS[unit].common && duration.as(unit) >= ticks.length) {
+ return unit;
+ }
+ }
+
+ return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];
+}
+
+function determineMajorUnit(unit) {
+ for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {
+ if (INTERVALS[UNITS[i]].common) {
+ return UNITS[i];
+ }
+ }
+}
+
+/**
+ * Generates a maximum of `capacity` timestamps between min and max, rounded to the
+ * `minor` unit, aligned on the `major` unit and using the given scale time `options`.
+ * Important: this method can return ticks outside the min and max range, it's the
+ * responsibility of the calling code to clamp values if needed.
+ */
+function generate(min, max, capacity, options) {
+ var timeOpts = options.time;
+ var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, capacity);
+ var major = determineMajorUnit(minor);
+ var stepSize = helpers.valueOrDefault(timeOpts.stepSize, timeOpts.unitStepSize);
+ var weekday = minor === 'week' ? timeOpts.isoWeekday : false;
+ var majorTicksEnabled = options.ticks.major.enabled;
+ var interval = INTERVALS[minor];
+ var first = moment(min);
+ var last = moment(max);
+ var ticks = [];
+ var time;
+
+ if (!stepSize) {
+ stepSize = determineStepSize(min, max, minor, capacity);
+ }
+
+ // For 'week' unit, handle the first day of week option
+ if (weekday) {
+ first = first.isoWeekday(weekday);
+ last = last.isoWeekday(weekday);
+ }
+
+ // Align first/last ticks on unit
+ first = first.startOf(weekday ? 'day' : minor);
+ last = last.startOf(weekday ? 'day' : minor);
+
+ // Make sure that the last tick include max
+ if (last < max) {
+ last.add(1, minor);
+ }
+
+ time = moment(first);
+
+ if (majorTicksEnabled && major && !weekday && !timeOpts.round) {
+ // Align the first tick on the previous `minor` unit aligned on the `major` unit:
+ // we first aligned time on the previous `major` unit then add the number of full
+ // stepSize there is between first and the previous major time.
+ time.startOf(major);
+ time.add(~~((first - time) / (interval.size * stepSize)) * stepSize, minor);
+ }
+
+ for (; time < last; time.add(stepSize, minor)) {
+ ticks.push(+time);
+ }
+
+ ticks.push(+time);
+
+ return ticks;
+}
+
+/**
+ * Returns the right and left offsets from edges in the form of {left, right}.
+ * Offsets are added when the `offset` option is true.
+ */
+function computeOffsets(table, ticks, min, max, options) {
+ var left = 0;
+ var right = 0;
+ var upper, lower;
+
+ if (options.offset && ticks.length) {
+ if (!options.time.min) {
+ upper = ticks.length > 1 ? ticks[1] : max;
+ lower = ticks[0];
+ left = (
+ interpolate(table, 'time', upper, 'pos') -
+ interpolate(table, 'time', lower, 'pos')
+ ) / 2;
+ }
+ if (!options.time.max) {
+ upper = ticks[ticks.length - 1];
+ lower = ticks.length > 1 ? ticks[ticks.length - 2] : min;
+ right = (
+ interpolate(table, 'time', upper, 'pos') -
+ interpolate(table, 'time', lower, 'pos')
+ ) / 2;
+ }
+ }
+
+ return {left: left, right: right};
+}
+
+function ticksFromTimestamps(values, majorUnit) {
+ var ticks = [];
+ var i, ilen, value, major;
+
+ for (i = 0, ilen = values.length; i < ilen; ++i) {
+ value = values[i];
+ major = majorUnit ? value === +moment(value).startOf(majorUnit) : false;
+
+ ticks.push({
+ value: value,
+ major: major
+ });
+ }
+
+ return ticks;
+}
+
+module.exports = function(Chart) {
+
+ var defaultConfig = {
+ position: 'bottom',
+
+ /**
+ * Data distribution along the scale:
+ * - 'linear': data are spread according to their time (distances can vary),
+ * - 'series': data are spread at the same distance from each other.
+ * @see https://github.com/chartjs/Chart.js/pull/4507
+ * @since 2.7.0
+ */
+ distribution: 'linear',
+
+ /**
+ * Scale boundary strategy (bypassed by min/max time options)
+ * - `data`: make sure data are fully visible, ticks outside are removed
+ * - `ticks`: make sure ticks are fully visible, data outside are truncated
+ * @see https://github.com/chartjs/Chart.js/pull/4556
+ * @since 2.7.0
+ */
+ bounds: 'data',
+
+ time: {
+ parser: false, // false == a pattern string from http://momentjs.com/docs/#/parsing/string-format/ or a custom callback that converts its argument to a moment
+ format: false, // DEPRECATED false == date objects, moment object, callback or a pattern string from http://momentjs.com/docs/#/parsing/string-format/
+ unit: false, // false == automatic or override with week, month, year, etc.
+ round: false, // none, or override with week, month, year, etc.
+ displayFormat: false, // DEPRECATED
+ isoWeekday: false, // override week start day - see http://momentjs.com/docs/#/get-set/iso-weekday/
+ minUnit: 'millisecond',
+
+ // defaults to unit's corresponding unitFormat below or override using pattern string from http://momentjs.com/docs/#/displaying/format/
+ displayFormats: {
+ millisecond: 'h:mm:ss.SSS a', // 11:20:01.123 AM,
+ second: 'h:mm:ss a', // 11:20:01 AM
+ minute: 'h:mm a', // 11:20 AM
+ hour: 'hA', // 5PM
+ day: 'MMM D', // Sep 4
+ week: 'll', // Week 46, or maybe "[W]WW - YYYY" ?
+ month: 'MMM YYYY', // Sept 2015
+ quarter: '[Q]Q - YYYY', // Q3
+ year: 'YYYY' // 2015
+ },
+ },
+ ticks: {
+ autoSkip: false,
+
+ /**
+ * Ticks generation input values:
+ * - 'auto': generates "optimal" ticks based on scale size and time options.
+ * - 'data': generates ticks from data (including labels from data {t|x|y} objects).
+ * - 'labels': generates ticks from user given `data.labels` values ONLY.
+ * @see https://github.com/chartjs/Chart.js/pull/4507
+ * @since 2.7.0
+ */
+ source: 'auto',
+
+ major: {
+ enabled: false
+ }
+ }
+ };
+
+ var TimeScale = Chart.Scale.extend({
+ initialize: function() {
+ if (!moment) {
+ throw new Error('Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com');
+ }
+
+ this.mergeTicksOptions();
+
+ Chart.Scale.prototype.initialize.call(this);
+ },
+
+ update: function() {
+ var me = this;
+ var options = me.options;
+
+ // DEPRECATIONS: output a message only one time per update
+ if (options.time && options.time.format) {
+ console.warn('options.time.format is deprecated and replaced by options.time.parser.');
+ }
+
+ return Chart.Scale.prototype.update.apply(me, arguments);
+ },
+
+ /**
+ * Allows data to be referenced via 't' attribute
+ */
+ getRightValue: function(rawValue) {
+ if (rawValue && rawValue.t !== undefined) {
+ rawValue = rawValue.t;
+ }
+ return Chart.Scale.prototype.getRightValue.call(this, rawValue);
+ },
+
+ determineDataLimits: function() {
+ var me = this;
+ var chart = me.chart;
+ var timeOpts = me.options.time;
+ var min = MAX_INTEGER;
+ var max = MIN_INTEGER;
+ var timestamps = [];
+ var datasets = [];
+ var labels = [];
+ var i, j, ilen, jlen, data, timestamp;
+
+ // Convert labels to timestamps
+ for (i = 0, ilen = chart.data.labels.length; i < ilen; ++i) {
+ labels.push(parse(chart.data.labels[i], me));
+ }
+
+ // Convert data to timestamps
+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
+ if (chart.isDatasetVisible(i)) {
+ data = chart.data.datasets[i].data;
+
+ // Let's consider that all data have the same format.
+ if (helpers.isObject(data[0])) {
+ datasets[i] = [];
+
+ for (j = 0, jlen = data.length; j < jlen; ++j) {
+ timestamp = parse(data[j], me);
+ timestamps.push(timestamp);
+ datasets[i][j] = timestamp;
+ }
+ } else {
+ timestamps.push.apply(timestamps, labels);
+ datasets[i] = labels.slice(0);
+ }
+ } else {
+ datasets[i] = [];
+ }
+ }
+
+ if (labels.length) {
+ // Sort labels **after** data have been converted
+ labels = arrayUnique(labels).sort(sorter);
+ min = Math.min(min, labels[0]);
+ max = Math.max(max, labels[labels.length - 1]);
+ }
+
+ if (timestamps.length) {
+ timestamps = arrayUnique(timestamps).sort(sorter);
+ min = Math.min(min, timestamps[0]);
+ max = Math.max(max, timestamps[timestamps.length - 1]);
+ }
+
+ min = parse(timeOpts.min, me) || min;
+ max = parse(timeOpts.max, me) || max;
+
+ // In case there is no valid min/max, let's use today limits
+ min = min === MAX_INTEGER ? +moment().startOf('day') : min;
+ max = max === MIN_INTEGER ? +moment().endOf('day') + 1 : max;
+
+ // Make sure that max is strictly higher than min (required by the lookup table)
+ me.min = Math.min(min, max);
+ me.max = Math.max(min + 1, max);
+
+ // PRIVATE
+ me._horizontal = me.isHorizontal();
+ me._table = [];
+ me._timestamps = {
+ data: timestamps,
+ datasets: datasets,
+ labels: labels
+ };
+ },
+
+ buildTicks: function() {
+ var me = this;
+ var min = me.min;
+ var max = me.max;
+ var options = me.options;
+ var timeOpts = options.time;
+ var timestamps = [];
+ var ticks = [];
+ var i, ilen, timestamp;
+
+ switch (options.ticks.source) {
+ case 'data':
+ timestamps = me._timestamps.data;
+ break;
+ case 'labels':
+ timestamps = me._timestamps.labels;
+ break;
+ case 'auto':
+ default:
+ timestamps = generate(min, max, me.getLabelCapacity(min), options);
+ }
+
+ if (options.bounds === 'ticks' && timestamps.length) {
+ min = timestamps[0];
+ max = timestamps[timestamps.length - 1];
+ }
+
+ // Enforce limits with user min/max options
+ min = parse(timeOpts.min, me) || min;
+ max = parse(timeOpts.max, me) || max;
+
+ // Remove ticks outside the min/max range
+ for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
+ timestamp = timestamps[i];
+ if (timestamp >= min && timestamp <= max) {
+ ticks.push(timestamp);
+ }
+ }
+
+ me.min = min;
+ me.max = max;
+
+ // PRIVATE
+ me._unit = timeOpts.unit || determineUnitForFormatting(ticks, timeOpts.minUnit, me.min, me.max);
+ me._majorUnit = determineMajorUnit(me._unit);
+ me._table = buildLookupTable(me._timestamps.data, min, max, options.distribution);
+ me._offsets = computeOffsets(me._table, ticks, min, max, options);
+
+ return ticksFromTimestamps(ticks, me._majorUnit);
+ },
+
+ getLabelForIndex: function(index, datasetIndex) {
+ var me = this;
+ var data = me.chart.data;
+ var timeOpts = me.options.time;
+ var label = data.labels && index < data.labels.length ? data.labels[index] : '';
+ var value = data.datasets[datasetIndex].data[index];
+
+ if (helpers.isObject(value)) {
+ label = me.getRightValue(value);
+ }
+ if (timeOpts.tooltipFormat) {
+ label = momentify(label, timeOpts).format(timeOpts.tooltipFormat);
+ }
+
+ return label;
+ },
+
+ /**
+ * Function to format an individual tick mark
+ * @private
+ */
+ tickFormatFunction: function(tick, index, ticks, formatOverride) {
+ var me = this;
+ var options = me.options;
+ var time = tick.valueOf();
+ var formats = options.time.displayFormats;
+ var minorFormat = formats[me._unit];
+ var majorUnit = me._majorUnit;
+ var majorFormat = formats[majorUnit];
+ var majorTime = tick.clone().startOf(majorUnit).valueOf();
+ var majorTickOpts = options.ticks.major;
+ var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
+ var label = tick.format(formatOverride ? formatOverride : major ? majorFormat : minorFormat);
+ var tickOpts = major ? majorTickOpts : options.ticks.minor;
+ var formatter = helpers.valueOrDefault(tickOpts.callback, tickOpts.userCallback);
+
+ return formatter ? formatter(label, index, ticks) : label;
+ },
+
+ convertTicksToLabels: function(ticks) {
+ var labels = [];
+ var i, ilen;
+
+ for (i = 0, ilen = ticks.length; i < ilen; ++i) {
+ labels.push(this.tickFormatFunction(moment(ticks[i].value), i, ticks));
+ }
+
+ return labels;
+ },
+
+ /**
+ * @private
+ */
+ getPixelForOffset: function(time) {
+ var me = this;
+ var size = me._horizontal ? me.width : me.height;
+ var start = me._horizontal ? me.left : me.top;
+ var pos = interpolate(me._table, 'time', time, 'pos');
+
+ return start + size * (me._offsets.left + pos) / (me._offsets.left + 1 + me._offsets.right);
+ },
+
+ getPixelForValue: function(value, index, datasetIndex) {
+ var me = this;
+ var time = null;
+
+ if (index !== undefined && datasetIndex !== undefined) {
+ time = me._timestamps.datasets[datasetIndex][index];
+ }
+
+ if (time === null) {
+ time = parse(value, me);
+ }
+
+ if (time !== null) {
+ return me.getPixelForOffset(time);
+ }
+ },
+
+ getPixelForTick: function(index) {
+ var ticks = this.getTicks();
+ return index >= 0 && index < ticks.length ?
+ this.getPixelForOffset(ticks[index].value) :
+ null;
+ },
+
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var size = me._horizontal ? me.width : me.height;
+ var start = me._horizontal ? me.left : me.top;
+ var pos = (size ? (pixel - start) / size : 0) * (me._offsets.left + 1 + me._offsets.left) - me._offsets.right;
+ var time = interpolate(me._table, 'pos', pos, 'time');
+
+ return moment(time);
+ },
+
+ /**
+ * Crude approximation of what the label width might be
+ * @private
+ */
+ getLabelWidth: function(label) {
+ var me = this;
+ var ticksOpts = me.options.ticks;
+ var tickLabelWidth = me.ctx.measureText(label).width;
+ var angle = helpers.toRadians(ticksOpts.maxRotation);
+ var cosRotation = Math.cos(angle);
+ var sinRotation = Math.sin(angle);
+ var tickFontSize = helpers.valueOrDefault(ticksOpts.fontSize, defaults.global.defaultFontSize);
+
+ return (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation);
+ },
+
+ /**
+ * @private
+ */
+ getLabelCapacity: function(exampleTime) {
+ var me = this;
+
+ var formatOverride = me.options.time.displayFormats.millisecond; // Pick the longest format for guestimation
+
+ var exampleLabel = me.tickFormatFunction(moment(exampleTime), 0, [], formatOverride);
+ var tickLabelWidth = me.getLabelWidth(exampleLabel);
+ var innerWidth = me.isHorizontal() ? me.width : me.height;
+
+ return Math.floor(innerWidth / tickLabelWidth);
+ }
+ });
+
+ Chart.scaleService.registerScaleType('time', TimeScale, defaultConfig);
+};
+
+},{"25":25,"45":45,"6":6}]},{},[7])(7)
+}); \ No newline at end of file
diff --git a/main/survey/js/ChartJS/Chart.bundle.min.js b/main/survey/js/ChartJS/Chart.bundle.min.js
new file mode 100644
index 0000000..754fdb7
--- /dev/null
+++ b/main/survey/js/ChartJS/Chart.bundle.min.js
@@ -0,0 +1,10 @@
+/*!
+ * Chart.js
+ * http://chartjs.org/
+ * Version: 2.7.1
+ *
+ * Copyright 2017 Nick Downie
+ * Released under the MIT license
+ * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
+ */
+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Chart=t()}}(function(){return function t(e,n,i){function a(o,s){if(!n[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[o]={exports:{}};e[o][0].call(d.exports,function(t){var n=e[o][1][t];return a(n||t)},d,d.exports,t,e,n,i)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;o<i.length;o++)a(i[o]);return a}({1:[function(t,e,n){function i(t){if(t){var e=[0,0,0],n=1,i=t.match(/^#([a-fA-F0-9]{3})$/i);if(i){i=i[1];for(a=0;a<e.length;a++)e[a]=parseInt(i[a]+i[a],16)}else if(i=t.match(/^#([a-fA-F0-9]{6})$/i)){i=i[1];for(a=0;a<e.length;a++)e[a]=parseInt(i.slice(2*a,2*a+2),16)}else if(i=t.match(/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i)){for(a=0;a<e.length;a++)e[a]=parseInt(i[a+1]);n=parseFloat(i[4])}else if(i=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i)){for(a=0;a<e.length;a++)e[a]=Math.round(2.55*parseFloat(i[a+1]));n=parseFloat(i[4])}else if(i=t.match(/(\w+)/)){if("transparent"==i[1])return[0,0,0,0];if(!(e=c[i[1]]))return}for(var a=0;a<e.length;a++)e[a]=u(e[a],0,255);return n=n||0==n?u(n,0,1):1,e[3]=n,e}}function a(t){if(t){var e=t.match(/^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/);if(e){var n=parseFloat(e[4]);return[u(parseInt(e[1]),0,360),u(parseFloat(e[2]),0,100),u(parseFloat(e[3]),0,100),u(isNaN(n)?1:n,0,1)]}}}function r(t){if(t){var e=t.match(/^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/);if(e){var n=parseFloat(e[4]);return[u(parseInt(e[1]),0,360),u(parseFloat(e[2]),0,100),u(parseFloat(e[3]),0,100),u(isNaN(n)?1:n,0,1)]}}}function o(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function s(t,e){return"rgba("+Math.round(t[0]/255*100)+"%, "+Math.round(t[1]/255*100)+"%, "+Math.round(t[2]/255*100)+"%, "+(e||t[3]||1)+")"}function l(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function u(t,e,n){return Math.min(Math.max(e,t),n)}function d(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var c=t(5);e.exports={getRgba:i,getHsla:a,getRgb:function(t){var e=i(t);return e&&e.slice(0,3)},getHsl:function(t){var e=a(t);return e&&e.slice(0,3)},getHwb:r,getAlpha:function(t){var e=i(t);return e?e[3]:(e=a(t))?e[3]:(e=r(t))?e[3]:void 0},hexString:function(t){return"#"+d(t[0])+d(t[1])+d(t[2])},rgbString:function(t,e){return e<1||t[3]&&t[3]<1?o(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"},rgbaString:o,percentString:function(t,e){return e<1||t[3]&&t[3]<1?s(t,e):"rgb("+Math.round(t[0]/255*100)+"%, "+Math.round(t[1]/255*100)+"%, "+Math.round(t[2]/255*100)+"%)"},percentaString:s,hslString:function(t,e){return e<1||t[3]&&t[3]<1?l(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"},hslaString:l,hwbString:function(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"},keyword:function(t){return h[t.slice(0,3)]}};var h={};for(var f in c)h[c[f]]=f},{5:5}],2:[function(t,e,n){var i=t(4),a=t(1),r=function(t){if(t instanceof r)return t;if(!(this instanceof r))return new r(t);this.valid=!1,this.values={rgb:[0,0,0],hsl:[0,0,0],hsv:[0,0,0],hwb:[0,0,0],cmyk:[0,0,0,0],alpha:1};var e;"string"==typeof t?(e=a.getRgba(t))?this.setValues("rgb",e):(e=a.getHsla(t))?this.setValues("hsl",e):(e=a.getHwb(t))&&this.setValues("hwb",e):"object"==typeof t&&(void 0!==(e=t).r||void 0!==e.red?this.setValues("rgb",e):void 0!==e.l||void 0!==e.lightness?this.setValues("hsl",e):void 0!==e.v||void 0!==e.value?this.setValues("hsv",e):void 0!==e.w||void 0!==e.whiteness?this.setValues("hwb",e):void 0===e.c&&void 0===e.cyan||this.setValues("cmyk",e))};r.prototype={isValid:function(){return this.valid},rgb:function(){return this.setSpace("rgb",arguments)},hsl:function(){return this.setSpace("hsl",arguments)},hsv:function(){return this.setSpace("hsv",arguments)},hwb:function(){return this.setSpace("hwb",arguments)},cmyk:function(){return this.setSpace("cmyk",arguments)},rgbArray:function(){return this.values.rgb},hslArray:function(){return this.values.hsl},hsvArray:function(){return this.values.hsv},hwbArray:function(){var t=this.values;return 1!==t.alpha?t.hwb.concat([t.alpha]):t.hwb},cmykArray:function(){return this.values.cmyk},rgbaArray:function(){var t=this.values;return t.rgb.concat([t.alpha])},hslaArray:function(){var t=this.values;return t.hsl.concat([t.alpha])},alpha:function(t){return void 0===t?this.values.alpha:(this.setValues("alpha",t),this)},red:function(t){return this.setChannel("rgb",0,t)},green:function(t){return this.setChannel("rgb",1,t)},blue:function(t){return this.setChannel("rgb",2,t)},hue:function(t){return t&&(t=(t%=360)<0?360+t:t),this.setChannel("hsl",0,t)},saturation:function(t){return this.setChannel("hsl",1,t)},lightness:function(t){return this.setChannel("hsl",2,t)},saturationv:function(t){return this.setChannel("hsv",1,t)},whiteness:function(t){return this.setChannel("hwb",1,t)},blackness:function(t){return this.setChannel("hwb",2,t)},value:function(t){return this.setChannel("hsv",2,t)},cyan:function(t){return this.setChannel("cmyk",0,t)},magenta:function(t){return this.setChannel("cmyk",1,t)},yellow:function(t){return this.setChannel("cmyk",2,t)},black:function(t){return this.setChannel("cmyk",3,t)},hexString:function(){return a.hexString(this.values.rgb)},rgbString:function(){return a.rgbString(this.values.rgb,this.values.alpha)},rgbaString:function(){return a.rgbaString(this.values.rgb,this.values.alpha)},percentString:function(){return a.percentString(this.values.rgb,this.values.alpha)},hslString:function(){return a.hslString(this.values.hsl,this.values.alpha)},hslaString:function(){return a.hslaString(this.values.hsl,this.values.alpha)},hwbString:function(){return a.hwbString(this.values.hwb,this.values.alpha)},keyword:function(){return a.keyword(this.values.rgb,this.values.alpha)},rgbNumber:function(){var t=this.values.rgb;return t[0]<<16|t[1]<<8|t[2]},luminosity:function(){for(var t=this.values.rgb,e=[],n=0;n<t.length;n++){var i=t[n]/255;e[n]=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;e<3;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){var e=this.values.hsl;return e[2]+=e[2]*t,this.setValues("hsl",e),this},darken:function(t){var e=this.values.hsl;return e[2]-=e[2]*t,this.setValues("hsl",e),this},saturate:function(t){var e=this.values.hsl;return e[1]+=e[1]*t,this.setValues("hsl",e),this},desaturate:function(t){var e=this.values.hsl;return e[1]-=e[1]*t,this.setValues("hsl",e),this},whiten:function(t){var e=this.values.hwb;return e[1]+=e[1]*t,this.setValues("hwb",e),this},blacken:function(t){var e=this.values.hwb;return e[2]+=e[2]*t,this.setValues("hwb",e),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){var e=this.values.alpha;return this.setValues("alpha",e-e*t),this},opaquer:function(t){var e=this.values.alpha;return this.setValues("alpha",e+e*t),this},rotate:function(t){var e=this.values.hsl,n=(e[0]+t)%360;return e[0]=n<0?360+n:n,this.setValues("hsl",e),this},mix:function(t,e){var n=this,i=t,a=void 0===e?.5:e,r=2*a-1,o=n.alpha()-i.alpha(),s=((r*o==-1?r:(r+o)/(1+r*o))+1)/2,l=1-s;return this.rgb(s*n.red()+l*i.red(),s*n.green()+l*i.green(),s*n.blue()+l*i.blue()).alpha(n.alpha()*a+i.alpha()*(1-a))},toJSON:function(){return this.rgb()},clone:function(){var t,e,n=new r,i=this.values,a=n.values;for(var o in i)i.hasOwnProperty(o)&&(t=i[o],"[object Array]"===(e={}.toString.call(t))?a[o]=t.slice(0):"[object Number]"===e?a[o]=t:console.error("unexpected color value:",t));return n}},r.prototype.spaces={rgb:["red","green","blue"],hsl:["hue","saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whiteness","blackness"],cmyk:["cyan","magenta","yellow","black"]},r.prototype.maxes={rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,100],cmyk:[100,100,100,100]},r.prototype.getValues=function(t){for(var e=this.values,n={},i=0;i<t.length;i++)n[t.charAt(i)]=e[t][i];return 1!==e.alpha&&(n.a=e.alpha),n},r.prototype.setValues=function(t,e){var n,a=this.values,r=this.spaces,o=this.maxes,s=1;if(this.valid=!0,"alpha"===t)s=e;else if(e.length)a[t]=e.slice(0,t.length),s=e[t.length];else if(void 0!==e[t.charAt(0)]){for(n=0;n<t.length;n++)a[t][n]=e[t.charAt(n)];s=e.a}else if(void 0!==e[r[t][0]]){var l=r[t];for(n=0;n<t.length;n++)a[t][n]=e[l[n]];s=e.alpha}if(a.alpha=Math.max(0,Math.min(1,void 0===s?a.alpha:s)),"alpha"===t)return!1;var u;for(n=0;n<t.length;n++)u=Math.max(0,Math.min(o[t][n],a[t][n])),a[t][n]=Math.round(u);for(var d in r)d!==t&&(a[d]=i[t][d](a[t]));return!0},r.prototype.setSpace=function(t,e){var n=e[0];return void 0===n?this.getValues(t):("number"==typeof n&&(n=Array.prototype.slice.call(e)),this.setValues(t,n),this)},r.prototype.setChannel=function(t,e,n){var i=this.values[t];return void 0===n?i[e]:n===i[e]?this:(i[e]=n,this.setValues(t,i),this)},"undefined"!=typeof window&&(window.Color=r),e.exports=r},{1:1,4:4}],3:[function(t,e,n){function i(t){var e,n,i,a=t[0]/255,r=t[1]/255,o=t[2]/255,s=Math.min(a,r,o),l=Math.max(a,r,o),u=l-s;return l==s?e=0:a==l?e=(r-o)/u:r==l?e=2+(o-a)/u:o==l&&(e=4+(a-r)/u),(e=Math.min(60*e,360))<0&&(e+=360),i=(s+l)/2,n=l==s?0:i<=.5?u/(l+s):u/(2-l-s),[e,100*n,100*i]}function a(t){var e,n,i,a=t[0],r=t[1],o=t[2],s=Math.min(a,r,o),l=Math.max(a,r,o),u=l-s;return n=0==l?0:u/l*1e3/10,l==s?e=0:a==l?e=(r-o)/u:r==l?e=2+(o-a)/u:o==l&&(e=4+(a-r)/u),(e=Math.min(60*e,360))<0&&(e+=360),i=l/255*1e3/10,[e,n,i]}function o(t){var e=t[0],n=t[1],a=t[2];return[i(t)[0],100*(1/255*Math.min(e,Math.min(n,a))),100*(a=1-1/255*Math.max(e,Math.max(n,a)))]}function s(t){var e,n,i,a,r=t[0]/255,o=t[1]/255,s=t[2]/255;return a=Math.min(1-r,1-o,1-s),e=(1-r-a)/(1-a)||0,n=(1-o-a)/(1-a)||0,i=(1-s-a)/(1-a)||0,[100*e,100*n,100*i,100*a]}function l(t){return S[JSON.stringify(t)]}function u(t){var e=t[0]/255,n=t[1]/255,i=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92)),100*(.2126*e+.7152*n+.0722*i),100*(.0193*e+.1192*n+.9505*i)]}function d(t){var e,n,i,a=u(t),r=a[0],o=a[1],s=a[2];return r/=95.047,o/=100,s/=108.883,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,e=116*o-16,n=500*(r-o),i=200*(o-s),[e,n,i]}function c(t){var e,n,i,a,r,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0==s)return r=255*l,[r,r,r];e=2*l-(n=l<.5?l*(1+s):l+s-l*s),a=[0,0,0];for(var u=0;u<3;u++)(i=o+1/3*-(u-1))<0&&i++,i>1&&i--,r=6*i<1?e+6*(n-e)*i:2*i<1?n:3*i<2?e+(n-e)*(2/3-i)*6:e,a[u]=255*r;return a}function h(t){var e=t[0]/60,n=t[1]/100,i=t[2]/100,a=Math.floor(e)%6,r=e-Math.floor(e),o=255*i*(1-n),s=255*i*(1-n*r),l=255*i*(1-n*(1-r)),i=255*i;switch(a){case 0:return[i,l,o];case 1:return[s,i,o];case 2:return[o,i,l];case 3:return[o,s,i];case 4:return[l,o,i];case 5:return[i,o,s]}}function f(t){var e,n,i,a,o=t[0]/360,s=t[1]/100,l=t[2]/100,u=s+l;switch(u>1&&(s/=u,l/=u),e=Math.floor(6*o),n=1-l,i=6*o-e,0!=(1&e)&&(i=1-i),a=s+i*(n-s),e){default:case 6:case 0:r=n,g=a,b=s;break;case 1:r=a,g=n,b=s;break;case 2:r=s,g=n,b=a;break;case 3:r=s,g=a,b=n;break;case 4:r=a,g=s,b=n;break;case 5:r=n,g=s,b=a}return[255*r,255*g,255*b]}function m(t){var e,n,i,a=t[0]/100,r=t[1]/100,o=t[2]/100,s=t[3]/100;return e=1-Math.min(1,a*(1-s)+s),n=1-Math.min(1,r*(1-s)+s),i=1-Math.min(1,o*(1-s)+s),[255*e,255*n,255*i]}function p(t){var e,n,i,a=t[0]/100,r=t[1]/100,o=t[2]/100;return e=3.2406*a+-1.5372*r+-.4986*o,n=-.9689*a+1.8758*r+.0415*o,i=.0557*a+-.204*r+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e*=12.92,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n*=12.92,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*=12.92,e=Math.min(Math.max(0,e),1),n=Math.min(Math.max(0,n),1),i=Math.min(Math.max(0,i),1),[255*e,255*n,255*i]}function v(t){var e,n,i,a=t[0],r=t[1],o=t[2];return a/=95.047,r/=100,o/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*r-16,n=500*(a-r),i=200*(r-o),[e,n,i]}function y(t){var e,n,i,a,r=t[0],o=t[1],s=t[2];return r<=8?a=(n=100*r/903.3)/100*7.787+16/116:(n=100*Math.pow((r+16)/116,3),a=Math.pow(n/100,1/3)),e=e/95.047<=.008856?e=95.047*(o/500+a-16/116)/7.787:95.047*Math.pow(o/500+a,3),i=i/108.883<=.008859?i=108.883*(a-s/200-16/116)/7.787:108.883*Math.pow(a-s/200,3),[e,n,i]}function x(t){var e,n,i,a=t[0],r=t[1],o=t[2];return e=Math.atan2(o,r),(n=360*e/2/Math.PI)<0&&(n+=360),i=Math.sqrt(r*r+o*o),[a,i,n]}function _(t){return p(y(t))}function k(t){var e,n,i,a=t[0],r=t[1];return i=t[2]/360*2*Math.PI,e=r*Math.cos(i),n=r*Math.sin(i),[a,e,n]}function w(t){return M[t]}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:o,rgb2cmyk:s,rgb2keyword:l,rgb2xyz:u,rgb2lab:d,rgb2lch:function(t){return x(d(t))},hsl2rgb:c,hsl2hsv:function(t){var e,n,i=t[0],a=t[1]/100,r=t[2]/100;return 0===r?[0,0,0]:(r*=2,a*=r<=1?r:2-r,n=(r+a)/2,e=2*a/(r+a),[i,100*e,100*n])},hsl2hwb:function(t){return o(c(t))},hsl2cmyk:function(t){return s(c(t))},hsl2keyword:function(t){return l(c(t))},hsv2rgb:h,hsv2hsl:function(t){var e,n,i=t[0],a=t[1]/100,r=t[2]/100;return n=(2-a)*r,e=a*r,e/=n<=1?n:2-n,e=e||0,n/=2,[i,100*e,100*n]},hsv2hwb:function(t){return o(h(t))},hsv2cmyk:function(t){return s(h(t))},hsv2keyword:function(t){return l(h(t))},hwb2rgb:f,hwb2hsl:function(t){return i(f(t))},hwb2hsv:function(t){return a(f(t))},hwb2cmyk:function(t){return s(f(t))},hwb2keyword:function(t){return l(f(t))},cmyk2rgb:m,cmyk2hsl:function(t){return i(m(t))},cmyk2hsv:function(t){return a(m(t))},cmyk2hwb:function(t){return o(m(t))},cmyk2keyword:function(t){return l(m(t))},keyword2rgb:w,keyword2hsl:function(t){return i(w(t))},keyword2hsv:function(t){return a(w(t))},keyword2hwb:function(t){return o(w(t))},keyword2cmyk:function(t){return s(w(t))},keyword2lab:function(t){return d(w(t))},keyword2xyz:function(t){return u(w(t))},xyz2rgb:p,xyz2lab:v,xyz2lch:function(t){return x(v(t))},lab2xyz:y,lab2rgb:_,lab2lch:x,lch2lab:k,lch2xyz:function(t){return y(k(t))},lch2rgb:function(t){return _(k(t))}};var M={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},S={};for(var D in M)S[JSON.stringify(M[D])]=D},{}],4:[function(t,e,n){var i=t(3),a=function(){return new u};for(var r in i){a[r+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(r);var o=/(\w+)2(\w+)/.exec(r),s=o[1],l=o[2];(a[s]=a[s]||{})[l]=a[r]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var n=i[t](e);if("string"==typeof n||void 0===n)return n;for(var a=0;a<n.length;a++)n[a]=Math.round(n[a]);return n}}(r)}var u=function(){this.convs={}};u.prototype.routeSpace=function(t,e){var n=e[0];return void 0===n?this.getValues(t):("number"==typeof n&&(n=Array.prototype.slice.call(e)),this.setValues(t,n))},u.prototype.setValues=function(t,e){return this.space=t,this.convs={},this.convs[t]=e,this},u.prototype.getValues=function(t){var e=this.convs[t];if(!e){var n=this.space,i=this.convs[n];e=a[n][t](i),this.convs[t]=e}return e},["rgb","hsl","hsv","cmyk","keyword"].forEach(function(t){u.prototype[t]=function(e){return this.routeSpace(t,arguments)}}),e.exports=a},{3:3}],5:[function(t,e,n){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],6:[function(t,e,n){!function(t,i){"object"==typeof n&&void 0!==e?e.exports=i():t.moment=i()}(this,function(){"use strict";function n(){return xe.apply(null,arguments)}function i(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function a(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function r(t){var e;for(e in t)return!1;return!0}function o(t){return void 0===t}function s(t){return"number"==typeof t||"[object Number]"===Object.prototype.toString.call(t)}function l(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function u(t,e){var n,i=[];for(n=0;n<t.length;++n)i.push(e(t[n],n));return i}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function c(t,e){for(var n in e)d(e,n)&&(t[n]=e[n]);return d(e,"toString")&&(t.toString=e.toString),d(e,"valueOf")&&(t.valueOf=e.valueOf),t}function h(t,e,n,i){return Yt(t,e,n,i,!0).utc()}function f(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function g(t){return null==t._pf&&(t._pf=f()),t._pf}function m(t){if(null==t._isValid){var e=g(t),n=ke.call(e.parsedDateParts,function(t){return null!=t}),i=!isNaN(t._d.getTime())&&e.overflow<0&&!e.empty&&!e.invalidMonth&&!e.invalidWeekday&&!e.nullInput&&!e.invalidFormat&&!e.userInvalidated&&(!e.meridiem||e.meridiem&&n);if(t._strict&&(i=i&&0===e.charsLeftOver&&0===e.unusedTokens.length&&void 0===e.bigHour),null!=Object.isFrozen&&Object.isFrozen(t))return i;t._isValid=i}return t._isValid}function p(t){var e=h(NaN);return null!=t?c(g(e),t):g(e).userInvalidated=!0,e}function v(t,e){var n,i,a;if(o(e._isAMomentObject)||(t._isAMomentObject=e._isAMomentObject),o(e._i)||(t._i=e._i),o(e._f)||(t._f=e._f),o(e._l)||(t._l=e._l),o(e._strict)||(t._strict=e._strict),o(e._tzm)||(t._tzm=e._tzm),o(e._isUTC)||(t._isUTC=e._isUTC),o(e._offset)||(t._offset=e._offset),o(e._pf)||(t._pf=g(e)),o(e._locale)||(t._locale=e._locale),we.length>0)for(n=0;n<we.length;n++)o(a=e[i=we[n]])||(t[i]=a);return t}function y(t){v(this,t),this._d=new Date(null!=t._d?t._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),!1===Me&&(Me=!0,n.updateOffset(this),Me=!1)}function b(t){return t instanceof y||null!=t&&null!=t._isAMomentObject}function x(t){return t<0?Math.ceil(t)||0:Math.floor(t)}function _(t){var e=+t,n=0;return 0!==e&&isFinite(e)&&(n=x(e)),n}function k(t,e,n){var i,a=Math.min(t.length,e.length),r=Math.abs(t.length-e.length),o=0;for(i=0;i<a;i++)(n&&t[i]!==e[i]||!n&&_(t[i])!==_(e[i]))&&o++;return o+r}function w(t){!1===n.suppressDeprecationWarnings&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+t)}function M(t,e){var i=!0;return c(function(){if(null!=n.deprecationHandler&&n.deprecationHandler(null,t),i){for(var a,r=[],o=0;o<arguments.length;o++){if(a="","object"==typeof arguments[o]){a+="\n["+o+"] ";for(var s in arguments[0])a+=s+": "+arguments[0][s]+", ";a=a.slice(0,-2)}else a=arguments[o];r.push(a)}w(t+"\nArguments: "+Array.prototype.slice.call(r).join("")+"\n"+(new Error).stack),i=!1}return e.apply(this,arguments)},e)}function S(t,e){null!=n.deprecationHandler&&n.deprecationHandler(t,e),Se[t]||(w(e),Se[t]=!0)}function D(t){return t instanceof Function||"[object Function]"===Object.prototype.toString.call(t)}function C(t,e){var n,i=c({},t);for(n in e)d(e,n)&&(a(t[n])&&a(e[n])?(i[n]={},c(i[n],t[n]),c(i[n],e[n])):null!=e[n]?i[n]=e[n]:delete i[n]);for(n in t)d(t,n)&&!d(e,n)&&a(t[n])&&(i[n]=c({},i[n]));return i}function P(t){null!=t&&this.set(t)}function T(t,e){var n=t.toLowerCase();Te[n]=Te[n+"s"]=Te[e]=t}function A(t){return"string"==typeof t?Te[t]||Te[t.toLowerCase()]:void 0}function I(t){var e,n,i={};for(n in t)d(t,n)&&(e=A(n))&&(i[e]=t[n]);return i}function O(t,e){Ae[t]=e}function F(t){var e=[];for(var n in t)e.push({unit:n,priority:Ae[n]});return e.sort(function(t,e){return t.priority-e.priority}),e}function R(t,e){return function(i){return null!=i?(W(this,t,i),n.updateOffset(this,e),this):L(this,t)}}function L(t,e){return t.isValid()?t._d["get"+(t._isUTC?"UTC":"")+e]():NaN}function W(t,e,n){t.isValid()&&t._d["set"+(t._isUTC?"UTC":"")+e](n)}function Y(t,e,n){var i=""+Math.abs(t),a=e-i.length;return(t>=0?n?"+":"":"-")+Math.pow(10,Math.max(0,a)).toString().substr(1)+i}function N(t,e,n,i){var a=i;"string"==typeof i&&(a=function(){return this[i]()}),t&&(Re[t]=a),e&&(Re[e[0]]=function(){return Y(a.apply(this,arguments),e[1],e[2])}),n&&(Re[n]=function(){return this.localeData().ordinal(a.apply(this,arguments),t)})}function z(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function B(t){var e,n,i=t.match(Ie);for(e=0,n=i.length;e<n;e++)Re[i[e]]?i[e]=Re[i[e]]:i[e]=z(i[e]);return function(e){var a,r="";for(a=0;a<n;a++)r+=D(i[a])?i[a].call(e,t):i[a];return r}}function V(t,e){return t.isValid()?(e=H(e,t.localeData()),Fe[e]=Fe[e]||B(e),Fe[e](t)):t.localeData().invalidDate()}function H(t,e){var n=5;for(Oe.lastIndex=0;n>=0&&Oe.test(t);)t=t.replace(Oe,function(t){return e.longDateFormat(t)||t}),Oe.lastIndex=0,n-=1;return t}function E(t,e,n){Ke[t]=D(e)?e:function(t,i){return t&&n?n:e}}function j(t,e){return d(Ke,t)?Ke[t](e._strict,e._locale):new RegExp(U(t))}function U(t){return q(t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,a){return e||n||i||a}))}function q(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function G(t,e){var n,i=e;for("string"==typeof t&&(t=[t]),s(e)&&(i=function(t,n){n[e]=_(t)}),n=0;n<t.length;n++)Qe[t[n]]=i}function Z(t,e){G(t,function(t,n,i,a){i._w=i._w||{},e(t,i._w,i,a)})}function X(t,e,n){null!=e&&d(Qe,t)&&Qe[t](e,n._a,n,t)}function J(t,e){return new Date(Date.UTC(t,e+1,0)).getUTCDate()}function K(t,e,n){var i,a,r,o=t.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],i=0;i<12;++i)r=h([2e3,i]),this._shortMonthsParse[i]=this.monthsShort(r,"").toLocaleLowerCase(),this._longMonthsParse[i]=this.months(r,"").toLocaleLowerCase();return n?"MMM"===e?-1!==(a=un.call(this._shortMonthsParse,o))?a:null:-1!==(a=un.call(this._longMonthsParse,o))?a:null:"MMM"===e?-1!==(a=un.call(this._shortMonthsParse,o))?a:-1!==(a=un.call(this._longMonthsParse,o))?a:null:-1!==(a=un.call(this._longMonthsParse,o))?a:-1!==(a=un.call(this._shortMonthsParse,o))?a:null}function Q(t,e){var n;if(!t.isValid())return t;if("string"==typeof e)if(/^\d+$/.test(e))e=_(e);else if(e=t.localeData().monthsParse(e),!s(e))return t;return n=Math.min(t.date(),J(t.year(),e)),t._d["set"+(t._isUTC?"UTC":"")+"Month"](e,n),t}function $(t){return null!=t?(Q(this,t),n.updateOffset(this,!0),this):L(this,"Month")}function tt(){function t(t,e){return e.length-t.length}var e,n,i=[],a=[],r=[];for(e=0;e<12;e++)n=h([2e3,e]),i.push(this.monthsShort(n,"")),a.push(this.months(n,"")),r.push(this.months(n,"")),r.push(this.monthsShort(n,""));for(i.sort(t),a.sort(t),r.sort(t),e=0;e<12;e++)i[e]=q(i[e]),a[e]=q(a[e]);for(e=0;e<24;e++)r[e]=q(r[e]);this._monthsRegex=new RegExp("^("+r.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+i.join("|")+")","i")}function et(t){return nt(t)?366:365}function nt(t){return t%4==0&&t%100!=0||t%400==0}function it(t,e,n,i,a,r,o){var s=new Date(t,e,n,i,a,r,o);return t<100&&t>=0&&isFinite(s.getFullYear())&&s.setFullYear(t),s}function at(t){var e=new Date(Date.UTC.apply(null,arguments));return t<100&&t>=0&&isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t),e}function rt(t,e,n){var i=7+e-n;return-((7+at(t,0,i).getUTCDay()-e)%7)+i-1}function ot(t,e,n,i,a){var r,o,s=1+7*(e-1)+(7+n-i)%7+rt(t,i,a);return s<=0?o=et(r=t-1)+s:s>et(t)?(r=t+1,o=s-et(t)):(r=t,o=s),{year:r,dayOfYear:o}}function st(t,e,n){var i,a,r=rt(t.year(),e,n),o=Math.floor((t.dayOfYear()-r-1)/7)+1;return o<1?i=o+lt(a=t.year()-1,e,n):o>lt(t.year(),e,n)?(i=o-lt(t.year(),e,n),a=t.year()+1):(a=t.year(),i=o),{week:i,year:a}}function lt(t,e,n){var i=rt(t,e,n),a=rt(t+1,e,n);return(et(t)-i+a)/7}function ut(t,e){return"string"!=typeof t?t:isNaN(t)?"number"==typeof(t=e.weekdaysParse(t))?t:null:parseInt(t,10)}function dt(t,e){return"string"==typeof t?e.weekdaysParse(t)%7||7:isNaN(t)?null:t}function ct(t,e,n){var i,a,r,o=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],i=0;i<7;++i)r=h([2e3,1]).day(i),this._minWeekdaysParse[i]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[i]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[i]=this.weekdays(r,"").toLocaleLowerCase();return n?"dddd"===e?-1!==(a=un.call(this._weekdaysParse,o))?a:null:"ddd"===e?-1!==(a=un.call(this._shortWeekdaysParse,o))?a:null:-1!==(a=un.call(this._minWeekdaysParse,o))?a:null:"dddd"===e?-1!==(a=un.call(this._weekdaysParse,o))?a:-1!==(a=un.call(this._shortWeekdaysParse,o))?a:-1!==(a=un.call(this._minWeekdaysParse,o))?a:null:"ddd"===e?-1!==(a=un.call(this._shortWeekdaysParse,o))?a:-1!==(a=un.call(this._weekdaysParse,o))?a:-1!==(a=un.call(this._minWeekdaysParse,o))?a:null:-1!==(a=un.call(this._minWeekdaysParse,o))?a:-1!==(a=un.call(this._weekdaysParse,o))?a:-1!==(a=un.call(this._shortWeekdaysParse,o))?a:null}function ht(){function t(t,e){return e.length-t.length}var e,n,i,a,r,o=[],s=[],l=[],u=[];for(e=0;e<7;e++)n=h([2e3,1]).day(e),i=this.weekdaysMin(n,""),a=this.weekdaysShort(n,""),r=this.weekdays(n,""),o.push(i),s.push(a),l.push(r),u.push(i),u.push(a),u.push(r);for(o.sort(t),s.sort(t),l.sort(t),u.sort(t),e=0;e<7;e++)s[e]=q(s[e]),l[e]=q(l[e]),u[e]=q(u[e]);this._weekdaysRegex=new RegExp("^("+u.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+o.join("|")+")","i")}function ft(){return this.hours()%12||12}function gt(t,e){N(t,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}function mt(t,e){return e._meridiemParse}function pt(t){return t?t.toLowerCase().replace("_","-"):t}function vt(t){for(var e,n,i,a,r=0;r<t.length;){for(e=(a=pt(t[r]).split("-")).length,n=(n=pt(t[r+1]))?n.split("-"):null;e>0;){if(i=yt(a.slice(0,e).join("-")))return i;if(n&&n.length>=e&&k(a,n,!0)>=e-1)break;e--}r++}return null}function yt(n){var i=null;if(!Sn[n]&&void 0!==e&&e&&e.exports)try{i=kn._abbr,t("./locale/"+n),bt(i)}catch(t){}return Sn[n]}function bt(t,e){var n;return t&&(n=o(e)?_t(t):xt(t,e))&&(kn=n),kn._abbr}function xt(t,e){if(null!==e){var n=Mn;if(e.abbr=t,null!=Sn[t])S("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=Sn[t]._config;else if(null!=e.parentLocale){if(null==Sn[e.parentLocale])return Dn[e.parentLocale]||(Dn[e.parentLocale]=[]),Dn[e.parentLocale].push({name:t,config:e}),null;n=Sn[e.parentLocale]._config}return Sn[t]=new P(C(n,e)),Dn[t]&&Dn[t].forEach(function(t){xt(t.name,t.config)}),bt(t),Sn[t]}return delete Sn[t],null}function _t(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return kn;if(!i(t)){if(e=yt(t))return e;t=[t]}return vt(t)}function kt(t){var e,n=t._a;return n&&-2===g(t).overflow&&(e=n[tn]<0||n[tn]>11?tn:n[en]<1||n[en]>J(n[$e],n[tn])?en:n[nn]<0||n[nn]>24||24===n[nn]&&(0!==n[an]||0!==n[rn]||0!==n[on])?nn:n[an]<0||n[an]>59?an:n[rn]<0||n[rn]>59?rn:n[on]<0||n[on]>999?on:-1,g(t)._overflowDayOfYear&&(e<$e||e>en)&&(e=en),g(t)._overflowWeeks&&-1===e&&(e=sn),g(t)._overflowWeekday&&-1===e&&(e=ln),g(t).overflow=e),t}function wt(t){var e,n,i,a,r,o,s=t._i,l=Cn.exec(s)||Pn.exec(s);if(l){for(g(t).iso=!0,e=0,n=An.length;e<n;e++)if(An[e][1].exec(l[1])){a=An[e][0],i=!1!==An[e][2];break}if(null==a)return void(t._isValid=!1);if(l[3]){for(e=0,n=In.length;e<n;e++)if(In[e][1].exec(l[3])){r=(l[2]||" ")+In[e][0];break}if(null==r)return void(t._isValid=!1)}if(!i&&null!=r)return void(t._isValid=!1);if(l[4]){if(!Tn.exec(l[4]))return void(t._isValid=!1);o="Z"}t._f=a+(r||"")+(o||""),At(t)}else t._isValid=!1}function Mt(t){var e,n,i,a,r,o,s,l,u={" GMT":" +0000"," EDT":" -0400"," EST":" -0500"," CDT":" -0500"," CST":" -0600"," MDT":" -0600"," MST":" -0700"," PDT":" -0700"," PST":" -0800"};if(e=t._i.replace(/\([^\)]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s|\s$/g,""),n=Fn.exec(e)){if(i=n[1]?"ddd"+(5===n[1].length?", ":" "):"",a="D MMM "+(n[2].length>10?"YYYY ":"YY "),r="HH:mm"+(n[4]?":ss":""),n[1]){var d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][new Date(n[2]).getDay()];if(n[1].substr(0,3)!==d)return g(t).weekdayMismatch=!0,void(t._isValid=!1)}switch(n[5].length){case 2:s=0===l?" +0000":((l="YXWVUTSRQPONZABCDEFGHIKLM".indexOf(n[5][1].toUpperCase())-12)<0?" -":" +")+(""+l).replace(/^-?/,"0").match(/..$/)[0]+"00";break;case 4:s=u[n[5]];break;default:s=u[" GMT"]}n[5]=s,t._i=n.splice(1).join(""),o=" ZZ",t._f=i+a+r+o,At(t),g(t).rfc2822=!0}else t._isValid=!1}function St(t){var e=On.exec(t._i);null===e?(wt(t),!1===t._isValid&&(delete t._isValid,Mt(t),!1===t._isValid&&(delete t._isValid,n.createFromInputFallback(t)))):t._d=new Date(+e[1])}function Dt(t,e,n){return null!=t?t:null!=e?e:n}function Ct(t){var e=new Date(n.now());return t._useUTC?[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()]:[e.getFullYear(),e.getMonth(),e.getDate()]}function Pt(t){var e,n,i,a,r=[];if(!t._d){for(i=Ct(t),t._w&&null==t._a[en]&&null==t._a[tn]&&Tt(t),null!=t._dayOfYear&&(a=Dt(t._a[$e],i[$e]),(t._dayOfYear>et(a)||0===t._dayOfYear)&&(g(t)._overflowDayOfYear=!0),n=at(a,0,t._dayOfYear),t._a[tn]=n.getUTCMonth(),t._a[en]=n.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=r[e]=i[e];for(;e<7;e++)t._a[e]=r[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[nn]&&0===t._a[an]&&0===t._a[rn]&&0===t._a[on]&&(t._nextDay=!0,t._a[nn]=0),t._d=(t._useUTC?at:it).apply(null,r),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[nn]=24)}}function Tt(t){var e,n,i,a,r,o,s,l;if(null!=(e=t._w).GG||null!=e.W||null!=e.E)r=1,o=4,n=Dt(e.GG,t._a[$e],st(Nt(),1,4).year),i=Dt(e.W,1),((a=Dt(e.E,1))<1||a>7)&&(l=!0);else{r=t._locale._week.dow,o=t._locale._week.doy;var u=st(Nt(),r,o);n=Dt(e.gg,t._a[$e],u.year),i=Dt(e.w,u.week),null!=e.d?((a=e.d)<0||a>6)&&(l=!0):null!=e.e?(a=e.e+r,(e.e<0||e.e>6)&&(l=!0)):a=r}i<1||i>lt(n,r,o)?g(t)._overflowWeeks=!0:null!=l?g(t)._overflowWeekday=!0:(s=ot(n,i,a,r,o),t._a[$e]=s.year,t._dayOfYear=s.dayOfYear)}function At(t){if(t._f!==n.ISO_8601)if(t._f!==n.RFC_2822){t._a=[],g(t).empty=!0;var e,i,a,r,o,s=""+t._i,l=s.length,u=0;for(a=H(t._f,t._locale).match(Ie)||[],e=0;e<a.length;e++)r=a[e],(i=(s.match(j(r,t))||[])[0])&&((o=s.substr(0,s.indexOf(i))).length>0&&g(t).unusedInput.push(o),s=s.slice(s.indexOf(i)+i.length),u+=i.length),Re[r]?(i?g(t).empty=!1:g(t).unusedTokens.push(r),X(r,i,t)):t._strict&&!i&&g(t).unusedTokens.push(r);g(t).charsLeftOver=l-u,s.length>0&&g(t).unusedInput.push(s),t._a[nn]<=12&&!0===g(t).bigHour&&t._a[nn]>0&&(g(t).bigHour=void 0),g(t).parsedDateParts=t._a.slice(0),g(t).meridiem=t._meridiem,t._a[nn]=It(t._locale,t._a[nn],t._meridiem),Pt(t),kt(t)}else Mt(t);else wt(t)}function It(t,e,n){var i;return null==n?e:null!=t.meridiemHour?t.meridiemHour(e,n):null!=t.isPM?((i=t.isPM(n))&&e<12&&(e+=12),i||12!==e||(e=0),e):e}function Ot(t){var e,n,i,a,r;if(0===t._f.length)return g(t).invalidFormat=!0,void(t._d=new Date(NaN));for(a=0;a<t._f.length;a++)r=0,e=v({},t),null!=t._useUTC&&(e._useUTC=t._useUTC),e._f=t._f[a],At(e),m(e)&&(r+=g(e).charsLeftOver,r+=10*g(e).unusedTokens.length,g(e).score=r,(null==i||r<i)&&(i=r,n=e));c(t,n||e)}function Ft(t){if(!t._d){var e=I(t._i);t._a=u([e.year,e.month,e.day||e.date,e.hour,e.minute,e.second,e.millisecond],function(t){return t&&parseInt(t,10)}),Pt(t)}}function Rt(t){var e=new y(kt(Lt(t)));return e._nextDay&&(e.add(1,"d"),e._nextDay=void 0),e}function Lt(t){var e=t._i,n=t._f;return t._locale=t._locale||_t(t._l),null===e||void 0===n&&""===e?p({nullInput:!0}):("string"==typeof e&&(t._i=e=t._locale.preparse(e)),b(e)?new y(kt(e)):(l(e)?t._d=e:i(n)?Ot(t):n?At(t):Wt(t),m(t)||(t._d=null),t))}function Wt(t){var e=t._i;o(e)?t._d=new Date(n.now()):l(e)?t._d=new Date(e.valueOf()):"string"==typeof e?St(t):i(e)?(t._a=u(e.slice(0),function(t){return parseInt(t,10)}),Pt(t)):a(e)?Ft(t):s(e)?t._d=new Date(e):n.createFromInputFallback(t)}function Yt(t,e,n,o,s){var l={};return!0!==n&&!1!==n||(o=n,n=void 0),(a(t)&&r(t)||i(t)&&0===t.length)&&(t=void 0),l._isAMomentObject=!0,l._useUTC=l._isUTC=s,l._l=n,l._i=t,l._f=e,l._strict=o,Rt(l)}function Nt(t,e,n,i){return Yt(t,e,n,i,!1)}function zt(t,e){var n,a;if(1===e.length&&i(e[0])&&(e=e[0]),!e.length)return Nt();for(n=e[0],a=1;a<e.length;++a)e[a].isValid()&&!e[a][t](n)||(n=e[a]);return n}function Bt(t){for(var e in t)if(-1===Wn.indexOf(e)||null!=t[e]&&isNaN(t[e]))return!1;for(var n=!1,i=0;i<Wn.length;++i)if(t[Wn[i]]){if(n)return!1;parseFloat(t[Wn[i]])!==_(t[Wn[i]])&&(n=!0)}return!0}function Vt(t){var e=I(t),n=e.year||0,i=e.quarter||0,a=e.month||0,r=e.week||0,o=e.day||0,s=e.hour||0,l=e.minute||0,u=e.second||0,d=e.millisecond||0;this._isValid=Bt(e),this._milliseconds=+d+1e3*u+6e4*l+1e3*s*60*60,this._days=+o+7*r,this._months=+a+3*i+12*n,this._data={},this._locale=_t(),this._bubble()}function Ht(t){return t instanceof Vt}function Et(t){return t<0?-1*Math.round(-1*t):Math.round(t)}function jt(t,e){N(t,0,0,function(){var t=this.utcOffset(),n="+";return t<0&&(t=-t,n="-"),n+Y(~~(t/60),2)+e+Y(~~t%60,2)})}function Ut(t,e){var n=(e||"").match(t);if(null===n)return null;var i=((n[n.length-1]||[])+"").match(Yn)||["-",0,0],a=60*i[1]+_(i[2]);return 0===a?0:"+"===i[0]?a:-a}function qt(t,e){var i,a;return e._isUTC?(i=e.clone(),a=(b(t)||l(t)?t.valueOf():Nt(t).valueOf())-i.valueOf(),i._d.setTime(i._d.valueOf()+a),n.updateOffset(i,!1),i):Nt(t).local()}function Gt(t){return 15*-Math.round(t._d.getTimezoneOffset()/15)}function Zt(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}function Xt(t,e){var n,i,a,r=t,o=null;return Ht(t)?r={ms:t._milliseconds,d:t._days,M:t._months}:s(t)?(r={},e?r[e]=t:r.milliseconds=t):(o=Nn.exec(t))?(n="-"===o[1]?-1:1,r={y:0,d:_(o[en])*n,h:_(o[nn])*n,m:_(o[an])*n,s:_(o[rn])*n,ms:_(Et(1e3*o[on]))*n}):(o=zn.exec(t))?(n="-"===o[1]?-1:1,r={y:Jt(o[2],n),M:Jt(o[3],n),w:Jt(o[4],n),d:Jt(o[5],n),h:Jt(o[6],n),m:Jt(o[7],n),s:Jt(o[8],n)}):null==r?r={}:"object"==typeof r&&("from"in r||"to"in r)&&(a=Qt(Nt(r.from),Nt(r.to)),(r={}).ms=a.milliseconds,r.M=a.months),i=new Vt(r),Ht(t)&&d(t,"_locale")&&(i._locale=t._locale),i}function Jt(t,e){var n=t&&parseFloat(t.replace(",","."));return(isNaN(n)?0:n)*e}function Kt(t,e){var n={milliseconds:0,months:0};return n.months=e.month()-t.month()+12*(e.year()-t.year()),t.clone().add(n.months,"M").isAfter(e)&&--n.months,n.milliseconds=+e-+t.clone().add(n.months,"M"),n}function Qt(t,e){var n;return t.isValid()&&e.isValid()?(e=qt(e,t),t.isBefore(e)?n=Kt(t,e):((n=Kt(e,t)).milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function $t(t,e){return function(n,i){var a,r;return null===i||isNaN(+i)||(S(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),r=n,n=i,i=r),n="string"==typeof n?+n:n,a=Xt(n,i),te(this,a,t),this}}function te(t,e,i,a){var r=e._milliseconds,o=Et(e._days),s=Et(e._months);t.isValid()&&(a=null==a||a,r&&t._d.setTime(t._d.valueOf()+r*i),o&&W(t,"Date",L(t,"Date")+o*i),s&&Q(t,L(t,"Month")+s*i),a&&n.updateOffset(t,o||s))}function ee(t,e){var n,i=12*(e.year()-t.year())+(e.month()-t.month()),a=t.clone().add(i,"months");return n=e-a<0?(e-a)/(a-t.clone().add(i-1,"months")):(e-a)/(t.clone().add(i+1,"months")-a),-(i+n)||0}function ne(t){var e;return void 0===t?this._locale._abbr:(null!=(e=_t(t))&&(this._locale=e),this)}function ie(){return this._locale}function ae(t,e){N(0,[t,t.length],0,e)}function re(t,e,n,i,a){var r;return null==t?st(this,i,a).year:(r=lt(t,i,a),e>r&&(e=r),oe.call(this,t,e,n,i,a))}function oe(t,e,n,i,a){var r=ot(t,e,n,i,a),o=at(r.year,0,r.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}function se(t){return t}function le(t,e,n,i){var a=_t(),r=h().set(i,e);return a[n](r,t)}function ue(t,e,n){if(s(t)&&(e=t,t=void 0),t=t||"",null!=e)return le(t,e,n,"month");var i,a=[];for(i=0;i<12;i++)a[i]=le(t,i,n,"month");return a}function de(t,e,n,i){"boolean"==typeof t?(s(e)&&(n=e,e=void 0),e=e||""):(n=e=t,t=!1,s(e)&&(n=e,e=void 0),e=e||"");var a=_t(),r=t?a._week.dow:0;if(null!=n)return le(e,(n+r)%7,i,"day");var o,l=[];for(o=0;o<7;o++)l[o]=le(e,(o+r)%7,i,"day");return l}function ce(t,e,n,i){var a=Xt(e,n);return t._milliseconds+=i*a._milliseconds,t._days+=i*a._days,t._months+=i*a._months,t._bubble()}function he(t){return t<0?Math.floor(t):Math.ceil(t)}function fe(t){return 4800*t/146097}function ge(t){return 146097*t/4800}function me(t){return function(){return this.as(t)}}function pe(t){return function(){return this.isValid()?this._data[t]:NaN}}function ve(t,e,n,i,a){return a.relativeTime(e||1,!!n,t,i)}function ye(t,e,n){var i=Xt(t).abs(),a=hi(i.as("s")),r=hi(i.as("m")),o=hi(i.as("h")),s=hi(i.as("d")),l=hi(i.as("M")),u=hi(i.as("y")),d=a<=fi.ss&&["s",a]||a<fi.s&&["ss",a]||r<=1&&["m"]||r<fi.m&&["mm",r]||o<=1&&["h"]||o<fi.h&&["hh",o]||s<=1&&["d"]||s<fi.d&&["dd",s]||l<=1&&["M"]||l<fi.M&&["MM",l]||u<=1&&["y"]||["yy",u];return d[2]=e,d[3]=+t>0,d[4]=n,ve.apply(null,d)}function be(){if(!this.isValid())return this.localeData().invalidDate();var t,e,n,i=gi(this._milliseconds)/1e3,a=gi(this._days),r=gi(this._months);e=x((t=x(i/60))/60),i%=60,t%=60;var o=n=x(r/12),s=r%=12,l=a,u=e,d=t,c=i,h=this.asSeconds();return h?(h<0?"-":"")+"P"+(o?o+"Y":"")+(s?s+"M":"")+(l?l+"D":"")+(u||d||c?"T":"")+(u?u+"H":"")+(d?d+"M":"")+(c?c+"S":""):"P0D"}var xe,_e,ke=_e=Array.prototype.some?Array.prototype.some:function(t){for(var e=Object(this),n=e.length>>>0,i=0;i<n;i++)if(i in e&&t.call(this,e[i],i,e))return!0;return!1},we=n.momentProperties=[],Me=!1,Se={};n.suppressDeprecationWarnings=!1,n.deprecationHandler=null;var De,Ce,Pe=De=Object.keys?Object.keys:function(t){var e,n=[];for(e in t)d(t,e)&&n.push(e);return n},Te={},Ae={},Ie=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Oe=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Fe={},Re={},Le=/\d/,We=/\d\d/,Ye=/\d{3}/,Ne=/\d{4}/,ze=/[+-]?\d{6}/,Be=/\d\d?/,Ve=/\d\d\d\d?/,He=/\d\d\d\d\d\d?/,Ee=/\d{1,3}/,je=/\d{1,4}/,Ue=/[+-]?\d{1,6}/,qe=/\d+/,Ge=/[+-]?\d+/,Ze=/Z|[+-]\d\d:?\d\d/gi,Xe=/Z|[+-]\d\d(?::?\d\d)?/gi,Je=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Ke={},Qe={},$e=0,tn=1,en=2,nn=3,an=4,rn=5,on=6,sn=7,ln=8,un=Ce=Array.prototype.indexOf?Array.prototype.indexOf:function(t){var e;for(e=0;e<this.length;++e)if(this[e]===t)return e;return-1};N("M",["MM",2],"Mo",function(){return this.month()+1}),N("MMM",0,0,function(t){return this.localeData().monthsShort(this,t)}),N("MMMM",0,0,function(t){return this.localeData().months(this,t)}),T("month","M"),O("month",8),E("M",Be),E("MM",Be,We),E("MMM",function(t,e){return e.monthsShortRegex(t)}),E("MMMM",function(t,e){return e.monthsRegex(t)}),G(["M","MM"],function(t,e){e[tn]=_(t)-1}),G(["MMM","MMMM"],function(t,e,n,i){var a=n._locale.monthsParse(t,i,n._strict);null!=a?e[tn]=a:g(n).invalidMonth=t});var dn=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,cn="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),hn="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),fn=Je,gn=Je;N("Y",0,0,function(){var t=this.year();return t<=9999?""+t:"+"+t}),N(0,["YY",2],0,function(){return this.year()%100}),N(0,["YYYY",4],0,"year"),N(0,["YYYYY",5],0,"year"),N(0,["YYYYYY",6,!0],0,"year"),T("year","y"),O("year",1),E("Y",Ge),E("YY",Be,We),E("YYYY",je,Ne),E("YYYYY",Ue,ze),E("YYYYYY",Ue,ze),G(["YYYYY","YYYYYY"],$e),G("YYYY",function(t,e){e[$e]=2===t.length?n.parseTwoDigitYear(t):_(t)}),G("YY",function(t,e){e[$e]=n.parseTwoDigitYear(t)}),G("Y",function(t,e){e[$e]=parseInt(t,10)}),n.parseTwoDigitYear=function(t){return _(t)+(_(t)>68?1900:2e3)};var mn=R("FullYear",!0);N("w",["ww",2],"wo","week"),N("W",["WW",2],"Wo","isoWeek"),T("week","w"),T("isoWeek","W"),O("week",5),O("isoWeek",5),E("w",Be),E("ww",Be,We),E("W",Be),E("WW",Be,We),Z(["w","ww","W","WW"],function(t,e,n,i){e[i.substr(0,1)]=_(t)});N("d",0,"do","day"),N("dd",0,0,function(t){return this.localeData().weekdaysMin(this,t)}),N("ddd",0,0,function(t){return this.localeData().weekdaysShort(this,t)}),N("dddd",0,0,function(t){return this.localeData().weekdays(this,t)}),N("e",0,0,"weekday"),N("E",0,0,"isoWeekday"),T("day","d"),T("weekday","e"),T("isoWeekday","E"),O("day",11),O("weekday",11),O("isoWeekday",11),E("d",Be),E("e",Be),E("E",Be),E("dd",function(t,e){return e.weekdaysMinRegex(t)}),E("ddd",function(t,e){return e.weekdaysShortRegex(t)}),E("dddd",function(t,e){return e.weekdaysRegex(t)}),Z(["dd","ddd","dddd"],function(t,e,n,i){var a=n._locale.weekdaysParse(t,i,n._strict);null!=a?e.d=a:g(n).invalidWeekday=t}),Z(["d","e","E"],function(t,e,n,i){e[i]=_(t)});var pn="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),vn="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),yn="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),bn=Je,xn=Je,_n=Je;N("H",["HH",2],0,"hour"),N("h",["hh",2],0,ft),N("k",["kk",2],0,function(){return this.hours()||24}),N("hmm",0,0,function(){return""+ft.apply(this)+Y(this.minutes(),2)}),N("hmmss",0,0,function(){return""+ft.apply(this)+Y(this.minutes(),2)+Y(this.seconds(),2)}),N("Hmm",0,0,function(){return""+this.hours()+Y(this.minutes(),2)}),N("Hmmss",0,0,function(){return""+this.hours()+Y(this.minutes(),2)+Y(this.seconds(),2)}),gt("a",!0),gt("A",!1),T("hour","h"),O("hour",13),E("a",mt),E("A",mt),E("H",Be),E("h",Be),E("k",Be),E("HH",Be,We),E("hh",Be,We),E("kk",Be,We),E("hmm",Ve),E("hmmss",He),E("Hmm",Ve),E("Hmmss",He),G(["H","HH"],nn),G(["k","kk"],function(t,e,n){var i=_(t);e[nn]=24===i?0:i}),G(["a","A"],function(t,e,n){n._isPm=n._locale.isPM(t),n._meridiem=t}),G(["h","hh"],function(t,e,n){e[nn]=_(t),g(n).bigHour=!0}),G("hmm",function(t,e,n){var i=t.length-2;e[nn]=_(t.substr(0,i)),e[an]=_(t.substr(i)),g(n).bigHour=!0}),G("hmmss",function(t,e,n){var i=t.length-4,a=t.length-2;e[nn]=_(t.substr(0,i)),e[an]=_(t.substr(i,2)),e[rn]=_(t.substr(a)),g(n).bigHour=!0}),G("Hmm",function(t,e,n){var i=t.length-2;e[nn]=_(t.substr(0,i)),e[an]=_(t.substr(i))}),G("Hmmss",function(t,e,n){var i=t.length-4,a=t.length-2;e[nn]=_(t.substr(0,i)),e[an]=_(t.substr(i,2)),e[rn]=_(t.substr(a))});var kn,wn=R("Hours",!0),Mn={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:cn,monthsShort:hn,week:{dow:0,doy:6},weekdays:pn,weekdaysMin:yn,weekdaysShort:vn,meridiemParse:/[ap]\.?m?\.?/i},Sn={},Dn={},Cn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Pn=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Tn=/Z|[+-]\d\d(?::?\d\d)?/,An=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],In=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],On=/^\/?Date\((\-?\d+)/i,Fn=/^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/;n.createFromInputFallback=M("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""))}),n.ISO_8601=function(){},n.RFC_2822=function(){};var Rn=M("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=Nt.apply(null,arguments);return this.isValid()&&t.isValid()?t<this?this:t:p()}),Ln=M("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=Nt.apply(null,arguments);return this.isValid()&&t.isValid()?t>this?this:t:p()}),Wn=["year","quarter","month","week","day","hour","minute","second","millisecond"];jt("Z",":"),jt("ZZ",""),E("Z",Xe),E("ZZ",Xe),G(["Z","ZZ"],function(t,e,n){n._useUTC=!0,n._tzm=Ut(Xe,t)});var Yn=/([\+\-]|\d\d)/gi;n.updateOffset=function(){};var Nn=/^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,zn=/^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;Xt.fn=Vt.prototype,Xt.invalid=function(){return Xt(NaN)};var Bn=$t(1,"add"),Vn=$t(-1,"subtract");n.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",n.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var Hn=M("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(t){return void 0===t?this.localeData():this.locale(t)});N(0,["gg",2],0,function(){return this.weekYear()%100}),N(0,["GG",2],0,function(){return this.isoWeekYear()%100}),ae("gggg","weekYear"),ae("ggggg","weekYear"),ae("GGGG","isoWeekYear"),ae("GGGGG","isoWeekYear"),T("weekYear","gg"),T("isoWeekYear","GG"),O("weekYear",1),O("isoWeekYear",1),E("G",Ge),E("g",Ge),E("GG",Be,We),E("gg",Be,We),E("GGGG",je,Ne),E("gggg",je,Ne),E("GGGGG",Ue,ze),E("ggggg",Ue,ze),Z(["gggg","ggggg","GGGG","GGGGG"],function(t,e,n,i){e[i.substr(0,2)]=_(t)}),Z(["gg","GG"],function(t,e,i,a){e[a]=n.parseTwoDigitYear(t)}),N("Q",0,"Qo","quarter"),T("quarter","Q"),O("quarter",7),E("Q",Le),G("Q",function(t,e){e[tn]=3*(_(t)-1)}),N("D",["DD",2],"Do","date"),T("date","D"),O("date",9),E("D",Be),E("DD",Be,We),E("Do",function(t,e){return t?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient}),G(["D","DD"],en),G("Do",function(t,e){e[en]=_(t.match(Be)[0],10)});var En=R("Date",!0);N("DDD",["DDDD",3],"DDDo","dayOfYear"),T("dayOfYear","DDD"),O("dayOfYear",4),E("DDD",Ee),E("DDDD",Ye),G(["DDD","DDDD"],function(t,e,n){n._dayOfYear=_(t)}),N("m",["mm",2],0,"minute"),T("minute","m"),O("minute",14),E("m",Be),E("mm",Be,We),G(["m","mm"],an);var jn=R("Minutes",!1);N("s",["ss",2],0,"second"),T("second","s"),O("second",15),E("s",Be),E("ss",Be,We),G(["s","ss"],rn);var Un=R("Seconds",!1);N("S",0,0,function(){return~~(this.millisecond()/100)}),N(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),N(0,["SSS",3],0,"millisecond"),N(0,["SSSS",4],0,function(){return 10*this.millisecond()}),N(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),N(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),N(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),N(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),N(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),T("millisecond","ms"),O("millisecond",16),E("S",Ee,Le),E("SS",Ee,We),E("SSS",Ee,Ye);var qn;for(qn="SSSS";qn.length<=9;qn+="S")E(qn,qe);for(qn="S";qn.length<=9;qn+="S")G(qn,function(t,e){e[on]=_(1e3*("0."+t))});var Gn=R("Milliseconds",!1);N("z",0,0,"zoneAbbr"),N("zz",0,0,"zoneName");var Zn=y.prototype;Zn.add=Bn,Zn.calendar=function(t,e){var i=t||Nt(),a=qt(i,this).startOf("day"),r=n.calendarFormat(this,a)||"sameElse",o=e&&(D(e[r])?e[r].call(this,i):e[r]);return this.format(o||this.localeData().calendar(r,this,Nt(i)))},Zn.clone=function(){return new y(this)},Zn.diff=function(t,e,n){var i,a,r,o;return this.isValid()&&(i=qt(t,this)).isValid()?(a=6e4*(i.utcOffset()-this.utcOffset()),"year"===(e=A(e))||"month"===e||"quarter"===e?(o=ee(this,i),"quarter"===e?o/=3:"year"===e&&(o/=12)):(r=this-i,o="second"===e?r/1e3:"minute"===e?r/6e4:"hour"===e?r/36e5:"day"===e?(r-a)/864e5:"week"===e?(r-a)/6048e5:r),n?o:x(o)):NaN},Zn.endOf=function(t){return void 0===(t=A(t))||"millisecond"===t?this:("date"===t&&(t="day"),this.startOf(t).add(1,"isoWeek"===t?"week":t).subtract(1,"ms"))},Zn.format=function(t){t||(t=this.isUtc()?n.defaultFormatUtc:n.defaultFormat);var e=V(this,t);return this.localeData().postformat(e)},Zn.from=function(t,e){return this.isValid()&&(b(t)&&t.isValid()||Nt(t).isValid())?Xt({to:this,from:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()},Zn.fromNow=function(t){return this.from(Nt(),t)},Zn.to=function(t,e){return this.isValid()&&(b(t)&&t.isValid()||Nt(t).isValid())?Xt({from:this,to:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()},Zn.toNow=function(t){return this.to(Nt(),t)},Zn.get=function(t){return t=A(t),D(this[t])?this[t]():this},Zn.invalidAt=function(){return g(this).overflow},Zn.isAfter=function(t,e){var n=b(t)?t:Nt(t);return!(!this.isValid()||!n.isValid())&&("millisecond"===(e=A(o(e)?"millisecond":e))?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(e).valueOf())},Zn.isBefore=function(t,e){var n=b(t)?t:Nt(t);return!(!this.isValid()||!n.isValid())&&("millisecond"===(e=A(o(e)?"millisecond":e))?this.valueOf()<n.valueOf():this.clone().endOf(e).valueOf()<n.valueOf())},Zn.isBetween=function(t,e,n,i){return("("===(i=i||"()")[0]?this.isAfter(t,n):!this.isBefore(t,n))&&(")"===i[1]?this.isBefore(e,n):!this.isAfter(e,n))},Zn.isSame=function(t,e){var n,i=b(t)?t:Nt(t);return!(!this.isValid()||!i.isValid())&&("millisecond"===(e=A(e||"millisecond"))?this.valueOf()===i.valueOf():(n=i.valueOf(),this.clone().startOf(e).valueOf()<=n&&n<=this.clone().endOf(e).valueOf()))},Zn.isSameOrAfter=function(t,e){return this.isSame(t,e)||this.isAfter(t,e)},Zn.isSameOrBefore=function(t,e){return this.isSame(t,e)||this.isBefore(t,e)},Zn.isValid=function(){return m(this)},Zn.lang=Hn,Zn.locale=ne,Zn.localeData=ie,Zn.max=Ln,Zn.min=Rn,Zn.parsingFlags=function(){return c({},g(this))},Zn.set=function(t,e){if("object"==typeof t)for(var n=F(t=I(t)),i=0;i<n.length;i++)this[n[i].unit](t[n[i].unit]);else if(t=A(t),D(this[t]))return this[t](e);return this},Zn.startOf=function(t){switch(t=A(t)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":case"date":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===t&&this.weekday(0),"isoWeek"===t&&this.isoWeekday(1),"quarter"===t&&this.month(3*Math.floor(this.month()/3)),this},Zn.subtract=Vn,Zn.toArray=function(){var t=this;return[t.year(),t.month(),t.date(),t.hour(),t.minute(),t.second(),t.millisecond()]},Zn.toObject=function(){var t=this;return{years:t.year(),months:t.month(),date:t.date(),hours:t.hours(),minutes:t.minutes(),seconds:t.seconds(),milliseconds:t.milliseconds()}},Zn.toDate=function(){return new Date(this.valueOf())},Zn.toISOString=function(){if(!this.isValid())return null;var t=this.clone().utc();return t.year()<0||t.year()>9999?V(t,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):D(Date.prototype.toISOString)?this.toDate().toISOString():V(t,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},Zn.inspect=function(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var t="moment",e="";this.isLocal()||(t=0===this.utcOffset()?"moment.utc":"moment.parseZone",e="Z");var n="["+t+'("]',i=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",a=e+'[")]';return this.format(n+i+"-MM-DD[T]HH:mm:ss.SSS"+a)},Zn.toJSON=function(){return this.isValid()?this.toISOString():null},Zn.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},Zn.unix=function(){return Math.floor(this.valueOf()/1e3)},Zn.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},Zn.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},Zn.year=mn,Zn.isLeapYear=function(){return nt(this.year())},Zn.weekYear=function(t){return re.call(this,t,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)},Zn.isoWeekYear=function(t){return re.call(this,t,this.isoWeek(),this.isoWeekday(),1,4)},Zn.quarter=Zn.quarters=function(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)},Zn.month=$,Zn.daysInMonth=function(){return J(this.year(),this.month())},Zn.week=Zn.weeks=function(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")},Zn.isoWeek=Zn.isoWeeks=function(t){var e=st(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")},Zn.weeksInYear=function(){var t=this.localeData()._week;return lt(this.year(),t.dow,t.doy)},Zn.isoWeeksInYear=function(){return lt(this.year(),1,4)},Zn.date=En,Zn.day=Zn.days=function(t){if(!this.isValid())return null!=t?this:NaN;var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=ut(t,this.localeData()),this.add(t-e,"d")):e},Zn.weekday=function(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")},Zn.isoWeekday=function(t){if(!this.isValid())return null!=t?this:NaN;if(null!=t){var e=dt(t,this.localeData());return this.day(this.day()%7?e:e-7)}return this.day()||7},Zn.dayOfYear=function(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")},Zn.hour=Zn.hours=wn,Zn.minute=Zn.minutes=jn,Zn.second=Zn.seconds=Un,Zn.millisecond=Zn.milliseconds=Gn,Zn.utcOffset=function(t,e,i){var a,r=this._offset||0;if(!this.isValid())return null!=t?this:NaN;if(null!=t){if("string"==typeof t){if(null===(t=Ut(Xe,t)))return this}else Math.abs(t)<16&&!i&&(t*=60);return!this._isUTC&&e&&(a=Gt(this)),this._offset=t,this._isUTC=!0,null!=a&&this.add(a,"m"),r!==t&&(!e||this._changeInProgress?te(this,Xt(t-r,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,n.updateOffset(this,!0),this._changeInProgress=null)),this}return this._isUTC?r:Gt(this)},Zn.utc=function(t){return this.utcOffset(0,t)},Zn.local=function(t){return this._isUTC&&(this.utcOffset(0,t),this._isUTC=!1,t&&this.subtract(Gt(this),"m")),this},Zn.parseZone=function(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if("string"==typeof this._i){var t=Ut(Ze,this._i);null!=t?this.utcOffset(t):this.utcOffset(0,!0)}return this},Zn.hasAlignedHourOffset=function(t){return!!this.isValid()&&(t=t?Nt(t).utcOffset():0,(this.utcOffset()-t)%60==0)},Zn.isDST=function(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},Zn.isLocal=function(){return!!this.isValid()&&!this._isUTC},Zn.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},Zn.isUtc=Zt,Zn.isUTC=Zt,Zn.zoneAbbr=function(){return this._isUTC?"UTC":""},Zn.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},Zn.dates=M("dates accessor is deprecated. Use date instead.",En),Zn.months=M("months accessor is deprecated. Use month instead",$),Zn.years=M("years accessor is deprecated. Use year instead",mn),Zn.zone=M("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(t,e){return null!=t?("string"!=typeof t&&(t=-t),this.utcOffset(t,e),this):-this.utcOffset()}),Zn.isDSTShifted=M("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!o(this._isDSTShifted))return this._isDSTShifted;var t={};if(v(t,this),(t=Lt(t))._a){var e=t._isUTC?h(t._a):Nt(t._a);this._isDSTShifted=this.isValid()&&k(t._a,e.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted});var Xn=P.prototype;Xn.calendar=function(t,e,n){var i=this._calendar[t]||this._calendar.sameElse;return D(i)?i.call(e,n):i},Xn.longDateFormat=function(t){var e=this._longDateFormat[t],n=this._longDateFormat[t.toUpperCase()];return e||!n?e:(this._longDateFormat[t]=n.replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t])},Xn.invalidDate=function(){return this._invalidDate},Xn.ordinal=function(t){return this._ordinal.replace("%d",t)},Xn.preparse=se,Xn.postformat=se,Xn.relativeTime=function(t,e,n,i){var a=this._relativeTime[n];return D(a)?a(t,e,n,i):a.replace(/%d/i,t)},Xn.pastFuture=function(t,e){var n=this._relativeTime[t>0?"future":"past"];return D(n)?n(e):n.replace(/%s/i,e)},Xn.set=function(t){var e,n;for(n in t)D(e=t[n])?this[n]=e:this["_"+n]=e;this._config=t,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)},Xn.months=function(t,e){return t?i(this._months)?this._months[t.month()]:this._months[(this._months.isFormat||dn).test(e)?"format":"standalone"][t.month()]:i(this._months)?this._months:this._months.standalone},Xn.monthsShort=function(t,e){return t?i(this._monthsShort)?this._monthsShort[t.month()]:this._monthsShort[dn.test(e)?"format":"standalone"][t.month()]:i(this._monthsShort)?this._monthsShort:this._monthsShort.standalone},Xn.monthsParse=function(t,e,n){var i,a,r;if(this._monthsParseExact)return K.call(this,t,e,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),i=0;i<12;i++){if(a=h([2e3,i]),n&&!this._longMonthsParse[i]&&(this._longMonthsParse[i]=new RegExp("^"+this.months(a,"").replace(".","")+"$","i"),this._shortMonthsParse[i]=new RegExp("^"+this.monthsShort(a,"").replace(".","")+"$","i")),n||this._monthsParse[i]||(r="^"+this.months(a,"")+"|^"+this.monthsShort(a,""),this._monthsParse[i]=new RegExp(r.replace(".",""),"i")),n&&"MMMM"===e&&this._longMonthsParse[i].test(t))return i;if(n&&"MMM"===e&&this._shortMonthsParse[i].test(t))return i;if(!n&&this._monthsParse[i].test(t))return i}},Xn.monthsRegex=function(t){return this._monthsParseExact?(d(this,"_monthsRegex")||tt.call(this),t?this._monthsStrictRegex:this._monthsRegex):(d(this,"_monthsRegex")||(this._monthsRegex=gn),this._monthsStrictRegex&&t?this._monthsStrictRegex:this._monthsRegex)},Xn.monthsShortRegex=function(t){return this._monthsParseExact?(d(this,"_monthsRegex")||tt.call(this),t?this._monthsShortStrictRegex:this._monthsShortRegex):(d(this,"_monthsShortRegex")||(this._monthsShortRegex=fn),this._monthsShortStrictRegex&&t?this._monthsShortStrictRegex:this._monthsShortRegex)},Xn.week=function(t){return st(t,this._week.dow,this._week.doy).week},Xn.firstDayOfYear=function(){return this._week.doy},Xn.firstDayOfWeek=function(){return this._week.dow},Xn.weekdays=function(t,e){return t?i(this._weekdays)?this._weekdays[t.day()]:this._weekdays[this._weekdays.isFormat.test(e)?"format":"standalone"][t.day()]:i(this._weekdays)?this._weekdays:this._weekdays.standalone},Xn.weekdaysMin=function(t){return t?this._weekdaysMin[t.day()]:this._weekdaysMin},Xn.weekdaysShort=function(t){return t?this._weekdaysShort[t.day()]:this._weekdaysShort},Xn.weekdaysParse=function(t,e,n){var i,a,r;if(this._weekdaysParseExact)return ct.call(this,t,e,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),i=0;i<7;i++){if(a=h([2e3,1]).day(i),n&&!this._fullWeekdaysParse[i]&&(this._fullWeekdaysParse[i]=new RegExp("^"+this.weekdays(a,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[i]=new RegExp("^"+this.weekdaysShort(a,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[i]=new RegExp("^"+this.weekdaysMin(a,"").replace(".",".?")+"$","i")),this._weekdaysParse[i]||(r="^"+this.weekdays(a,"")+"|^"+this.weekdaysShort(a,"")+"|^"+this.weekdaysMin(a,""),this._weekdaysParse[i]=new RegExp(r.replace(".",""),"i")),n&&"dddd"===e&&this._fullWeekdaysParse[i].test(t))return i;if(n&&"ddd"===e&&this._shortWeekdaysParse[i].test(t))return i;if(n&&"dd"===e&&this._minWeekdaysParse[i].test(t))return i;if(!n&&this._weekdaysParse[i].test(t))return i}},Xn.weekdaysRegex=function(t){return this._weekdaysParseExact?(d(this,"_weekdaysRegex")||ht.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(d(this,"_weekdaysRegex")||(this._weekdaysRegex=bn),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)},Xn.weekdaysShortRegex=function(t){return this._weekdaysParseExact?(d(this,"_weekdaysRegex")||ht.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(d(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=xn),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)},Xn.weekdaysMinRegex=function(t){return this._weekdaysParseExact?(d(this,"_weekdaysRegex")||ht.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(d(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=_n),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)},Xn.isPM=function(t){return"p"===(t+"").toLowerCase().charAt(0)},Xn.meridiem=function(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"},bt("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10;return t+(1===_(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th")}}),n.lang=M("moment.lang is deprecated. Use moment.locale instead.",bt),n.langData=M("moment.langData is deprecated. Use moment.localeData instead.",_t);var Jn=Math.abs,Kn=me("ms"),Qn=me("s"),$n=me("m"),ti=me("h"),ei=me("d"),ni=me("w"),ii=me("M"),ai=me("y"),ri=pe("milliseconds"),oi=pe("seconds"),si=pe("minutes"),li=pe("hours"),ui=pe("days"),di=pe("months"),ci=pe("years"),hi=Math.round,fi={ss:44,s:45,m:45,h:22,d:26,M:11},gi=Math.abs,mi=Vt.prototype;return mi.isValid=function(){return this._isValid},mi.abs=function(){var t=this._data;return this._milliseconds=Jn(this._milliseconds),this._days=Jn(this._days),this._months=Jn(this._months),t.milliseconds=Jn(t.milliseconds),t.seconds=Jn(t.seconds),t.minutes=Jn(t.minutes),t.hours=Jn(t.hours),t.months=Jn(t.months),t.years=Jn(t.years),this},mi.add=function(t,e){return ce(this,t,e,1)},mi.subtract=function(t,e){return ce(this,t,e,-1)},mi.as=function(t){if(!this.isValid())return NaN;var e,n,i=this._milliseconds;if("month"===(t=A(t))||"year"===t)return e=this._days+i/864e5,n=this._months+fe(e),"month"===t?n:n/12;switch(e=this._days+Math.round(ge(this._months)),t){case"week":return e/7+i/6048e5;case"day":return e+i/864e5;case"hour":return 24*e+i/36e5;case"minute":return 1440*e+i/6e4;case"second":return 86400*e+i/1e3;case"millisecond":return Math.floor(864e5*e)+i;default:throw new Error("Unknown unit "+t)}},mi.asMilliseconds=Kn,mi.asSeconds=Qn,mi.asMinutes=$n,mi.asHours=ti,mi.asDays=ei,mi.asWeeks=ni,mi.asMonths=ii,mi.asYears=ai,mi.valueOf=function(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*_(this._months/12):NaN},mi._bubble=function(){var t,e,n,i,a,r=this._milliseconds,o=this._days,s=this._months,l=this._data;return r>=0&&o>=0&&s>=0||r<=0&&o<=0&&s<=0||(r+=864e5*he(ge(s)+o),o=0,s=0),l.milliseconds=r%1e3,t=x(r/1e3),l.seconds=t%60,e=x(t/60),l.minutes=e%60,n=x(e/60),l.hours=n%24,o+=x(n/24),a=x(fe(o)),s+=a,o-=he(ge(a)),i=x(s/12),s%=12,l.days=o,l.months=s,l.years=i,this},mi.get=function(t){return t=A(t),this.isValid()?this[t+"s"]():NaN},mi.milliseconds=ri,mi.seconds=oi,mi.minutes=si,mi.hours=li,mi.days=ui,mi.weeks=function(){return x(this.days()/7)},mi.months=di,mi.years=ci,mi.humanize=function(t){if(!this.isValid())return this.localeData().invalidDate();var e=this.localeData(),n=ye(this,!t,e);return t&&(n=e.pastFuture(+this,n)),e.postformat(n)},mi.toISOString=be,mi.toString=be,mi.toJSON=be,mi.locale=ne,mi.localeData=ie,mi.toIsoString=M("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",be),mi.lang=Hn,N("X",0,0,"unix"),N("x",0,0,"valueOf"),E("x",Ge),E("X",/[+-]?\d+(\.\d{1,3})?/),G("X",function(t,e,n){n._d=new Date(1e3*parseFloat(t,10))}),G("x",function(t,e,n){n._d=new Date(_(t))}),n.version="2.18.1",function(t){xe=t}(Nt),n.fn=Zn,n.min=function(){return zt("isBefore",[].slice.call(arguments,0))},n.max=function(){return zt("isAfter",[].slice.call(arguments,0))},n.now=function(){return Date.now?Date.now():+new Date},n.utc=h,n.unix=function(t){return Nt(1e3*t)},n.months=function(t,e){return ue(t,e,"months")},n.isDate=l,n.locale=bt,n.invalid=p,n.duration=Xt,n.isMoment=b,n.weekdays=function(t,e,n){return de(t,e,n,"weekdays")},n.parseZone=function(){return Nt.apply(null,arguments).parseZone()},n.localeData=_t,n.isDuration=Ht,n.monthsShort=function(t,e){return ue(t,e,"monthsShort")},n.weekdaysMin=function(t,e,n){return de(t,e,n,"weekdaysMin")},n.defineLocale=xt,n.updateLocale=function(t,e){if(null!=e){var n,i=Mn;null!=Sn[t]&&(i=Sn[t]._config),(n=new P(e=C(i,e))).parentLocale=Sn[t],Sn[t]=n,bt(t)}else null!=Sn[t]&&(null!=Sn[t].parentLocale?Sn[t]=Sn[t].parentLocale:null!=Sn[t]&&delete Sn[t]);return Sn[t]},n.locales=function(){return Pe(Sn)},n.weekdaysShort=function(t,e,n){return de(t,e,n,"weekdaysShort")},n.normalizeUnits=A,n.relativeTimeRounding=function(t){return void 0===t?hi:"function"==typeof t&&(hi=t,!0)},n.relativeTimeThreshold=function(t,e){return void 0!==fi[t]&&(void 0===e?fi[t]:(fi[t]=e,"s"===t&&(fi.ss=e-1),!0))},n.calendarFormat=function(t,e){var n=t.diff(e,"days",!0);return n<-6?"sameElse":n<-1?"lastWeek":n<0?"lastDay":n<1?"sameDay":n<2?"nextDay":n<7?"nextWeek":"sameElse"},n.prototype=Zn,n})},{}],7:[function(t,e,n){var i=t(29)();i.helpers=t(45),t(27)(i),i.defaults=t(25),i.Element=t(26),i.elements=t(40),i.Interaction=t(28),i.platform=t(48),t(31)(i),t(22)(i),t(23)(i),t(24)(i),t(30)(i),t(33)(i),t(32)(i),t(35)(i),t(54)(i),t(52)(i),t(53)(i),t(55)(i),t(56)(i),t(57)(i),t(15)(i),t(16)(i),t(17)(i),t(18)(i),t(19)(i),t(20)(i),t(21)(i),t(8)(i),t(9)(i),t(10)(i),t(11)(i),t(12)(i),t(13)(i),t(14)(i);var a=[];a.push(t(49)(i),t(50)(i),t(51)(i)),i.plugins.register(a),i.platform.initialize(),e.exports=i,"undefined"!=typeof window&&(window.Chart=i),i.canvasHelpers=i.helpers.canvas},{10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,29:29,30:30,31:31,32:32,33:33,35:35,40:40,45:45,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,8:8,9:9}],8:[function(t,e,n){"use strict";e.exports=function(t){t.Bar=function(e,n){return n.type="bar",new t(e,n)}}},{}],9:[function(t,e,n){"use strict";e.exports=function(t){t.Bubble=function(e,n){return n.type="bubble",new t(e,n)}}},{}],10:[function(t,e,n){"use strict";e.exports=function(t){t.Doughnut=function(e,n){return n.type="doughnut",new t(e,n)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t){t.Line=function(e,n){return n.type="line",new t(e,n)}}},{}],12:[function(t,e,n){"use strict";e.exports=function(t){t.PolarArea=function(e,n){return n.type="polarArea",new t(e,n)}}},{}],13:[function(t,e,n){"use strict";e.exports=function(t){t.Radar=function(e,n){return n.type="radar",new t(e,n)}}},{}],14:[function(t,e,n){"use strict";e.exports=function(t){t.Scatter=function(e,n){return n.type="scatter",new t(e,n)}}},{}],15:[function(t,e,n){"use strict";var i=t(25),a=t(40),r=t(45);i._set("bar",{hover:{mode:"label"},scales:{xAxes:[{type:"category",categoryPercentage:.8,barPercentage:.9,offset:!0,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}}),i._set("horizontalBar",{hover:{mode:"index",axis:"y"},scales:{xAxes:[{type:"linear",position:"bottom"}],yAxes:[{position:"left",type:"category",categoryPercentage:.8,barPercentage:.9,offset:!0,gridLines:{offsetGridLines:!0}}]},elements:{rectangle:{borderSkipped:"left"}},tooltips:{callbacks:{title:function(t,e){var n="";return t.length>0&&(t[0].yLabel?n=t[0].yLabel:e.labels.length>0&&t[0].index<e.labels.length&&(n=e.labels[t[0].index])),n},label:function(t,e){return(e.datasets[t.datasetIndex].label||"")+": "+t.xLabel}},mode:"index",axis:"y"}}),e.exports=function(t){t.controllers.bar=t.DatasetController.extend({dataElementType:a.Rectangle,initialize:function(){var e,n=this;t.DatasetController.prototype.initialize.apply(n,arguments),(e=n.getMeta()).stack=n.getDataset().stack,e.bar=!0},update:function(t){var e,n,i=this,a=i.getMeta().data;for(i._ruler=i.getRuler(),e=0,n=a.length;e<n;++e)i.updateElement(a[e],e,t)},updateElement:function(t,e,n){var i=this,a=i.chart,o=i.getMeta(),s=i.getDataset(),l=t.custom||{},u=a.options.elements.rectangle;t._xScale=i.getScaleForId(o.xAxisID),t._yScale=i.getScaleForId(o.yAxisID),t._datasetIndex=i.index,t._index=e,t._model={datasetLabel:s.label,label:a.data.labels[e],borderSkipped:l.borderSkipped?l.borderSkipped:u.borderSkipped,backgroundColor:l.backgroundColor?l.backgroundColor:r.valueAtIndexOrDefault(s.backgroundColor,e,u.backgroundColor),borderColor:l.borderColor?l.borderColor:r.valueAtIndexOrDefault(s.borderColor,e,u.borderColor),borderWidth:l.borderWidth?l.borderWidth:r.valueAtIndexOrDefault(s.borderWidth,e,u.borderWidth)},i.updateElementGeometry(t,e,n),t.pivot()},updateElementGeometry:function(t,e,n){var i=this,a=t._model,r=i.getValueScale(),o=r.getBasePixel(),s=r.isHorizontal(),l=i._ruler||i.getRuler(),u=i.calculateBarValuePixels(i.index,e),d=i.calculateBarIndexPixels(i.index,e,l);a.horizontal=s,a.base=n?o:u.base,a.x=s?n?o:u.head:d.center,a.y=s?d.center:n?o:u.head,a.height=s?d.size:void 0,a.width=s?void 0:d.size},getValueScaleId:function(){return this.getMeta().yAxisID},getIndexScaleId:function(){return this.getMeta().xAxisID},getValueScale:function(){return this.getScaleForId(this.getValueScaleId())},getIndexScale:function(){return this.getScaleForId(this.getIndexScaleId())},getStackCount:function(t){var e,n,i=this,a=i.chart,r=i.getIndexScale().options.stacked,o=void 0===t?a.data.datasets.length:t+1,s=[];for(e=0;e<o;++e)(n=a.getDatasetMeta(e)).bar&&a.isDatasetVisible(e)&&(!1===r||!0===r&&-1===s.indexOf(n.stack)||void 0===r&&(void 0===n.stack||-1===s.indexOf(n.stack)))&&s.push(n.stack);return s.length},getStackIndex:function(t){return this.getStackCount(t)-1},getRuler:function(){var t,e,n=this,i=n.getIndexScale(),a=n.getStackCount(),r=n.index,o=[],s=i.isHorizontal(),l=s?i.left:i.top,u=l+(s?i.width:i.height);for(t=0,e=n.getMeta().data.length;t<e;++t)o.push(i.getPixelForValue(null,t,r));return{pixels:o,start:l,end:u,stackCount:a,scale:i}},calculateBarValuePixels:function(t,e){var n,i,a,r,o,s,l=this,u=l.chart,d=l.getMeta(),c=l.getValueScale(),h=u.data.datasets,f=c.getRightValue(h[t].data[e]),g=c.options.stacked,m=d.stack,p=0;if(g||void 0===g&&void 0!==m)for(n=0;n<t;++n)(i=u.getDatasetMeta(n)).bar&&i.stack===m&&i.controller.getValueScaleId()===c.id&&u.isDatasetVisible(n)&&(a=c.getRightValue(h[n].data[e]),(f<0&&a<0||f>=0&&a>0)&&(p+=a));return r=c.getPixelForValue(p),o=c.getPixelForValue(p+f),s=(o-r)/2,{size:s,base:r,head:o,center:o+s/2}},calculateBarIndexPixels:function(t,e,n){var i,a,o,s,l,u,d=this,c=n.scale.options,h=d.getStackIndex(t),f=n.pixels,g=f[e],m=f.length,p=n.start,v=n.end;return 1===m?(i=g>p?g-p:v-g,a=g<v?v-g:g-p):(e>0&&(i=(g-f[e-1])/2,e===m-1&&(a=i)),e<m-1&&(a=(f[e+1]-g)/2,0===e&&(i=a))),o=i*c.categoryPercentage,s=a*c.categoryPercentage,l=(o+s)/n.stackCount,u=l*c.barPercentage,u=Math.min(r.valueOrDefault(c.barThickness,u),r.valueOrDefault(c.maxBarThickness,1/0)),g-=o,g+=l*h,g+=(l-u)/2,{size:u,base:g,head:g+u,center:g+u/2}},draw:function(){var t=this,e=t.chart,n=t.getValueScale(),i=t.getMeta().data,a=t.getDataset(),o=i.length,s=0;for(r.canvas.clipArea(e.ctx,e.chartArea);s<o;++s)isNaN(n.getRightValue(a.data[s]))||i[s].draw();r.canvas.unclipArea(e.ctx)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,i=t.custom||{},a=t._model;a.backgroundColor=i.hoverBackgroundColor?i.hoverBackgroundColor:r.valueAtIndexOrDefault(e.hoverBackgroundColor,n,r.getHoverColor(a.backgroundColor)),a.borderColor=i.hoverBorderColor?i.hoverBorderColor:r.valueAtIndexOrDefault(e.hoverBorderColor,n,r.getHoverColor(a.borderColor)),a.borderWidth=i.hoverBorderWidth?i.hoverBorderWidth:r.valueAtIndexOrDefault(e.hoverBorderWidth,n,a.borderWidth)},removeHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,i=t.custom||{},a=t._model,o=this.chart.options.elements.rectangle;a.backgroundColor=i.backgroundColor?i.backgroundColor:r.valueAtIndexOrDefault(e.backgroundColor,n,o.backgroundColor),a.borderColor=i.borderColor?i.borderColor:r.valueAtIndexOrDefault(e.borderColor,n,o.borderColor),a.borderWidth=i.borderWidth?i.borderWidth:r.valueAtIndexOrDefault(e.borderWidth,n,o.borderWidth)}}),t.controllers.horizontalBar=t.controllers.bar.extend({getValueScaleId:function(){return this.getMeta().xAxisID},getIndexScaleId:function(){return this.getMeta().yAxisID}})}},{25:25,40:40,45:45}],16:[function(t,e,n){"use strict";var i=t(25),a=t(40),r=t(45);i._set("bubble",{hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-0"}],yAxes:[{type:"linear",position:"left",id:"y-axis-0"}]},tooltips:{callbacks:{title:function(){return""},label:function(t,e){var n=e.datasets[t.datasetIndex].label||"",i=e.datasets[t.datasetIndex].data[t.index];return n+": ("+t.xLabel+", "+t.yLabel+", "+i.r+")"}}}}),e.exports=function(t){t.controllers.bubble=t.DatasetController.extend({dataElementType:a.Point,update:function(t){var e=this,n=e.getMeta().data;r.each(n,function(n,i){e.updateElement(n,i,t)})},updateElement:function(t,e,n){var i=this,a=i.getMeta(),r=t.custom||{},o=i.getScaleForId(a.xAxisID),s=i.getScaleForId(a.yAxisID),l=i._resolveElementOptions(t,e),u=i.getDataset().data[e],d=i.index,c=n?o.getPixelForDecimal(.5):o.getPixelForValue("object"==typeof u?u:NaN,e,d),h=n?s.getBasePixel():s.getPixelForValue(u,e,d);t._xScale=o,t._yScale=s,t._options=l,t._datasetIndex=d,t._index=e,t._model={backgroundColor:l.backgroundColor,borderColor:l.borderColor,borderWidth:l.borderWidth,hitRadius:l.hitRadius,pointStyle:l.pointStyle,radius:n?0:l.radius,skip:r.skip||isNaN(c)||isNaN(h),x:c,y:h},t.pivot()},setHoverStyle:function(t){var e=t._model,n=t._options;e.backgroundColor=r.valueOrDefault(n.hoverBackgroundColor,r.getHoverColor(n.backgroundColor)),e.borderColor=r.valueOrDefault(n.hoverBorderColor,r.getHoverColor(n.borderColor)),e.borderWidth=r.valueOrDefault(n.hoverBorderWidth,n.borderWidth),e.radius=n.radius+n.hoverRadius},removeHoverStyle:function(t){var e=t._model,n=t._options;e.backgroundColor=n.backgroundColor,e.borderColor=n.borderColor,e.borderWidth=n.borderWidth,e.radius=n.radius},_resolveElementOptions:function(t,e){var n,i,a,o=this,s=o.chart,l=s.data.datasets[o.index],u=t.custom||{},d=s.options.elements.point,c=r.options.resolve,h=l.data[e],f={},g={chart:s,dataIndex:e,dataset:l,datasetIndex:o.index},m=["backgroundColor","borderColor","borderWidth","hoverBackgroundColor","hoverBorderColor","hoverBorderWidth","hoverRadius","hitRadius","pointStyle"];for(n=0,i=m.length;n<i;++n)f[a=m[n]]=c([u[a],l[a],d[a]],g,e);return f.radius=c([u.radius,h?h.r:void 0,l.radius,d.radius],g,e),f}})}},{25:25,40:40,45:45}],17:[function(t,e,n){"use strict";var i=t(25),a=t(40),r=t(45);i._set("doughnut",{animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var n=t.data,i=n.datasets,a=n.labels;if(i.length)for(var r=0;r<i[0].data.length;++r)e.push('<li><span style="background-color:'+i[0].backgroundColor[r]+'"></span>'),a[r]&&e.push(a[r]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var e=t.data;return e.labels.length&&e.datasets.length?e.labels.map(function(n,i){var a=t.getDatasetMeta(0),o=e.datasets[0],s=a.data[i],l=s&&s.custom||{},u=r.valueAtIndexOrDefault,d=t.options.elements.arc;return{text:n,fillStyle:l.backgroundColor?l.backgroundColor:u(o.backgroundColor,i,d.backgroundColor),strokeStyle:l.borderColor?l.borderColor:u(o.borderColor,i,d.borderColor),lineWidth:l.borderWidth?l.borderWidth:u(o.borderWidth,i,d.borderWidth),hidden:isNaN(o.data[i])||a.data[i].hidden,index:i}}):[]}},onClick:function(t,e){var n,i,a,r=e.index,o=this.chart;for(n=0,i=(o.data.datasets||[]).length;n<i;++n)(a=o.getDatasetMeta(n)).data[r]&&(a.data[r].hidden=!a.data[r].hidden);o.update()}},cutoutPercentage:50,rotation:-.5*Math.PI,circumference:2*Math.PI,tooltips:{callbacks:{title:function(){return""},label:function(t,e){var n=e.labels[t.index],i=": "+e.datasets[t.datasetIndex].data[t.index];return r.isArray(n)?(n=n.slice())[0]+=i:n+=i,n}}}}),i._set("pie",r.clone(i.doughnut)),i._set("pie",{cutoutPercentage:0}),e.exports=function(t){t.controllers.doughnut=t.controllers.pie=t.DatasetController.extend({dataElementType:a.Arc,linkScales:r.noop,getRingIndex:function(t){for(var e=0,n=0;n<t;++n)this.chart.isDatasetVisible(n)&&++e;return e},update:function(t){var e=this,n=e.chart,i=n.chartArea,a=n.options,o=a.elements.arc,s=i.right-i.left-o.borderWidth,l=i.bottom-i.top-o.borderWidth,u=Math.min(s,l),d={x:0,y:0},c=e.getMeta(),h=a.cutoutPercentage,f=a.circumference;if(f<2*Math.PI){var g=a.rotation%(2*Math.PI),m=(g+=2*Math.PI*(g>=Math.PI?-1:g<-Math.PI?1:0))+f,p={x:Math.cos(g),y:Math.sin(g)},v={x:Math.cos(m),y:Math.sin(m)},y=g<=0&&m>=0||g<=2*Math.PI&&2*Math.PI<=m,b=g<=.5*Math.PI&&.5*Math.PI<=m||g<=2.5*Math.PI&&2.5*Math.PI<=m,x=g<=-Math.PI&&-Math.PI<=m||g<=Math.PI&&Math.PI<=m,_=g<=.5*-Math.PI&&.5*-Math.PI<=m||g<=1.5*Math.PI&&1.5*Math.PI<=m,k=h/100,w={x:x?-1:Math.min(p.x*(p.x<0?1:k),v.x*(v.x<0?1:k)),y:_?-1:Math.min(p.y*(p.y<0?1:k),v.y*(v.y<0?1:k))},M={x:y?1:Math.max(p.x*(p.x>0?1:k),v.x*(v.x>0?1:k)),y:b?1:Math.max(p.y*(p.y>0?1:k),v.y*(v.y>0?1:k))},S={width:.5*(M.x-w.x),height:.5*(M.y-w.y)};u=Math.min(s/S.width,l/S.height),d={x:-.5*(M.x+w.x),y:-.5*(M.y+w.y)}}n.borderWidth=e.getMaxBorderWidth(c.data),n.outerRadius=Math.max((u-n.borderWidth)/2,0),n.innerRadius=Math.max(h?n.outerRadius/100*h:0,0),n.radiusLength=(n.outerRadius-n.innerRadius)/n.getVisibleDatasetCount(),n.offsetX=d.x*n.outerRadius,n.offsetY=d.y*n.outerRadius,c.total=e.calculateTotal(),e.outerRadius=n.outerRadius-n.radiusLength*e.getRingIndex(e.index),e.innerRadius=Math.max(e.outerRadius-n.radiusLength,0),r.each(c.data,function(n,i){e.updateElement(n,i,t)})},updateElement:function(t,e,n){var i=this,a=i.chart,o=a.chartArea,s=a.options,l=s.animation,u=(o.left+o.right)/2,d=(o.top+o.bottom)/2,c=s.rotation,h=s.rotation,f=i.getDataset(),g=n&&l.animateRotate?0:t.hidden?0:i.calculateCircumference(f.data[e])*(s.circumference/(2*Math.PI)),m=n&&l.animateScale?0:i.innerRadius,p=n&&l.animateScale?0:i.outerRadius,v=r.valueAtIndexOrDefault;r.extend(t,{_datasetIndex:i.index,_index:e,_model:{x:u+a.offsetX,y:d+a.offsetY,startAngle:c,endAngle:h,circumference:g,outerRadius:p,innerRadius:m,label:v(f.label,e,a.data.labels[e])}});var y=t._model;this.removeHoverStyle(t),n&&l.animateRotate||(y.startAngle=0===e?s.rotation:i.getMeta().data[e-1]._model.endAngle,y.endAngle=y.startAngle+y.circumference),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},calculateTotal:function(){var t,e=this.getDataset(),n=this.getMeta(),i=0;return r.each(n.data,function(n,a){t=e.data[a],isNaN(t)||n.hidden||(i+=Math.abs(t))}),i},calculateCircumference:function(t){var e=this.getMeta().total;return e>0&&!isNaN(t)?2*Math.PI*(t/e):0},getMaxBorderWidth:function(t){for(var e,n,i=0,a=this.index,r=t.length,o=0;o<r;o++)e=t[o]._model?t[o]._model.borderWidth:0,i=(n=t[o]._chart?t[o]._chart.config.data.datasets[a].hoverBorderWidth:0)>(i=e>i?e:i)?n:i;return i}})}},{25:25,40:40,45:45}],18:[function(t,e,n){"use strict";var i=t(25),a=t(40),r=t(45);i._set("line",{showLines:!0,spanGaps:!1,hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}}),e.exports=function(t){function e(t,e){return r.valueOrDefault(t.showLine,e.showLines)}t.controllers.line=t.DatasetController.extend({datasetElementType:a.Line,dataElementType:a.Point,update:function(t){var n,i,a,o=this,s=o.getMeta(),l=s.dataset,u=s.data||[],d=o.chart.options,c=d.elements.line,h=o.getScaleForId(s.yAxisID),f=o.getDataset(),g=e(f,d);for(g&&(a=l.custom||{},void 0!==f.tension&&void 0===f.lineTension&&(f.lineTension=f.tension),l._scale=h,l._datasetIndex=o.index,l._children=u,l._model={spanGaps:f.spanGaps?f.spanGaps:d.spanGaps,tension:a.tension?a.tension:r.valueOrDefault(f.lineTension,c.tension),backgroundColor:a.backgroundColor?a.backgroundColor:f.backgroundColor||c.backgroundColor,borderWidth:a.borderWidth?a.borderWidth:f.borderWidth||c.borderWidth,borderColor:a.borderColor?a.borderColor:f.borderColor||c.borderColor,borderCapStyle:a.borderCapStyle?a.borderCapStyle:f.borderCapStyle||c.borderCapStyle,borderDash:a.borderDash?a.borderDash:f.borderDash||c.borderDash,borderDashOffset:a.borderDashOffset?a.borderDashOffset:f.borderDashOffset||c.borderDashOffset,borderJoinStyle:a.borderJoinStyle?a.borderJoinStyle:f.borderJoinStyle||c.borderJoinStyle,fill:a.fill?a.fill:void 0!==f.fill?f.fill:c.fill,steppedLine:a.steppedLine?a.steppedLine:r.valueOrDefault(f.steppedLine,c.stepped),cubicInterpolationMode:a.cubicInterpolationMode?a.cubicInterpolationMode:r.valueOrDefault(f.cubicInterpolationMode,c.cubicInterpolationMode)},l.pivot()),n=0,i=u.length;n<i;++n)o.updateElement(u[n],n,t);for(g&&0!==l._model.tension&&o.updateBezierControlPoints(),n=0,i=u.length;n<i;++n)u[n].pivot()},getPointBackgroundColor:function(t,e){var n=this.chart.options.elements.point.backgroundColor,i=this.getDataset(),a=t.custom||{};return a.backgroundColor?n=a.backgroundColor:i.pointBackgroundColor?n=r.valueAtIndexOrDefault(i.pointBackgroundColor,e,n):i.backgroundColor&&(n=i.backgroundColor),n},getPointBorderColor:function(t,e){var n=this.chart.options.elements.point.borderColor,i=this.getDataset(),a=t.custom||{};return a.borderColor?n=a.borderColor:i.pointBorderColor?n=r.valueAtIndexOrDefault(i.pointBorderColor,e,n):i.borderColor&&(n=i.borderColor),n},getPointBorderWidth:function(t,e){var n=this.chart.options.elements.point.borderWidth,i=this.getDataset(),a=t.custom||{};return isNaN(a.borderWidth)?!isNaN(i.pointBorderWidth)||r.isArray(i.pointBorderWidth)?n=r.valueAtIndexOrDefault(i.pointBorderWidth,e,n):isNaN(i.borderWidth)||(n=i.borderWidth):n=a.borderWidth,n},updateElement:function(t,e,n){var i,a,o=this,s=o.getMeta(),l=t.custom||{},u=o.getDataset(),d=o.index,c=u.data[e],h=o.getScaleForId(s.yAxisID),f=o.getScaleForId(s.xAxisID),g=o.chart.options.elements.point;void 0!==u.radius&&void 0===u.pointRadius&&(u.pointRadius=u.radius),void 0!==u.hitRadius&&void 0===u.pointHitRadius&&(u.pointHitRadius=u.hitRadius),i=f.getPixelForValue("object"==typeof c?c:NaN,e,d),a=n?h.getBasePixel():o.calculatePointY(c,e,d),t._xScale=f,t._yScale=h,t._datasetIndex=d,t._index=e,t._model={x:i,y:a,skip:l.skip||isNaN(i)||isNaN(a),radius:l.radius||r.valueAtIndexOrDefault(u.pointRadius,e,g.radius),pointStyle:l.pointStyle||r.valueAtIndexOrDefault(u.pointStyle,e,g.pointStyle),backgroundColor:o.getPointBackgroundColor(t,e),borderColor:o.getPointBorderColor(t,e),borderWidth:o.getPointBorderWidth(t,e),tension:s.dataset._model?s.dataset._model.tension:0,steppedLine:!!s.dataset._model&&s.dataset._model.steppedLine,hitRadius:l.hitRadius||r.valueAtIndexOrDefault(u.pointHitRadius,e,g.hitRadius)}},calculatePointY:function(t,e,n){var i,a,r,o=this,s=o.chart,l=o.getMeta(),u=o.getScaleForId(l.yAxisID),d=0,c=0;if(u.options.stacked){for(i=0;i<n;i++)if(a=s.data.datasets[i],"line"===(r=s.getDatasetMeta(i)).type&&r.yAxisID===u.id&&s.isDatasetVisible(i)){var h=Number(u.getRightValue(a.data[e]));h<0?c+=h||0:d+=h||0}var f=Number(u.getRightValue(t));return f<0?u.getPixelForValue(c+f):u.getPixelForValue(d+f)}return u.getPixelForValue(t)},updateBezierControlPoints:function(){function t(t,e,n){return Math.max(Math.min(t,n),e)}var e,n,i,a,o=this,s=o.getMeta(),l=o.chart.chartArea,u=s.data||[];if(s.dataset._model.spanGaps&&(u=u.filter(function(t){return!t._model.skip})),"monotone"===s.dataset._model.cubicInterpolationMode)r.splineCurveMonotone(u);else for(e=0,n=u.length;e<n;++e)i=u[e]._model,a=r.splineCurve(r.previousItem(u,e)._model,i,r.nextItem(u,e)._model,s.dataset._model.tension),i.controlPointPreviousX=a.previous.x,i.controlPointPreviousY=a.previous.y,i.controlPointNextX=a.next.x,i.controlPointNextY=a.next.y;if(o.chart.options.elements.line.capBezierPoints)for(e=0,n=u.length;e<n;++e)(i=u[e]._model).controlPointPreviousX=t(i.controlPointPreviousX,l.left,l.right),i.controlPointPreviousY=t(i.controlPointPreviousY,l.top,l.bottom),i.controlPointNextX=t(i.controlPointNextX,l.left,l.right),i.controlPointNextY=t(i.controlPointNextY,l.top,l.bottom)},draw:function(){var t=this,n=t.chart,i=t.getMeta(),a=i.data||[],o=n.chartArea,s=a.length,l=0;for(r.canvas.clipArea(n.ctx,o),e(t.getDataset(),n.options)&&i.dataset.draw(),r.canvas.unclipArea(n.ctx);l<s;++l)a[l].draw(o)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,i=t.custom||{},a=t._model;a.radius=i.hoverRadius||r.valueAtIndexOrDefault(e.pointHoverRadius,n,this.chart.options.elements.point.hoverRadius),a.backgroundColor=i.hoverBackgroundColor||r.valueAtIndexOrDefault(e.pointHoverBackgroundColor,n,r.getHoverColor(a.backgroundColor)),a.borderColor=i.hoverBorderColor||r.valueAtIndexOrDefault(e.pointHoverBorderColor,n,r.getHoverColor(a.borderColor)),a.borderWidth=i.hoverBorderWidth||r.valueAtIndexOrDefault(e.pointHoverBorderWidth,n,a.borderWidth)},removeHoverStyle:function(t){var e=this,n=e.chart.data.datasets[t._datasetIndex],i=t._index,a=t.custom||{},o=t._model;void 0!==n.radius&&void 0===n.pointRadius&&(n.pointRadius=n.radius),o.radius=a.radius||r.valueAtIndexOrDefault(n.pointRadius,i,e.chart.options.elements.point.radius),o.backgroundColor=e.getPointBackgroundColor(t,i),o.borderColor=e.getPointBorderColor(t,i),o.borderWidth=e.getPointBorderWidth(t,i)}})}},{25:25,40:40,45:45}],19:[function(t,e,n){"use strict";var i=t(25),a=t(40),r=t(45);i._set("polarArea",{scale:{type:"radialLinear",angleLines:{display:!1},gridLines:{circular:!0},pointLabels:{display:!1},ticks:{beginAtZero:!0}},animation:{animateRotate:!0,animateScale:!0},startAngle:-.5*Math.PI,legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var n=t.data,i=n.datasets,a=n.labels;if(i.length)for(var r=0;r<i[0].data.length;++r)e.push('<li><span style="background-color:'+i[0].backgroundColor[r]+'"></span>'),a[r]&&e.push(a[r]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var e=t.data;return e.labels.length&&e.datasets.length?e.labels.map(function(n,i){var a=t.getDatasetMeta(0),o=e.datasets[0],s=a.data[i].custom||{},l=r.valueAtIndexOrDefault,u=t.options.elements.arc;return{text:n,fillStyle:s.backgroundColor?s.backgroundColor:l(o.backgroundColor,i,u.backgroundColor),strokeStyle:s.borderColor?s.borderColor:l(o.borderColor,i,u.borderColor),lineWidth:s.borderWidth?s.borderWidth:l(o.borderWidth,i,u.borderWidth),hidden:isNaN(o.data[i])||a.data[i].hidden,index:i}}):[]}},onClick:function(t,e){var n,i,a,r=e.index,o=this.chart;for(n=0,i=(o.data.datasets||[]).length;n<i;++n)(a=o.getDatasetMeta(n)).data[r].hidden=!a.data[r].hidden;o.update()}},tooltips:{callbacks:{title:function(){return""},label:function(t,e){return e.labels[t.index]+": "+t.yLabel}}}}),e.exports=function(t){t.controllers.polarArea=t.DatasetController.extend({dataElementType:a.Arc,linkScales:r.noop,update:function(t){var e=this,n=e.chart,i=n.chartArea,a=e.getMeta(),o=n.options,s=o.elements.arc,l=Math.min(i.right-i.left,i.bottom-i.top);n.outerRadius=Math.max((l-s.borderWidth/2)/2,0),n.innerRadius=Math.max(o.cutoutPercentage?n.outerRadius/100*o.cutoutPercentage:1,0),n.radiusLength=(n.outerRadius-n.innerRadius)/n.getVisibleDatasetCount(),e.outerRadius=n.outerRadius-n.radiusLength*e.index,e.innerRadius=e.outerRadius-n.radiusLength,a.count=e.countVisibleElements(),r.each(a.data,function(n,i){e.updateElement(n,i,t)})},updateElement:function(t,e,n){for(var i=this,a=i.chart,o=i.getDataset(),s=a.options,l=s.animation,u=a.scale,d=a.data.labels,c=i.calculateCircumference(o.data[e]),h=u.xCenter,f=u.yCenter,g=0,m=i.getMeta(),p=0;p<e;++p)isNaN(o.data[p])||m.data[p].hidden||++g;var v=s.startAngle,y=t.hidden?0:u.getDistanceFromCenterForValue(o.data[e]),b=v+c*g,x=b+(t.hidden?0:c),_=l.animateScale?0:u.getDistanceFromCenterForValue(o.data[e]);r.extend(t,{_datasetIndex:i.index,_index:e,_scale:u,_model:{x:h,y:f,innerRadius:0,outerRadius:n?_:y,startAngle:n&&l.animateRotate?v:b,endAngle:n&&l.animateRotate?v:x,label:r.valueAtIndexOrDefault(d,e,d[e])}}),i.removeHoverStyle(t),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},countVisibleElements:function(){var t=this.getDataset(),e=this.getMeta(),n=0;return r.each(e.data,function(e,i){isNaN(t.data[i])||e.hidden||n++}),n},calculateCircumference:function(t){var e=this.getMeta().count;return e>0&&!isNaN(t)?2*Math.PI/e:0}})}},{25:25,40:40,45:45}],20:[function(t,e,n){"use strict";var i=t(25),a=t(40),r=t(45);i._set("radar",{scale:{type:"radialLinear"},elements:{line:{tension:0}}}),e.exports=function(t){t.controllers.radar=t.DatasetController.extend({datasetElementType:a.Line,dataElementType:a.Point,linkScales:r.noop,update:function(t){var e=this,n=e.getMeta(),i=n.dataset,a=n.data,o=i.custom||{},s=e.getDataset(),l=e.chart.options.elements.line,u=e.chart.scale;void 0!==s.tension&&void 0===s.lineTension&&(s.lineTension=s.tension),r.extend(n.dataset,{_datasetIndex:e.index,_scale:u,_children:a,_loop:!0,_model:{tension:o.tension?o.tension:r.valueOrDefault(s.lineTension,l.tension),backgroundColor:o.backgroundColor?o.backgroundColor:s.backgroundColor||l.backgroundColor,borderWidth:o.borderWidth?o.borderWidth:s.borderWidth||l.borderWidth,borderColor:o.borderColor?o.borderColor:s.borderColor||l.borderColor,fill:o.fill?o.fill:void 0!==s.fill?s.fill:l.fill,borderCapStyle:o.borderCapStyle?o.borderCapStyle:s.borderCapStyle||l.borderCapStyle,borderDash:o.borderDash?o.borderDash:s.borderDash||l.borderDash,borderDashOffset:o.borderDashOffset?o.borderDashOffset:s.borderDashOffset||l.borderDashOffset,borderJoinStyle:o.borderJoinStyle?o.borderJoinStyle:s.borderJoinStyle||l.borderJoinStyle}}),n.dataset.pivot(),r.each(a,function(n,i){e.updateElement(n,i,t)},e),e.updateBezierControlPoints()},updateElement:function(t,e,n){var i=this,a=t.custom||{},o=i.getDataset(),s=i.chart.scale,l=i.chart.options.elements.point,u=s.getPointPositionForValue(e,o.data[e]);void 0!==o.radius&&void 0===o.pointRadius&&(o.pointRadius=o.radius),void 0!==o.hitRadius&&void 0===o.pointHitRadius&&(o.pointHitRadius=o.hitRadius),r.extend(t,{_datasetIndex:i.index,_index:e,_scale:s,_model:{x:n?s.xCenter:u.x,y:n?s.yCenter:u.y,tension:a.tension?a.tension:r.valueOrDefault(o.lineTension,i.chart.options.elements.line.tension),radius:a.radius?a.radius:r.valueAtIndexOrDefault(o.pointRadius,e,l.radius),backgroundColor:a.backgroundColor?a.backgroundColor:r.valueAtIndexOrDefault(o.pointBackgroundColor,e,l.backgroundColor),borderColor:a.borderColor?a.borderColor:r.valueAtIndexOrDefault(o.pointBorderColor,e,l.borderColor),borderWidth:a.borderWidth?a.borderWidth:r.valueAtIndexOrDefault(o.pointBorderWidth,e,l.borderWidth),pointStyle:a.pointStyle?a.pointStyle:r.valueAtIndexOrDefault(o.pointStyle,e,l.pointStyle),hitRadius:a.hitRadius?a.hitRadius:r.valueAtIndexOrDefault(o.pointHitRadius,e,l.hitRadius)}}),t._model.skip=a.skip?a.skip:isNaN(t._model.x)||isNaN(t._model.y)},updateBezierControlPoints:function(){var t=this.chart.chartArea,e=this.getMeta();r.each(e.data,function(n,i){var a=n._model,o=r.splineCurve(r.previousItem(e.data,i,!0)._model,a,r.nextItem(e.data,i,!0)._model,a.tension);a.controlPointPreviousX=Math.max(Math.min(o.previous.x,t.right),t.left),a.controlPointPreviousY=Math.max(Math.min(o.previous.y,t.bottom),t.top),a.controlPointNextX=Math.max(Math.min(o.next.x,t.right),t.left),a.controlPointNextY=Math.max(Math.min(o.next.y,t.bottom),t.top),n.pivot()})},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t.custom||{},i=t._index,a=t._model;a.radius=n.hoverRadius?n.hoverRadius:r.valueAtIndexOrDefault(e.pointHoverRadius,i,this.chart.options.elements.point.hoverRadius),a.backgroundColor=n.hoverBackgroundColor?n.hoverBackgroundColor:r.valueAtIndexOrDefault(e.pointHoverBackgroundColor,i,r.getHoverColor(a.backgroundColor)),a.borderColor=n.hoverBorderColor?n.hoverBorderColor:r.valueAtIndexOrDefault(e.pointHoverBorderColor,i,r.getHoverColor(a.borderColor)),a.borderWidth=n.hoverBorderWidth?n.hoverBorderWidth:r.valueAtIndexOrDefault(e.pointHoverBorderWidth,i,a.borderWidth)},removeHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t.custom||{},i=t._index,a=t._model,o=this.chart.options.elements.point;a.radius=n.radius?n.radius:r.valueAtIndexOrDefault(e.pointRadius,i,o.radius),a.backgroundColor=n.backgroundColor?n.backgroundColor:r.valueAtIndexOrDefault(e.pointBackgroundColor,i,o.backgroundColor),a.borderColor=n.borderColor?n.borderColor:r.valueAtIndexOrDefault(e.pointBorderColor,i,o.borderColor),a.borderWidth=n.borderWidth?n.borderWidth:r.valueAtIndexOrDefault(e.pointBorderWidth,i,o.borderWidth)}})}},{25:25,40:40,45:45}],21:[function(t,e,n){"use strict";t(25)._set("scatter",{hover:{mode:"single"},scales:{xAxes:[{id:"x-axis-1",type:"linear",position:"bottom"}],yAxes:[{id:"y-axis-1",type:"linear",position:"left"}]},showLines:!1,tooltips:{callbacks:{title:function(){return""},label:function(t){return"("+t.xLabel+", "+t.yLabel+")"}}}}),e.exports=function(t){t.controllers.scatter=t.controllers.line}},{25:25}],22:[function(t,e,n){"use strict";var i=t(25),a=t(26),r=t(45);i._set("global",{animation:{duration:1e3,easing:"easeOutQuart",onProgress:r.noop,onComplete:r.noop}}),e.exports=function(t){t.Animation=a.extend({chart:null,currentStep:0,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),t.animationService={frameDuration:17,animations:[],dropFrames:0,request:null,addAnimation:function(t,e,n,i){var a,r,o=this.animations;for(e.chart=t,i||(t.animating=!0),a=0,r=o.length;a<r;++a)if(o[a].chart===t)return void(o[a]=e);o.push(e),1===o.length&&this.requestAnimationFrame()},cancelAnimation:function(t){var e=r.findIndex(this.animations,function(e){return e.chart===t});-1!==e&&(this.animations.splice(e,1),t.animating=!1)},requestAnimationFrame:function(){var t=this;null===t.request&&(t.request=r.requestAnimFrame.call(window,function(){t.request=null,t.startDigest()}))},startDigest:function(){var t=this,e=Date.now(),n=0;t.dropFrames>1&&(n=Math.floor(t.dropFrames),t.dropFrames=t.dropFrames%1),t.advance(1+n);var i=Date.now();t.dropFrames+=(i-e)/t.frameDuration,t.animations.length>0&&t.requestAnimationFrame()},advance:function(t){for(var e,n,i=this.animations,a=0;a<i.length;)n=(e=i[a]).chart,e.currentStep=(e.currentStep||0)+t,e.currentStep=Math.min(e.currentStep,e.numSteps),r.callback(e.render,[n,e],n),r.callback(e.onAnimationProgress,[e],n),e.currentStep>=e.numSteps?(r.callback(e.onAnimationComplete,[e],n),n.animating=!1,i.splice(a,1)):++a}},Object.defineProperty(t.Animation.prototype,"animationObject",{get:function(){return this}}),Object.defineProperty(t.Animation.prototype,"chartInstance",{get:function(){return this.chart},set:function(t){this.chart=t}})}},{25:25,26:26,45:45}],23:[function(t,e,n){"use strict";var i=t(25),a=t(45),r=t(28),o=t(48);e.exports=function(t){function e(t){var e=(t=t||{}).data=t.data||{};return e.datasets=e.datasets||[],e.labels=e.labels||[],t.options=a.configMerge(i.global,i[t.type],t.options||{}),t}function n(t){var e=t.options;e.scale?t.scale.options=e.scale:e.scales&&e.scales.xAxes.concat(e.scales.yAxes).forEach(function(e){t.scales[e.id].options=e}),t.tooltip._options=e.tooltips}function s(t){return"top"===t||"bottom"===t}var l=t.plugins;t.types={},t.instances={},t.controllers={},a.extend(t.prototype,{construct:function(n,i){var r=this;i=e(i);var s=o.acquireContext(n,i),l=s&&s.canvas,u=l&&l.height,d=l&&l.width;r.id=a.uid(),r.ctx=s,r.canvas=l,r.config=i,r.width=d,r.height=u,r.aspectRatio=u?d/u:null,r.options=i.options,r._bufferedRender=!1,r.chart=r,r.controller=r,t.instances[r.id]=r,Object.defineProperty(r,"data",{get:function(){return r.config.data},set:function(t){r.config.data=t}}),s&&l?(r.initialize(),r.update()):console.error("Failed to create chart: can't acquire context from the given item")},initialize:function(){var t=this;return l.notify(t,"beforeInit"),a.retinaScale(t,t.options.devicePixelRatio),t.bindEvents(),t.options.responsive&&t.resize(!0),t.ensureScalesHaveIDs(),t.buildScales(),t.initToolTip(),l.notify(t,"afterInit"),t},clear:function(){return a.canvas.clear(this),this},stop:function(){return t.animationService.cancelAnimation(this),this},resize:function(t){var e=this,n=e.options,i=e.canvas,r=n.maintainAspectRatio&&e.aspectRatio||null,o=Math.max(0,Math.floor(a.getMaximumWidth(i))),s=Math.max(0,Math.floor(r?o/r:a.getMaximumHeight(i)));if((e.width!==o||e.height!==s)&&(i.width=e.width=o,i.height=e.height=s,i.style.width=o+"px",i.style.height=s+"px",a.retinaScale(e,n.devicePixelRatio),!t)){var u={width:o,height:s};l.notify(e,"resize",[u]),e.options.onResize&&e.options.onResize(e,u),e.stop(),e.update(e.options.responsiveAnimationDuration)}},ensureScalesHaveIDs:function(){var t=this.options,e=t.scales||{},n=t.scale;a.each(e.xAxes,function(t,e){t.id=t.id||"x-axis-"+e}),a.each(e.yAxes,function(t,e){t.id=t.id||"y-axis-"+e}),n&&(n.id=n.id||"scale")},buildScales:function(){var e=this,n=e.options,i=e.scales={},r=[];n.scales&&(r=r.concat((n.scales.xAxes||[]).map(function(t){return{options:t,dtype:"category",dposition:"bottom"}}),(n.scales.yAxes||[]).map(function(t){return{options:t,dtype:"linear",dposition:"left"}}))),n.scale&&r.push({options:n.scale,dtype:"radialLinear",isDefault:!0,dposition:"chartArea"}),a.each(r,function(n){var r=n.options,o=a.valueOrDefault(r.type,n.dtype),l=t.scaleService.getScaleConstructor(o);if(l){s(r.position)!==s(n.dposition)&&(r.position=n.dposition);var u=new l({id:r.id,options:r,ctx:e.ctx,chart:e});i[u.id]=u,u.mergeTicksOptions(),n.isDefault&&(e.scale=u)}}),t.scaleService.addScalesToLayout(this)},buildOrUpdateControllers:function(){var e=this,n=[],i=[];return a.each(e.data.datasets,function(a,r){var o=e.getDatasetMeta(r),s=a.type||e.config.type;if(o.type&&o.type!==s&&(e.destroyDatasetMeta(r),o=e.getDatasetMeta(r)),o.type=s,n.push(o.type),o.controller)o.controller.updateIndex(r);else{var l=t.controllers[o.type];if(void 0===l)throw new Error('"'+o.type+'" is not a chart type.');o.controller=new l(e,r),i.push(o.controller)}},e),i},resetElements:function(){var t=this;a.each(t.data.datasets,function(e,n){t.getDatasetMeta(n).controller.reset()},t)},reset:function(){this.resetElements(),this.tooltip.initialize()},update:function(t){var e=this;if(t&&"object"==typeof t||(t={duration:t,lazy:arguments[1]}),n(e),!1!==l.notify(e,"beforeUpdate")){e.tooltip._data=e.data;var i=e.buildOrUpdateControllers();a.each(e.data.datasets,function(t,n){e.getDatasetMeta(n).controller.buildOrUpdateElements()},e),e.updateLayout(),a.each(i,function(t){t.reset()}),e.updateDatasets(),e.tooltip.initialize(),e.lastActive=[],l.notify(e,"afterUpdate"),e._bufferedRender?e._bufferedRequest={duration:t.duration,easing:t.easing,lazy:t.lazy}:e.render(t)}},updateLayout:function(){var e=this;!1!==l.notify(e,"beforeLayout")&&(t.layoutService.update(this,this.width,this.height),l.notify(e,"afterScaleUpdate"),l.notify(e,"afterLayout"))},updateDatasets:function(){var t=this;if(!1!==l.notify(t,"beforeDatasetsUpdate")){for(var e=0,n=t.data.datasets.length;e<n;++e)t.updateDataset(e);l.notify(t,"afterDatasetsUpdate")}},updateDataset:function(t){var e=this,n=e.getDatasetMeta(t),i={meta:n,index:t};!1!==l.notify(e,"beforeDatasetUpdate",[i])&&(n.controller.update(),l.notify(e,"afterDatasetUpdate",[i]))},render:function(e){var n=this;e&&"object"==typeof e||(e={duration:e,lazy:arguments[1]});var i=e.duration,r=e.lazy;if(!1!==l.notify(n,"beforeRender")){var o=n.options.animation,s=function(t){l.notify(n,"afterRender"),a.callback(o&&o.onComplete,[t],n)};if(o&&(void 0!==i&&0!==i||void 0===i&&0!==o.duration)){var u=new t.Animation({numSteps:(i||o.duration)/16.66,easing:e.easing||o.easing,render:function(t,e){var n=a.easing.effects[e.easing],i=e.currentStep,r=i/e.numSteps;t.draw(n(r),r,i)},onAnimationProgress:o.onProgress,onAnimationComplete:s});t.animationService.addAnimation(n,u,i,r)}else n.draw(),s(new t.Animation({numSteps:0,chart:n}));return n}},draw:function(t){var e=this;e.clear(),a.isNullOrUndef(t)&&(t=1),e.transition(t),!1!==l.notify(e,"beforeDraw",[t])&&(a.each(e.boxes,function(t){t.draw(e.chartArea)},e),e.scale&&e.scale.draw(),e.drawDatasets(t),e._drawTooltip(t),l.notify(e,"afterDraw",[t]))},transition:function(t){for(var e=this,n=0,i=(e.data.datasets||[]).length;n<i;++n)e.isDatasetVisible(n)&&e.getDatasetMeta(n).controller.transition(t);e.tooltip.transition(t)},drawDatasets:function(t){var e=this;if(!1!==l.notify(e,"beforeDatasetsDraw",[t])){for(var n=(e.data.datasets||[]).length-1;n>=0;--n)e.isDatasetVisible(n)&&e.drawDataset(n,t);l.notify(e,"afterDatasetsDraw",[t])}},drawDataset:function(t,e){var n=this,i=n.getDatasetMeta(t),a={meta:i,index:t,easingValue:e};!1!==l.notify(n,"beforeDatasetDraw",[a])&&(i.controller.draw(e),l.notify(n,"afterDatasetDraw",[a]))},_drawTooltip:function(t){var e=this,n=e.tooltip,i={tooltip:n,easingValue:t};!1!==l.notify(e,"beforeTooltipDraw",[i])&&(n.draw(),l.notify(e,"afterTooltipDraw",[i]))},getElementAtEvent:function(t){return r.modes.single(this,t)},getElementsAtEvent:function(t){return r.modes.label(this,t,{intersect:!0})},getElementsAtXAxis:function(t){return r.modes["x-axis"](this,t,{intersect:!0})},getElementsAtEventForMode:function(t,e,n){var i=r.modes[e];return"function"==typeof i?i(this,t,n):[]},getDatasetAtEvent:function(t){return r.modes.dataset(this,t,{intersect:!0})},getDatasetMeta:function(t){var e=this,n=e.data.datasets[t];n._meta||(n._meta={});var i=n._meta[e.id];return i||(i=n._meta[e.id]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null}),i},getVisibleDatasetCount:function(){for(var t=0,e=0,n=this.data.datasets.length;e<n;++e)this.isDatasetVisible(e)&&t++;return t},isDatasetVisible:function(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden},generateLegend:function(){return this.options.legendCallback(this)},destroyDatasetMeta:function(t){var e=this.id,n=this.data.datasets[t],i=n._meta&&n._meta[e];i&&(i.controller.destroy(),delete n._meta[e])},destroy:function(){var e,n,i=this,r=i.canvas;for(i.stop(),e=0,n=i.data.datasets.length;e<n;++e)i.destroyDatasetMeta(e);r&&(i.unbindEvents(),a.canvas.clear(i),o.releaseContext(i.ctx),i.canvas=null,i.ctx=null),l.notify(i,"destroy"),delete t.instances[i.id]},toBase64Image:function(){return this.canvas.toDataURL.apply(this.canvas,arguments)},initToolTip:function(){var e=this;e.tooltip=new t.Tooltip({_chart:e,_chartInstance:e,_data:e.data,_options:e.options.tooltips},e)},bindEvents:function(){var t=this,e=t._listeners={},n=function(){t.eventHandler.apply(t,arguments)};a.each(t.options.events,function(i){o.addEventListener(t,i,n),e[i]=n}),t.options.responsive&&(n=function(){t.resize()},o.addEventListener(t,"resize",n),e.resize=n)},unbindEvents:function(){var t=this,e=t._listeners;e&&(delete t._listeners,a.each(e,function(e,n){o.removeEventListener(t,n,e)}))},updateHoverStyle:function(t,e,n){var i,a,r,o=n?"setHoverStyle":"removeHoverStyle";for(a=0,r=t.length;a<r;++a)(i=t[a])&&this.getDatasetMeta(i._datasetIndex).controller[o](i)},eventHandler:function(t){var e=this,n=e.tooltip;if(!1!==l.notify(e,"beforeEvent",[t])){e._bufferedRender=!0,e._bufferedRequest=null;var i=e.handleEvent(t);i|=n&&n.handleEvent(t),l.notify(e,"afterEvent",[t]);var a=e._bufferedRequest;return a?e.render(a):i&&!e.animating&&(e.stop(),e.render(e.options.hover.animationDuration,!0)),e._bufferedRender=!1,e._bufferedRequest=null,e}},handleEvent:function(t){var e=this,n=e.options||{},i=n.hover,r=!1;return e.lastActive=e.lastActive||[],"mouseout"===t.type?e.active=[]:e.active=e.getElementsAtEventForMode(t,i.mode,i),a.callback(n.onHover||n.hover.onHover,[t.native,e.active],e),"mouseup"!==t.type&&"click"!==t.type||n.onClick&&n.onClick.call(e,t.native,e.active),e.lastActive.length&&e.updateHoverStyle(e.lastActive,i.mode,!1),e.active.length&&i.mode&&e.updateHoverStyle(e.active,i.mode,!0),r=!a.arrayEquals(e.active,e.lastActive),e.lastActive=e.active,r}}),t.Controller=t}},{25:25,28:28,45:45,48:48}],24:[function(t,e,n){"use strict";var i=t(45);e.exports=function(t){function e(t,e){t._chartjs?t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),a.forEach(function(e){var n="onData"+e.charAt(0).toUpperCase()+e.slice(1),a=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:function(){var e=Array.prototype.slice.call(arguments),r=a.apply(this,e);return i.each(t._chartjs.listeners,function(t){"function"==typeof t[n]&&t[n].apply(t,e)}),r}})}))}function n(t,e){var n=t._chartjs;if(n){var i=n.listeners,r=i.indexOf(e);-1!==r&&i.splice(r,1),i.length>0||(a.forEach(function(e){delete t[e]}),delete t._chartjs)}}var a=["push","pop","shift","splice","unshift"];t.DatasetController=function(t,e){this.initialize(t,e)},i.extend(t.DatasetController.prototype,{datasetElementType:null,dataElementType:null,initialize:function(t,e){var n=this;n.chart=t,n.index=e,n.linkScales(),n.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){var t=this,e=t.getMeta(),n=t.getDataset();null===e.xAxisID&&(e.xAxisID=n.xAxisID||t.chart.options.scales.xAxes[0].id),null===e.yAxisID&&(e.yAxisID=n.yAxisID||t.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getMeta:function(){return this.chart.getDatasetMeta(this.index)},getScaleForId:function(t){return this.chart.scales[t]},reset:function(){this.update(!0)},destroy:function(){this._data&&n(this._data,this)},createMetaDataset:function(){var t=this,e=t.datasetElementType;return e&&new e({_chart:t.chart,_datasetIndex:t.index})},createMetaData:function(t){var e=this,n=e.dataElementType;return n&&new n({_chart:e.chart,_datasetIndex:e.index,_index:t})},addElements:function(){var t,e,n=this,i=n.getMeta(),a=n.getDataset().data||[],r=i.data;for(t=0,e=a.length;t<e;++t)r[t]=r[t]||n.createMetaData(t);i.dataset=i.dataset||n.createMetaDataset()},addElementAndReset:function(t){var e=this.createMetaData(t);this.getMeta().data.splice(t,0,e),this.updateElement(e,t,!0)},buildOrUpdateElements:function(){var t=this,i=t.getDataset(),a=i.data||(i.data=[]);t._data!==a&&(t._data&&n(t._data,t),e(a,t),t._data=a),t.resyncElements()},update:i.noop,transition:function(t){for(var e=this.getMeta(),n=e.data||[],i=n.length,a=0;a<i;++a)n[a].transition(t);e.dataset&&e.dataset.transition(t)},draw:function(){var t=this.getMeta(),e=t.data||[],n=e.length,i=0;for(t.dataset&&t.dataset.draw();i<n;++i)e[i].draw()},removeHoverStyle:function(t,e){var n=this.chart.data.datasets[t._datasetIndex],a=t._index,r=t.custom||{},o=i.valueAtIndexOrDefault,s=t._model;s.backgroundColor=r.backgroundColor?r.backgroundColor:o(n.backgroundColor,a,e.backgroundColor),s.borderColor=r.borderColor?r.borderColor:o(n.borderColor,a,e.borderColor),s.borderWidth=r.borderWidth?r.borderWidth:o(n.borderWidth,a,e.borderWidth)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,a=t.custom||{},r=i.valueAtIndexOrDefault,o=i.getHoverColor,s=t._model;s.backgroundColor=a.hoverBackgroundColor?a.hoverBackgroundColor:r(e.hoverBackgroundColor,n,o(s.backgroundColor)),s.borderColor=a.hoverBorderColor?a.hoverBorderColor:r(e.hoverBorderColor,n,o(s.borderColor)),s.borderWidth=a.hoverBorderWidth?a.hoverBorderWidth:r(e.hoverBorderWidth,n,s.borderWidth)},resyncElements:function(){var t=this,e=t.getMeta(),n=t.getDataset().data,i=e.data.length,a=n.length;a<i?e.data.splice(a,i-a):a>i&&t.insertElements(i,a-i)},insertElements:function(t,e){for(var n=0;n<e;++n)this.addElementAndReset(t+n)},onDataPush:function(){this.insertElements(this.getDataset().data.length-1,arguments.length)},onDataPop:function(){this.getMeta().data.pop()},onDataShift:function(){this.getMeta().data.shift()},onDataSplice:function(t,e){this.getMeta().data.splice(t,e),this.insertElements(t,arguments.length-2)},onDataUnshift:function(){this.insertElements(0,arguments.length)}}),t.DatasetController.extend=i.inherits}},{45:45}],25:[function(t,e,n){"use strict";var i=t(45);e.exports={_set:function(t,e){return i.merge(this[t]||(this[t]={}),e)}}},{45:45}],26:[function(t,e,n){"use strict";function i(t,e,n,i){var r,o,s,l,u,d,c,h,f,g=Object.keys(n);for(r=0,o=g.length;r<o;++r)if(s=g[r],d=n[s],e.hasOwnProperty(s)||(e[s]=d),(l=e[s])!==d&&"_"!==s[0]){if(t.hasOwnProperty(s)||(t[s]=l),u=t[s],(c=typeof d)===typeof u)if("string"===c){if((h=a(u)).valid&&(f=a(d)).valid){e[s]=f.mix(h,i).rgbString();continue}}else if("number"===c&&isFinite(u)&&isFinite(d)){e[s]=u+(d-u)*i;continue}e[s]=d}}var a=t(2),r=t(45),o=function(t){r.extend(this,t),this.initialize.apply(this,arguments)};r.extend(o.prototype,{initialize:function(){this.hidden=!1},pivot:function(){var t=this;return t._view||(t._view=r.clone(t._model)),t._start={},t},transition:function(t){var e=this,n=e._model,a=e._start,r=e._view;return n&&1!==t?(r||(r=e._view={}),a||(a=e._start={}),i(a,r,n,t),e):(e._view=n,e._start=null,e)},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return r.isNumber(this._model.x)&&r.isNumber(this._model.y)}}),o.extend=r.inherits,e.exports=o},{2:2,45:45}],27:[function(t,e,n){"use strict";var i=t(2),a=t(25),r=t(45);e.exports=function(t){function e(t,e,n){var i;return"string"==typeof t?(i=parseInt(t,10),-1!==t.indexOf("%")&&(i=i/100*e.parentNode[n])):i=t,i}function n(t){return void 0!==t&&null!==t&&"none"!==t}function o(t,i,a){var r=document.defaultView,o=t.parentNode,s=r.getComputedStyle(t)[i],l=r.getComputedStyle(o)[i],u=n(s),d=n(l),c=Number.POSITIVE_INFINITY;return u||d?Math.min(u?e(s,t,a):c,d?e(l,o,a):c):"none"}r.configMerge=function(){return r.merge(r.clone(arguments[0]),[].slice.call(arguments,1),{merger:function(e,n,i,a){var o=n[e]||{},s=i[e];"scales"===e?n[e]=r.scaleMerge(o,s):"scale"===e?n[e]=r.merge(o,[t.scaleService.getScaleDefaults(s.type),s]):r._merger(e,n,i,a)}})},r.scaleMerge=function(){return r.merge(r.clone(arguments[0]),[].slice.call(arguments,1),{merger:function(e,n,i,a){if("xAxes"===e||"yAxes"===e){var o,s,l,u=i[e].length;for(n[e]||(n[e]=[]),o=0;o<u;++o)l=i[e][o],s=r.valueOrDefault(l.type,"xAxes"===e?"category":"linear"),o>=n[e].length&&n[e].push({}),!n[e][o].type||l.type&&l.type!==n[e][o].type?r.merge(n[e][o],[t.scaleService.getScaleDefaults(s),l]):r.merge(n[e][o],l)}else r._merger(e,n,i,a)}})},r.where=function(t,e){if(r.isArray(t)&&Array.prototype.filter)return t.filter(e);var n=[];return r.each(t,function(t){e(t)&&n.push(t)}),n},r.findIndex=Array.prototype.findIndex?function(t,e,n){return t.findIndex(e,n)}:function(t,e,n){n=void 0===n?t:n;for(var i=0,a=t.length;i<a;++i)if(e.call(n,t[i],i,t))return i;return-1},r.findNextWhere=function(t,e,n){r.isNullOrUndef(n)&&(n=-1);for(var i=n+1;i<t.length;i++){var a=t[i];if(e(a))return a}},r.findPreviousWhere=function(t,e,n){r.isNullOrUndef(n)&&(n=t.length);for(var i=n-1;i>=0;i--){var a=t[i];if(e(a))return a}},r.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},r.almostEquals=function(t,e,n){return Math.abs(t-e)<n},r.almostWhole=function(t,e){var n=Math.round(t);return n-e<t&&n+e>t},r.max=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.max(t,e)},Number.NEGATIVE_INFINITY)},r.min=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.min(t,e)},Number.POSITIVE_INFINITY)},r.sign=Math.sign?function(t){return Math.sign(t)}:function(t){return 0==(t=+t)||isNaN(t)?t:t>0?1:-1},r.log10=Math.log10?function(t){return Math.log10(t)}:function(t){return Math.log(t)/Math.LN10},r.toRadians=function(t){return t*(Math.PI/180)},r.toDegrees=function(t){return t*(180/Math.PI)},r.getAngleFromPoint=function(t,e){var n=e.x-t.x,i=e.y-t.y,a=Math.sqrt(n*n+i*i),r=Math.atan2(i,n);return r<-.5*Math.PI&&(r+=2*Math.PI),{angle:r,distance:a}},r.distanceBetweenPoints=function(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},r.aliasPixel=function(t){return t%2==0?0:.5},r.splineCurve=function(t,e,n,i){var a=t.skip?e:t,r=e,o=n.skip?e:n,s=Math.sqrt(Math.pow(r.x-a.x,2)+Math.pow(r.y-a.y,2)),l=Math.sqrt(Math.pow(o.x-r.x,2)+Math.pow(o.y-r.y,2)),u=s/(s+l),d=l/(s+l),c=i*(u=isNaN(u)?0:u),h=i*(d=isNaN(d)?0:d);return{previous:{x:r.x-c*(o.x-a.x),y:r.y-c*(o.y-a.y)},next:{x:r.x+h*(o.x-a.x),y:r.y+h*(o.y-a.y)}}},r.EPSILON=Number.EPSILON||1e-14,r.splineCurveMonotone=function(t){var e,n,i,a,o=(t||[]).map(function(t){return{model:t._model,deltaK:0,mK:0}}),s=o.length;for(e=0;e<s;++e)if(!(i=o[e]).model.skip){if(n=e>0?o[e-1]:null,(a=e<s-1?o[e+1]:null)&&!a.model.skip){var l=a.model.x-i.model.x;i.deltaK=0!==l?(a.model.y-i.model.y)/l:0}!n||n.model.skip?i.mK=i.deltaK:!a||a.model.skip?i.mK=n.deltaK:this.sign(n.deltaK)!==this.sign(i.deltaK)?i.mK=0:i.mK=(n.deltaK+i.deltaK)/2}var u,d,c,h;for(e=0;e<s-1;++e)i=o[e],a=o[e+1],i.model.skip||a.model.skip||(r.almostEquals(i.deltaK,0,this.EPSILON)?i.mK=a.mK=0:(u=i.mK/i.deltaK,d=a.mK/i.deltaK,(h=Math.pow(u,2)+Math.pow(d,2))<=9||(c=3/Math.sqrt(h),i.mK=u*c*i.deltaK,a.mK=d*c*i.deltaK)));var f;for(e=0;e<s;++e)(i=o[e]).model.skip||(n=e>0?o[e-1]:null,a=e<s-1?o[e+1]:null,n&&!n.model.skip&&(f=(i.model.x-n.model.x)/3,i.model.controlPointPreviousX=i.model.x-f,i.model.controlPointPreviousY=i.model.y-f*i.mK),a&&!a.model.skip&&(f=(a.model.x-i.model.x)/3,i.model.controlPointNextX=i.model.x+f,i.model.controlPointNextY=i.model.y+f*i.mK))},r.nextItem=function(t,e,n){return n?e>=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},r.previousItem=function(t,e,n){return n?e<=0?t[t.length-1]:t[e-1]:e<=0?t[0]:t[e-1]},r.niceNum=function(t,e){var n=Math.floor(r.log10(t)),i=t/Math.pow(10,n);return(e?i<1.5?1:i<3?2:i<7?5:10:i<=1?1:i<=2?2:i<=5?5:10)*Math.pow(10,n)},r.requestAnimFrame="undefined"==typeof window?function(t){t()}:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)},r.getRelativePosition=function(t,e){var n,i,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,s=o.getBoundingClientRect(),l=a.touches;l&&l.length>0?(n=l[0].clientX,i=l[0].clientY):(n=a.clientX,i=a.clientY);var u=parseFloat(r.getStyle(o,"padding-left")),d=parseFloat(r.getStyle(o,"padding-top")),c=parseFloat(r.getStyle(o,"padding-right")),h=parseFloat(r.getStyle(o,"padding-bottom")),f=s.right-s.left-u-c,g=s.bottom-s.top-d-h;return n=Math.round((n-s.left-u)/f*o.width/e.currentDevicePixelRatio),i=Math.round((i-s.top-d)/g*o.height/e.currentDevicePixelRatio),{x:n,y:i}},r.getConstraintWidth=function(t){return o(t,"max-width","clientWidth")},r.getConstraintHeight=function(t){return o(t,"max-height","clientHeight")},r.getMaximumWidth=function(t){var e=t.parentNode;if(!e)return t.clientWidth;var n=parseInt(r.getStyle(e,"padding-left"),10),i=parseInt(r.getStyle(e,"padding-right"),10),a=e.clientWidth-n-i,o=r.getConstraintWidth(t);return isNaN(o)?a:Math.min(a,o)},r.getMaximumHeight=function(t){var e=t.parentNode;if(!e)return t.clientHeight;var n=parseInt(r.getStyle(e,"padding-top"),10),i=parseInt(r.getStyle(e,"padding-bottom"),10),a=e.clientHeight-n-i,o=r.getConstraintHeight(t);return isNaN(o)?a:Math.min(a,o)},r.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},r.retinaScale=function(t,e){var n=t.currentDevicePixelRatio=e||window.devicePixelRatio||1;if(1!==n){var i=t.canvas,a=t.height,r=t.width;i.height=a*n,i.width=r*n,t.ctx.scale(n,n),i.style.height=a+"px",i.style.width=r+"px"}},r.fontString=function(t,e,n){return e+" "+t+"px "+n},r.longestText=function(t,e,n,i){var a=(i=i||{}).data=i.data||{},o=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(a=i.data={},o=i.garbageCollect=[],i.font=e),t.font=e;var s=0;r.each(n,function(e){void 0!==e&&null!==e&&!0!==r.isArray(e)?s=r.measureText(t,a,o,s,e):r.isArray(e)&&r.each(e,function(e){void 0===e||null===e||r.isArray(e)||(s=r.measureText(t,a,o,s,e))})});var l=o.length/2;if(l>n.length){for(var u=0;u<l;u++)delete a[o[u]];o.splice(0,l)}return s},r.measureText=function(t,e,n,i,a){var r=e[a];return r||(r=e[a]=t.measureText(a).width,n.push(a)),r>i&&(i=r),i},r.numberOfLabelLines=function(t){var e=1;return r.each(t,function(t){r.isArray(t)&&t.length>e&&(e=t.length)}),e},r.color=i?function(t){return t instanceof CanvasGradient&&(t=a.global.defaultColor),i(t)}:function(t){return console.error("Color.js not found!"),t},r.getHoverColor=function(t){return t instanceof CanvasPattern?t:r.color(t).saturate(.5).darken(.1).rgbString()}}},{2:2,25:25,45:45}],28:[function(t,e,n){"use strict";function i(t,e){return t.native?{x:t.x,y:t.y}:u.getRelativePosition(t,e)}function a(t,e){var n,i,a,r,o;for(i=0,r=t.data.datasets.length;i<r;++i)if(t.isDatasetVisible(i))for(a=0,o=(n=t.getDatasetMeta(i)).data.length;a<o;++a){var s=n.data[a];s._view.skip||e(s)}}function r(t,e){var n=[];return a(t,function(t){t.inRange(e.x,e.y)&&n.push(t)}),n}function o(t,e,n,i){var r=Number.POSITIVE_INFINITY,o=[];return a(t,function(t){if(!n||t.inRange(e.x,e.y)){var a=t.getCenterPoint(),s=i(e,a);s<r?(o=[t],r=s):s===r&&o.push(t)}}),o}function s(t){var e=-1!==t.indexOf("x"),n=-1!==t.indexOf("y");return function(t,i){var a=e?Math.abs(t.x-i.x):0,r=n?Math.abs(t.y-i.y):0;return Math.sqrt(Math.pow(a,2)+Math.pow(r,2))}}function l(t,e,n){var a=i(e,t);n.axis=n.axis||"x";var l=s(n.axis),u=n.intersect?r(t,a):o(t,a,!1,l),d=[];return u.length?(t.data.datasets.forEach(function(e,n){if(t.isDatasetVisible(n)){var i=t.getDatasetMeta(n).data[u[0]._index];i&&!i._view.skip&&d.push(i)}}),d):[]}var u=t(45);e.exports={modes:{single:function(t,e){var n=i(e,t),r=[];return a(t,function(t){if(t.inRange(n.x,n.y))return r.push(t),r}),r.slice(0,1)},label:l,index:l,dataset:function(t,e,n){var a=i(e,t);n.axis=n.axis||"xy";var l=s(n.axis),u=n.intersect?r(t,a):o(t,a,!1,l);return u.length>0&&(u=t.getDatasetMeta(u[0]._datasetIndex).data),u},"x-axis":function(t,e){return l(t,e,{intersect:!1})},point:function(t,e){return r(t,i(e,t))},nearest:function(t,e,n){var a=i(e,t);n.axis=n.axis||"xy";var r=s(n.axis),l=o(t,a,n.intersect,r);return l.length>1&&l.sort(function(t,e){var n=t.getArea()-e.getArea();return 0===n&&(n=t._datasetIndex-e._datasetIndex),n}),l.slice(0,1)},x:function(t,e,n){var r=i(e,t),o=[],s=!1;return a(t,function(t){t.inXRange(r.x)&&o.push(t),t.inRange(r.x,r.y)&&(s=!0)}),n.intersect&&!s&&(o=[]),o},y:function(t,e,n){var r=i(e,t),o=[],s=!1;return a(t,function(t){t.inYRange(r.y)&&o.push(t),t.inRange(r.x,r.y)&&(s=!0)}),n.intersect&&!s&&(o=[]),o}}}},{45:45}],29:[function(t,e,n){"use strict";t(25)._set("global",{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:null,mode:"nearest",intersect:!0,animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",defaultFontColor:"#666",defaultFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",defaultFontSize:12,defaultFontStyle:"normal",showLines:!0,elements:{},layout:{padding:{top:0,right:0,bottom:0,left:0}}}),e.exports=function(){var t=function(t,e){return this.construct(t,e),this};return t.Chart=t,t}},{25:25}],30:[function(t,e,n){"use strict";var i=t(45);e.exports=function(t){function e(t,e){return i.where(t,function(t){return t.position===e})}function n(t,e){t.forEach(function(t,e){return t._tmpIndex_=e,t}),t.sort(function(t,n){var i=e?n:t,a=e?t:n;return i.weight===a.weight?i._tmpIndex_-a._tmpIndex_:i.weight-a.weight}),t.forEach(function(t){delete t._tmpIndex_})}t.layoutService={defaults:{},addBox:function(t,e){t.boxes||(t.boxes=[]),e.fullWidth=e.fullWidth||!1,e.position=e.position||"top",e.weight=e.weight||0,t.boxes.push(e)},removeBox:function(t,e){var n=t.boxes?t.boxes.indexOf(e):-1;-1!==n&&t.boxes.splice(n,1)},configure:function(t,e,n){for(var i,a=["fullWidth","position","weight"],r=a.length,o=0;o<r;++o)i=a[o],n.hasOwnProperty(i)&&(e[i]=n[i])},update:function(t,a,r){function o(t){var e=i.findNextWhere(D,function(e){return e.box===t});if(e)if(t.isHorizontal()){var n={left:Math.max(I,C),right:Math.max(O,P),top:0,bottom:0};t.update(t.fullWidth?b:M,x/2,n)}else t.update(e.minSize.width,S)}function s(t){t.isHorizontal()?(t.left=t.fullWidth?d:I,t.right=t.fullWidth?a-c:I+M,t.top=B,t.bottom=B+t.height,B=t.bottom):(t.left=z,t.right=z+t.width,t.top=F,t.bottom=F+S,z=t.right)}if(t){var l=t.options.layout||{},u=i.options.toPadding(l.padding),d=u.left,c=u.right,h=u.top,f=u.bottom,g=e(t.boxes,"left"),m=e(t.boxes,"right"),p=e(t.boxes,"top"),v=e(t.boxes,"bottom"),y=e(t.boxes,"chartArea");n(g,!0),n(m,!1),n(p,!0),n(v,!1);var b=a-d-c,x=r-h-f,_=x/2,k=(a-b/2)/(g.length+m.length),w=(r-_)/(p.length+v.length),M=b,S=x,D=[];i.each(g.concat(m,p,v),function(t){var e,n=t.isHorizontal();n?(e=t.update(t.fullWidth?b:M,w),S-=e.height):(e=t.update(k,_),M-=e.width),D.push({horizontal:n,minSize:e,box:t})});var C=0,P=0,T=0,A=0;i.each(p.concat(v),function(t){if(t.getPadding){var e=t.getPadding();C=Math.max(C,e.left),P=Math.max(P,e.right)}}),i.each(g.concat(m),function(t){if(t.getPadding){var e=t.getPadding();T=Math.max(T,e.top),A=Math.max(A,e.bottom)}});var I=d,O=c,F=h,R=f;i.each(g.concat(m),o),i.each(g,function(t){I+=t.width}),i.each(m,function(t){O+=t.width}),i.each(p.concat(v),o),i.each(p,function(t){F+=t.height}),i.each(v,function(t){R+=t.height}),i.each(g.concat(m),function(t){var e=i.findNextWhere(D,function(e){return e.box===t}),n={left:0,right:0,top:F,bottom:R};e&&t.update(e.minSize.width,S,n)}),I=d,O=c,F=h,R=f,i.each(g,function(t){I+=t.width}),i.each(m,function(t){O+=t.width}),i.each(p,function(t){F+=t.height}),i.each(v,function(t){R+=t.height});var L=Math.max(C-I,0);I+=L,O+=Math.max(P-O,0);var W=Math.max(T-F,0);F+=W,R+=Math.max(A-R,0);var Y=r-F-R,N=a-I-O;N===M&&Y===S||(i.each(g,function(t){t.height=Y}),i.each(m,function(t){t.height=Y}),i.each(p,function(t){t.fullWidth||(t.width=N)}),i.each(v,function(t){t.fullWidth||(t.width=N)}),S=Y,M=N);var z=d+L,B=h+W;i.each(g.concat(p),s),z+=M,B+=S,i.each(m,s),i.each(v,s),t.chartArea={left:I,top:F,right:I+M,bottom:F+S},i.each(y,function(e){e.left=t.chartArea.left,e.top=t.chartArea.top,e.right=t.chartArea.right,e.bottom=t.chartArea.bottom,e.update(M,S)})}}}}},{45:45}],31:[function(t,e,n){"use strict";var i=t(25),a=t(26),r=t(45);i._set("global",{plugins:{}}),e.exports=function(t){t.plugins={_plugins:[],_cacheId:0,register:function(t){var e=this._plugins;[].concat(t).forEach(function(t){-1===e.indexOf(t)&&e.push(t)}),this._cacheId++},unregister:function(t){var e=this._plugins;[].concat(t).forEach(function(t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}),this._cacheId++},clear:function(){this._plugins=[],this._cacheId++},count:function(){return this._plugins.length},getAll:function(){return this._plugins},notify:function(t,e,n){var i,a,r,o,s,l=this.descriptors(t),u=l.length;for(i=0;i<u;++i)if(a=l[i],r=a.plugin,"function"==typeof(s=r[e])&&((o=[t].concat(n||[])).push(a.options),!1===s.apply(r,o)))return!1;return!0},descriptors:function(t){var e=t._plugins||(t._plugins={});if(e.id===this._cacheId)return e.descriptors;var n=[],a=[],o=t&&t.config||{},s=o.options&&o.options.plugins||{};return this._plugins.concat(o.plugins||[]).forEach(function(t){if(-1===n.indexOf(t)){var e=t.id,o=s[e];!1!==o&&(!0===o&&(o=r.clone(i.global.plugins[e])),n.push(t),a.push({plugin:t,options:o||{}}))}}),e.descriptors=a,e.id=this._cacheId,a}},t.pluginService=t.plugins,t.PluginBase=a.extend({})}},{25:25,26:26,45:45}],32:[function(t,e,n){"use strict";function i(t){var e,n,i=[];for(e=0,n=t.length;e<n;++e)i.push(t[e].label);return i}function a(t,e,n){var i=t.getPixelForTick(e);return n&&(i-=0===e?(t.getPixelForTick(1)-i)/2:(i-t.getPixelForTick(e-1))/2),i}var r=t(25),o=t(26),s=t(45),l=t(34);r._set("scale",{display:!0,position:"left",offset:!1,gridLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawBorder:!0,drawOnChartArea:!0,drawTicks:!0,tickMarkLength:10,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",zeroLineBorderDash:[],zeroLineBorderDashOffset:0,offsetGridLines:!1,borderDash:[],borderDashOffset:0},scaleLabel:{display:!1,labelString:"",lineHeight:1.2,padding:{top:4,bottom:4}},ticks:{beginAtZero:!1,minRotation:0,maxRotation:50,mirror:!1,padding:0,reverse:!1,display:!0,autoSkip:!0,autoSkipPadding:0,labelOffset:0,callback:l.formatters.values,minor:{},major:{}}}),e.exports=function(t){function e(t,e,n){return s.isArray(e)?s.longestText(t,n,e):t.measureText(e).width}function n(t){var e=s.valueOrDefault,n=r.global,i=e(t.fontSize,n.defaultFontSize),a=e(t.fontStyle,n.defaultFontStyle),o=e(t.fontFamily,n.defaultFontFamily);return{size:i,style:a,family:o,font:s.fontString(i,a,o)}}function l(t){return s.options.toLineHeight(s.valueOrDefault(t.lineHeight,1.2),s.valueOrDefault(t.fontSize,r.global.defaultFontSize))}t.Scale=o.extend({getPadding:function(){var t=this;return{left:t.paddingLeft||0,top:t.paddingTop||0,right:t.paddingRight||0,bottom:t.paddingBottom||0}},getTicks:function(){return this._ticks},mergeTicksOptions:function(){var t=this.options.ticks;!1===t.minor&&(t.minor={display:!1}),!1===t.major&&(t.major={display:!1});for(var e in t)"major"!==e&&"minor"!==e&&(void 0===t.minor[e]&&(t.minor[e]=t[e]),void 0===t.major[e]&&(t.major[e]=t[e]))},beforeUpdate:function(){s.callback(this.options.beforeUpdate,[this])},update:function(t,e,n){var i,a,r,o,l,u,d=this;for(d.beforeUpdate(),d.maxWidth=t,d.maxHeight=e,d.margins=s.extend({left:0,right:0,top:0,bottom:0},n),d.longestTextCache=d.longestTextCache||{},d.beforeSetDimensions(),d.setDimensions(),d.afterSetDimensions(),d.beforeDataLimits(),d.determineDataLimits(),d.afterDataLimits(),d.beforeBuildTicks(),l=d.buildTicks()||[],d.afterBuildTicks(),d.beforeTickToLabelConversion(),r=d.convertTicksToLabels(l)||d.ticks,d.afterTickToLabelConversion(),d.ticks=r,i=0,a=r.length;i<a;++i)o=r[i],(u=l[i])?u.label=o:l.push(u={label:o,major:!1});return d._ticks=l,d.beforeCalculateTickRotation(),d.calculateTickRotation(),d.afterCalculateTickRotation(),d.beforeFit(),d.fit(),d.afterFit(),d.afterUpdate(),d.minSize},afterUpdate:function(){s.callback(this.options.afterUpdate,[this])},beforeSetDimensions:function(){s.callback(this.options.beforeSetDimensions,[this])},setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0},afterSetDimensions:function(){s.callback(this.options.afterSetDimensions,[this])},beforeDataLimits:function(){s.callback(this.options.beforeDataLimits,[this])},determineDataLimits:s.noop,afterDataLimits:function(){s.callback(this.options.afterDataLimits,[this])},beforeBuildTicks:function(){s.callback(this.options.beforeBuildTicks,[this])},buildTicks:s.noop,afterBuildTicks:function(){s.callback(this.options.afterBuildTicks,[this])},beforeTickToLabelConversion:function(){s.callback(this.options.beforeTickToLabelConversion,[this])},convertTicksToLabels:function(){var t=this,e=t.options.ticks;t.ticks=t.ticks.map(e.userCallback||e.callback,this)},afterTickToLabelConversion:function(){s.callback(this.options.afterTickToLabelConversion,[this])},beforeCalculateTickRotation:function(){s.callback(this.options.beforeCalculateTickRotation,[this])},calculateTickRotation:function(){var t=this,e=t.ctx,a=t.options.ticks,r=i(t._ticks),o=n(a);e.font=o.font;var l=a.minRotation||0;if(r.length&&t.options.display&&t.isHorizontal())for(var u,d=s.longestText(e,o.font,r,t.longestTextCache),c=d,h=t.getPixelForTick(1)-t.getPixelForTick(0)-6;c>h&&l<a.maxRotation;){var f=s.toRadians(l);if(u=Math.cos(f),Math.sin(f)*d>t.maxHeight){l--;break}l++,c=u*d}t.labelRotation=l},afterCalculateTickRotation:function(){s.callback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){s.callback(this.options.beforeFit,[this])},fit:function(){var t=this,a=t.minSize={width:0,height:0},r=i(t._ticks),o=t.options,u=o.ticks,d=o.scaleLabel,c=o.gridLines,h=o.display,f=t.isHorizontal(),g=n(u),m=o.gridLines.tickMarkLength;if(a.width=f?t.isFullWidth()?t.maxWidth-t.margins.left-t.margins.right:t.maxWidth:h&&c.drawTicks?m:0,a.height=f?h&&c.drawTicks?m:0:t.maxHeight,d.display&&h){var p=l(d)+s.options.toPadding(d.padding).height;f?a.height+=p:a.width+=p}if(u.display&&h){var v=s.longestText(t.ctx,g.font,r,t.longestTextCache),y=s.numberOfLabelLines(r),b=.5*g.size,x=t.options.ticks.padding;if(f){t.longestLabelWidth=v;var _=s.toRadians(t.labelRotation),k=Math.cos(_),w=Math.sin(_)*v+g.size*y+b*(y-1)+b;a.height=Math.min(t.maxHeight,a.height+w+x),t.ctx.font=g.font;var M=e(t.ctx,r[0],g.font),S=e(t.ctx,r[r.length-1],g.font);0!==t.labelRotation?(t.paddingLeft="bottom"===o.position?k*M+3:k*b+3,t.paddingRight="bottom"===o.position?k*b+3:k*S+3):(t.paddingLeft=M/2+3,t.paddingRight=S/2+3)}else u.mirror?v=0:v+=x+b,a.width=Math.min(t.maxWidth,a.width+v),t.paddingTop=g.size/2,t.paddingBottom=g.size/2}t.handleMargins(),t.width=a.width,t.height=a.height},handleMargins:function(){var t=this;t.margins&&(t.paddingLeft=Math.max(t.paddingLeft-t.margins.left,0),t.paddingTop=Math.max(t.paddingTop-t.margins.top,0),t.paddingRight=Math.max(t.paddingRight-t.margins.right,0),t.paddingBottom=Math.max(t.paddingBottom-t.margins.bottom,0))},afterFit:function(){s.callback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(t){if(s.isNullOrUndef(t))return NaN;if("number"==typeof t&&!isFinite(t))return NaN;if(t)if(this.isHorizontal()){if(void 0!==t.x)return this.getRightValue(t.x)}else if(void 0!==t.y)return this.getRightValue(t.y);return t},getLabelForIndex:s.noop,getPixelForValue:s.noop,getValueForPixel:s.noop,getPixelForTick:function(t){var e=this,n=e.options.offset;if(e.isHorizontal()){var i=(e.width-(e.paddingLeft+e.paddingRight))/Math.max(e._ticks.length-(n?0:1),1),a=i*t+e.paddingLeft;n&&(a+=i/2);var r=e.left+Math.round(a);return r+=e.isFullWidth()?e.margins.left:0}var o=e.height-(e.paddingTop+e.paddingBottom);return e.top+t*(o/(e._ticks.length-1))},getPixelForDecimal:function(t){var e=this;if(e.isHorizontal()){var n=(e.width-(e.paddingLeft+e.paddingRight))*t+e.paddingLeft,i=e.left+Math.round(n);return i+=e.isFullWidth()?e.margins.left:0}return e.top+t*e.height},getBasePixel:function(){return this.getPixelForValue(this.getBaseValue())},getBaseValue:function(){var t=this,e=t.min,n=t.max;return t.beginAtZero?0:e<0&&n<0?n:e>0&&n>0?e:0},_autoSkip:function(t){var e,n,i,a,r=this,o=r.isHorizontal(),l=r.options.ticks.minor,u=t.length,d=s.toRadians(r.labelRotation),c=Math.cos(d),h=r.longestLabelWidth*c,f=[];for(l.maxTicksLimit&&(a=l.maxTicksLimit),o&&(e=!1,(h+l.autoSkipPadding)*u>r.width-(r.paddingLeft+r.paddingRight)&&(e=1+Math.floor((h+l.autoSkipPadding)*u/(r.width-(r.paddingLeft+r.paddingRight)))),a&&u>a&&(e=Math.max(e,Math.floor(u/a)))),n=0;n<u;n++)i=t[n],(e>1&&n%e>0||n%e==0&&n+e>=u)&&n!==u-1&&delete i.label,f.push(i);return f},draw:function(t){var e=this,i=e.options;if(i.display){var o=e.ctx,u=r.global,d=i.ticks.minor,c=i.ticks.major||d,h=i.gridLines,f=i.scaleLabel,g=0!==e.labelRotation,m=e.isHorizontal(),p=d.autoSkip?e._autoSkip(e.getTicks()):e.getTicks(),v=s.valueOrDefault(d.fontColor,u.defaultFontColor),y=n(d),b=s.valueOrDefault(c.fontColor,u.defaultFontColor),x=n(c),_=h.drawTicks?h.tickMarkLength:0,k=s.valueOrDefault(f.fontColor,u.defaultFontColor),w=n(f),M=s.options.toPadding(f.padding),S=s.toRadians(e.labelRotation),D=[],C="right"===i.position?e.left:e.right-_,P="right"===i.position?e.left+_:e.right,T="bottom"===i.position?e.top:e.bottom-_,A="bottom"===i.position?e.top+_:e.bottom;if(s.each(p,function(n,r){if(!s.isNullOrUndef(n.label)){var o,l,c,f,v=n.label;r===e.zeroLineIndex&&i.offset===h.offsetGridLines?(o=h.zeroLineWidth,l=h.zeroLineColor,c=h.zeroLineBorderDash,f=h.zeroLineBorderDashOffset):(o=s.valueAtIndexOrDefault(h.lineWidth,r),l=s.valueAtIndexOrDefault(h.color,r),c=s.valueOrDefault(h.borderDash,u.borderDash),f=s.valueOrDefault(h.borderDashOffset,u.borderDashOffset));var y,b,x,k,w,M,I,O,F,R,L="middle",W="middle",Y=d.padding;if(m){var N=_+Y;"bottom"===i.position?(W=g?"middle":"top",L=g?"right":"center",R=e.top+N):(W=g?"middle":"bottom",L=g?"left":"center",R=e.bottom-N);var z=a(e,r,h.offsetGridLines&&p.length>1);z<e.left&&(l="rgba(0,0,0,0)"),z+=s.aliasPixel(o),F=e.getPixelForTick(r)+d.labelOffset,y=x=w=I=z,b=T,k=A,M=t.top,O=t.bottom}else{var B,V="left"===i.position;d.mirror?(L=V?"left":"right",B=Y):(L=V?"right":"left",B=_+Y),F=V?e.right-B:e.left+B;var H=a(e,r,h.offsetGridLines&&p.length>1);H<e.top&&(l="rgba(0,0,0,0)"),H+=s.aliasPixel(o),R=e.getPixelForTick(r)+d.labelOffset,y=C,x=P,w=t.left,I=t.right,b=k=M=O=H}D.push({tx1:y,ty1:b,tx2:x,ty2:k,x1:w,y1:M,x2:I,y2:O,labelX:F,labelY:R,glWidth:o,glColor:l,glBorderDash:c,glBorderDashOffset:f,rotation:-1*S,label:v,major:n.major,textBaseline:W,textAlign:L})}}),s.each(D,function(t){if(h.display&&(o.save(),o.lineWidth=t.glWidth,o.strokeStyle=t.glColor,o.setLineDash&&(o.setLineDash(t.glBorderDash),o.lineDashOffset=t.glBorderDashOffset),o.beginPath(),h.drawTicks&&(o.moveTo(t.tx1,t.ty1),o.lineTo(t.tx2,t.ty2)),h.drawOnChartArea&&(o.moveTo(t.x1,t.y1),o.lineTo(t.x2,t.y2)),o.stroke(),o.restore()),d.display){o.save(),o.translate(t.labelX,t.labelY),o.rotate(t.rotation),o.font=t.major?x.font:y.font,o.fillStyle=t.major?b:v,o.textBaseline=t.textBaseline,o.textAlign=t.textAlign;var e=t.label;if(s.isArray(e))for(var n=0,i=0;n<e.length;++n)o.fillText(""+e[n],0,i),i+=1.5*y.size;else o.fillText(e,0,0);o.restore()}}),f.display){var I,O,F=0,R=l(f)/2;if(m)I=e.left+(e.right-e.left)/2,O="bottom"===i.position?e.bottom-R-M.bottom:e.top+R+M.top;else{var L="left"===i.position;I=L?e.left+R+M.top:e.right-R-M.top,O=e.top+(e.bottom-e.top)/2,F=L?-.5*Math.PI:.5*Math.PI}o.save(),o.translate(I,O),o.rotate(F),o.textAlign="center",o.textBaseline="middle",o.fillStyle=k,o.font=w.font,o.fillText(f.labelString,0,0),o.restore()}if(h.drawBorder){o.lineWidth=s.valueAtIndexOrDefault(h.lineWidth,0),o.strokeStyle=s.valueAtIndexOrDefault(h.color,0);var W=e.left,Y=e.right,N=e.top,z=e.bottom,B=s.aliasPixel(o.lineWidth);m?(N=z="top"===i.position?e.bottom:e.top,N+=B,z+=B):(W=Y="left"===i.position?e.right:e.left,W+=B,Y+=B),o.beginPath(),o.moveTo(W,N),o.lineTo(Y,z),o.stroke()}}}})}},{25:25,26:26,34:34,45:45}],33:[function(t,e,n){"use strict";var i=t(25),a=t(45);e.exports=function(t){t.scaleService={constructors:{},defaults:{},registerScaleType:function(t,e,n){this.constructors[t]=e,this.defaults[t]=a.clone(n)},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0},getScaleDefaults:function(t){return this.defaults.hasOwnProperty(t)?a.merge({},[i.scale,this.defaults[t]]):{}},updateScaleDefaults:function(t,e){var n=this;n.defaults.hasOwnProperty(t)&&(n.defaults[t]=a.extend(n.defaults[t],e))},addScalesToLayout:function(e){a.each(e.scales,function(n){n.fullWidth=n.options.fullWidth,n.position=n.options.position,n.weight=n.options.weight,t.layoutService.addBox(e,n)})}}}},{25:25,45:45}],34:[function(t,e,n){"use strict";var i=t(45);e.exports={generators:{linear:function(t,e){var n,a=[];if(t.stepSize&&t.stepSize>0)n=t.stepSize;else{var r=i.niceNum(e.max-e.min,!1);n=i.niceNum(r/(t.maxTicks-1),!0)}var o=Math.floor(e.min/n)*n,s=Math.ceil(e.max/n)*n;t.min&&t.max&&t.stepSize&&i.almostWhole((t.max-t.min)/t.stepSize,n/1e3)&&(o=t.min,s=t.max);var l=(s-o)/n;l=i.almostEquals(l,Math.round(l),n/1e3)?Math.round(l):Math.ceil(l),a.push(void 0!==t.min?t.min:o);for(var u=1;u<l;++u)a.push(o+u*n);return a.push(void 0!==t.max?t.max:s),a},logarithmic:function(t,e){var n,a,r=[],o=i.valueOrDefault,s=o(t.min,Math.pow(10,Math.floor(i.log10(e.min)))),l=Math.floor(i.log10(e.max)),u=Math.ceil(e.max/Math.pow(10,l));0===s?(n=Math.floor(i.log10(e.minNotZero)),a=Math.floor(e.minNotZero/Math.pow(10,n)),r.push(s),s=a*Math.pow(10,n)):(n=Math.floor(i.log10(s)),a=Math.floor(s/Math.pow(10,n)));do{r.push(s),10===++a&&(a=1,++n),s=a*Math.pow(10,n)}while(n<l||n===l&&a<u);var d=o(t.max,s);return r.push(d),r}},formatters:{values:function(t){return i.isArray(t)?t:""+t},linear:function(t,e,n){var a=n.length>3?n[2]-n[1]:n[1]-n[0];Math.abs(a)>1&&t!==Math.floor(t)&&(a=t-Math.floor(t));var r=i.log10(Math.abs(a)),o="";if(0!==t){var s=-1*Math.floor(r);s=Math.max(Math.min(s,20),0),o=t.toFixed(s)}else o="0";return o},logarithmic:function(t,e,n){var a=t/Math.pow(10,Math.floor(i.log10(t)));return 0===t?"0":1===a||2===a||5===a||0===e||e===n.length-1?t.toExponential():""}}}},{45:45}],35:[function(t,e,n){"use strict";var i=t(25),a=t(26),r=t(45);i._set("global",{tooltips:{enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFontStyle:"bold",titleSpacing:2,titleMarginBottom:6,titleFontColor:"#fff",titleAlign:"left",bodySpacing:2,bodyFontColor:"#fff",bodyAlign:"left",footerFontStyle:"bold",footerSpacing:2,footerMarginTop:6,footerFontColor:"#fff",footerAlign:"left",yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,callbacks:{beforeTitle:r.noop,title:function(t,e){var n="",i=e.labels,a=i?i.length:0;if(t.length>0){var r=t[0];r.xLabel?n=r.xLabel:a>0&&r.index<a&&(n=i[r.index])}return n},afterTitle:r.noop,beforeBody:r.noop,beforeLabel:r.noop,label:function(t,e){var n=e.datasets[t.datasetIndex].label||"";return n&&(n+=": "),n+=t.yLabel},labelColor:function(t,e){var n=e.getDatasetMeta(t.datasetIndex).data[t.index]._view;return{borderColor:n.borderColor,backgroundColor:n.backgroundColor}},labelTextColor:function(){return this._options.bodyFontColor},afterLabel:r.noop,afterBody:r.noop,beforeFooter:r.noop,footer:r.noop,afterFooter:r.noop}}}),e.exports=function(t){function e(t,e){var n=r.color(t);return n.alpha(e*n.alpha()).rgbaString()}function n(t,e){return e&&(r.isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function o(t){var e=t._xScale,n=t._yScale||t._scale,i=t._index,a=t._datasetIndex;return{xLabel:e?e.getLabelForIndex(i,a):"",yLabel:n?n.getLabelForIndex(i,a):"",index:i,datasetIndex:a,x:t._model.x,y:t._model.y}}function s(t){var e=i.global,n=r.valueOrDefault;return{xPadding:t.xPadding,yPadding:t.yPadding,xAlign:t.xAlign,yAlign:t.yAlign,bodyFontColor:t.bodyFontColor,_bodyFontFamily:n(t.bodyFontFamily,e.defaultFontFamily),_bodyFontStyle:n(t.bodyFontStyle,e.defaultFontStyle),_bodyAlign:t.bodyAlign,bodyFontSize:n(t.bodyFontSize,e.defaultFontSize),bodySpacing:t.bodySpacing,titleFontColor:t.titleFontColor,_titleFontFamily:n(t.titleFontFamily,e.defaultFontFamily),_titleFontStyle:n(t.titleFontStyle,e.defaultFontStyle),titleFontSize:n(t.titleFontSize,e.defaultFontSize),_titleAlign:t.titleAlign,titleSpacing:t.titleSpacing,titleMarginBottom:t.titleMarginBottom,footerFontColor:t.footerFontColor,_footerFontFamily:n(t.footerFontFamily,e.defaultFontFamily),_footerFontStyle:n(t.footerFontStyle,e.defaultFontStyle),footerFontSize:n(t.footerFontSize,e.defaultFontSize),_footerAlign:t.footerAlign,footerSpacing:t.footerSpacing,footerMarginTop:t.footerMarginTop,caretSize:t.caretSize,cornerRadius:t.cornerRadius,backgroundColor:t.backgroundColor,opacity:0,legendColorBackground:t.multiKeyBackground,displayColors:t.displayColors,borderColor:t.borderColor,borderWidth:t.borderWidth}}function l(t,e){var n=t._chart.ctx,i=2*e.yPadding,a=0,o=e.body,s=o.reduce(function(t,e){return t+e.before.length+e.lines.length+e.after.length},0);s+=e.beforeBody.length+e.afterBody.length;var l=e.title.length,u=e.footer.length,d=e.titleFontSize,c=e.bodyFontSize,h=e.footerFontSize;i+=l*d,i+=l?(l-1)*e.titleSpacing:0,i+=l?e.titleMarginBottom:0,i+=s*c,i+=s?(s-1)*e.bodySpacing:0,i+=u?e.footerMarginTop:0,i+=u*h,i+=u?(u-1)*e.footerSpacing:0;var f=0,g=function(t){a=Math.max(a,n.measureText(t).width+f)};return n.font=r.fontString(d,e._titleFontStyle,e._titleFontFamily),r.each(e.title,g),n.font=r.fontString(c,e._bodyFontStyle,e._bodyFontFamily),r.each(e.beforeBody.concat(e.afterBody),g),f=e.displayColors?c+2:0,r.each(o,function(t){r.each(t.before,g),r.each(t.lines,g),r.each(t.after,g)}),f=0,n.font=r.fontString(h,e._footerFontStyle,e._footerFontFamily),r.each(e.footer,g),a+=2*e.xPadding,{width:a,height:i}}function u(t,e){var n=t._model,i=t._chart,a=t._chart.chartArea,r="center",o="center";n.y<e.height?o="top":n.y>i.height-e.height&&(o="bottom");var s,l,u,d,c,h=(a.left+a.right)/2,f=(a.top+a.bottom)/2;"center"===o?(s=function(t){return t<=h},l=function(t){return t>h}):(s=function(t){return t<=e.width/2},l=function(t){return t>=i.width-e.width/2}),u=function(t){return t+e.width>i.width},d=function(t){return t-e.width<0},c=function(t){return t<=f?"top":"bottom"},s(n.x)?(r="left",u(n.x)&&(r="center",o=c(n.y))):l(n.x)&&(r="right",d(n.x)&&(r="center",o=c(n.y)));var g=t._options;return{xAlign:g.xAlign?g.xAlign:r,yAlign:g.yAlign?g.yAlign:o}}function d(t,e,n){var i=t.x,a=t.y,r=t.caretSize,o=t.caretPadding,s=t.cornerRadius,l=n.xAlign,u=n.yAlign,d=r+o,c=s+o;return"right"===l?i-=e.width:"center"===l&&(i-=e.width/2),"top"===u?a+=d:a-="bottom"===u?e.height+d:e.height/2,"center"===u?"left"===l?i+=d:"right"===l&&(i-=d):"left"===l?i-=c:"right"===l&&(i+=c),{x:i,y:a}}t.Tooltip=a.extend({initialize:function(){this._model=s(this._options),this._lastActive=[]},getTitle:function(){var t=this,e=t._options.callbacks,i=e.beforeTitle.apply(t,arguments),a=e.title.apply(t,arguments),r=e.afterTitle.apply(t,arguments),o=[];return o=n(o,i),o=n(o,a),o=n(o,r)},getBeforeBody:function(){var t=this._options.callbacks.beforeBody.apply(this,arguments);return r.isArray(t)?t:void 0!==t?[t]:[]},getBody:function(t,e){var i=this,a=i._options.callbacks,o=[];return r.each(t,function(t){var r={before:[],lines:[],after:[]};n(r.before,a.beforeLabel.call(i,t,e)),n(r.lines,a.label.call(i,t,e)),n(r.after,a.afterLabel.call(i,t,e)),o.push(r)}),o},getAfterBody:function(){var t=this._options.callbacks.afterBody.apply(this,arguments);return r.isArray(t)?t:void 0!==t?[t]:[]},getFooter:function(){var t=this,e=t._options.callbacks,i=e.beforeFooter.apply(t,arguments),a=e.footer.apply(t,arguments),r=e.afterFooter.apply(t,arguments),o=[];return o=n(o,i),o=n(o,a),o=n(o,r)},update:function(e){var n,i,a=this,c=a._options,h=a._model,f=a._model=s(c),g=a._active,m=a._data,p={xAlign:h.xAlign,yAlign:h.yAlign},v={x:h.x,y:h.y},y={width:h.width,height:h.height},b={x:h.caretX,y:h.caretY};if(g.length){f.opacity=1;var x=[],_=[];b=t.Tooltip.positioners[c.position].call(a,g,a._eventPosition);var k=[];for(n=0,i=g.length;n<i;++n)k.push(o(g[n]));c.filter&&(k=k.filter(function(t){return c.filter(t,m)})),c.itemSort&&(k=k.sort(function(t,e){return c.itemSort(t,e,m)})),r.each(k,function(t){x.push(c.callbacks.labelColor.call(a,t,a._chart)),_.push(c.callbacks.labelTextColor.call(a,t,a._chart))}),f.title=a.getTitle(k,m),f.beforeBody=a.getBeforeBody(k,m),f.body=a.getBody(k,m),f.afterBody=a.getAfterBody(k,m),f.footer=a.getFooter(k,m),f.x=Math.round(b.x),f.y=Math.round(b.y),f.caretPadding=c.caretPadding,f.labelColors=x,f.labelTextColors=_,f.dataPoints=k,v=d(f,y=l(this,f),p=u(this,y))}else f.opacity=0;return f.xAlign=p.xAlign,f.yAlign=p.yAlign,f.x=v.x,f.y=v.y,f.width=y.width,f.height=y.height,f.caretX=b.x,f.caretY=b.y,a._model=f,e&&c.custom&&c.custom.call(a,f),a},drawCaret:function(t,e){var n=this._chart.ctx,i=this._view,a=this.getCaretPosition(t,e,i);n.lineTo(a.x1,a.y1),n.lineTo(a.x2,a.y2),n.lineTo(a.x3,a.y3)},getCaretPosition:function(t,e,n){var i,a,r,o,s,l,u=n.caretSize,d=n.cornerRadius,c=n.xAlign,h=n.yAlign,f=t.x,g=t.y,m=e.width,p=e.height;if("center"===h)s=g+p/2,"left"===c?(a=(i=f)-u,r=i,o=s+u,l=s-u):(a=(i=f+m)+u,r=i,o=s-u,l=s+u);else if("left"===c?(i=(a=f+d+u)-u,r=a+u):"right"===c?(i=(a=f+m-d-u)-u,r=a+u):(i=(a=f+m/2)-u,r=a+u),"top"===h)s=(o=g)-u,l=o;else{s=(o=g+p)+u,l=o;var v=r;r=i,i=v}return{x1:i,x2:a,x3:r,y1:o,y2:s,y3:l}},drawTitle:function(t,n,i,a){var o=n.title;if(o.length){i.textAlign=n._titleAlign,i.textBaseline="top";var s=n.titleFontSize,l=n.titleSpacing;i.fillStyle=e(n.titleFontColor,a),i.font=r.fontString(s,n._titleFontStyle,n._titleFontFamily);var u,d;for(u=0,d=o.length;u<d;++u)i.fillText(o[u],t.x,t.y),t.y+=s+l,u+1===o.length&&(t.y+=n.titleMarginBottom-l)}},drawBody:function(t,n,i,a){var o=n.bodyFontSize,s=n.bodySpacing,l=n.body;i.textAlign=n._bodyAlign,i.textBaseline="top",i.font=r.fontString(o,n._bodyFontStyle,n._bodyFontFamily);var u=0,d=function(e){i.fillText(e,t.x+u,t.y),t.y+=o+s};i.fillStyle=e(n.bodyFontColor,a),r.each(n.beforeBody,d);var c=n.displayColors;u=c?o+2:0,r.each(l,function(s,l){var u=e(n.labelTextColors[l],a);i.fillStyle=u,r.each(s.before,d),r.each(s.lines,function(r){c&&(i.fillStyle=e(n.legendColorBackground,a),i.fillRect(t.x,t.y,o,o),i.lineWidth=1,i.strokeStyle=e(n.labelColors[l].borderColor,a),i.strokeRect(t.x,t.y,o,o),i.fillStyle=e(n.labelColors[l].backgroundColor,a),i.fillRect(t.x+1,t.y+1,o-2,o-2),i.fillStyle=u),d(r)}),r.each(s.after,d)}),u=0,r.each(n.afterBody,d),t.y-=s},drawFooter:function(t,n,i,a){var o=n.footer;o.length&&(t.y+=n.footerMarginTop,i.textAlign=n._footerAlign,i.textBaseline="top",i.fillStyle=e(n.footerFontColor,a),i.font=r.fontString(n.footerFontSize,n._footerFontStyle,n._footerFontFamily),r.each(o,function(e){i.fillText(e,t.x,t.y),t.y+=n.footerFontSize+n.footerSpacing}))},drawBackground:function(t,n,i,a,r){i.fillStyle=e(n.backgroundColor,r),i.strokeStyle=e(n.borderColor,r),i.lineWidth=n.borderWidth;var o=n.xAlign,s=n.yAlign,l=t.x,u=t.y,d=a.width,c=a.height,h=n.cornerRadius;i.beginPath(),i.moveTo(l+h,u),"top"===s&&this.drawCaret(t,a),i.lineTo(l+d-h,u),i.quadraticCurveTo(l+d,u,l+d,u+h),"center"===s&&"right"===o&&this.drawCaret(t,a),i.lineTo(l+d,u+c-h),i.quadraticCurveTo(l+d,u+c,l+d-h,u+c),"bottom"===s&&this.drawCaret(t,a),i.lineTo(l+h,u+c),i.quadraticCurveTo(l,u+c,l,u+c-h),"center"===s&&"left"===o&&this.drawCaret(t,a),i.lineTo(l,u+h),i.quadraticCurveTo(l,u,l+h,u),i.closePath(),i.fill(),n.borderWidth>0&&i.stroke()},draw:function(){var t=this._chart.ctx,e=this._view;if(0!==e.opacity){var n={width:e.width,height:e.height},i={x:e.x,y:e.y},a=Math.abs(e.opacity<.001)?0:e.opacity,r=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;this._options.enabled&&r&&(this.drawBackground(i,e,t,n,a),i.x+=e.xPadding,i.y+=e.yPadding,this.drawTitle(i,e,t,a),this.drawBody(i,e,t,a),this.drawFooter(i,e,t,a))}},handleEvent:function(t){var e=this,n=e._options,i=!1;if(e._lastActive=e._lastActive||[],"mouseout"===t.type?e._active=[]:e._active=e._chart.getElementsAtEventForMode(t,n.mode,n),!(i=!r.arrayEquals(e._active,e._lastActive)))return!1;if(e._lastActive=e._active,n.enabled||n.custom){e._eventPosition={x:t.x,y:t.y};var a=e._model;e.update(!0),e.pivot(),i|=a.x!==e._model.x||a.y!==e._model.y}return i}}),t.Tooltip.positioners={average:function(t){if(!t.length)return!1;var e,n,i=0,a=0,r=0;for(e=0,n=t.length;e<n;++e){var o=t[e];if(o&&o.hasValue()){var s=o.tooltipPosition();i+=s.x,a+=s.y,++r}}return{x:Math.round(i/r),y:Math.round(a/r)}},nearest:function(t,e){var n,i,a,o=e.x,s=e.y,l=Number.POSITIVE_INFINITY;for(n=0,i=t.length;n<i;++n){var u=t[n];if(u&&u.hasValue()){var d=u.getCenterPoint(),c=r.distanceBetweenPoints(e,d);c<l&&(l=c,a=u)}}if(a){var h=a.tooltipPosition();o=h.x,s=h.y}return{x:o,y:s}}}}},{25:25,26:26,45:45}],36:[function(t,e,n){"use strict";var i=t(25),a=t(26),r=t(45);i._set("global",{elements:{arc:{backgroundColor:i.global.defaultColor,borderColor:"#fff",borderWidth:2}}}),e.exports=a.extend({inLabelRange:function(t){var e=this._view;return!!e&&Math.pow(t-e.x,2)<Math.pow(e.radius+e.hoverRadius,2)},inRange:function(t,e){var n=this._view;if(n){for(var i=r.getAngleFromPoint(n,{x:t,y:e}),a=i.angle,o=i.distance,s=n.startAngle,l=n.endAngle;l<s;)l+=2*Math.PI;for(;a>l;)a-=2*Math.PI;for(;a<s;)a+=2*Math.PI;var u=a>=s&&a<=l,d=o>=n.innerRadius&&o<=n.outerRadius;return u&&d}return!1},getCenterPoint:function(){var t=this._view,e=(t.startAngle+t.endAngle)/2,n=(t.innerRadius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},getArea:function(){var t=this._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,n=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},draw:function(){var t=this._chart.ctx,e=this._view,n=e.startAngle,i=e.endAngle;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,n,i),t.arc(e.x,e.y,e.innerRadius,i,n,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})},{25:25,26:26,45:45}],37:[function(t,e,n){"use strict";var i=t(25),a=t(26),r=t(45),o=i.global;i._set("global",{elements:{line:{tension:.4,backgroundColor:o.defaultColor,borderWidth:3,borderColor:o.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0}}}),e.exports=a.extend({draw:function(){var t,e,n,i,a=this,s=a._view,l=a._chart.ctx,u=s.spanGaps,d=a._children.slice(),c=o.elements.line,h=-1;for(a._loop&&d.length&&d.push(d[0]),l.save(),l.lineCap=s.borderCapStyle||c.borderCapStyle,l.setLineDash&&l.setLineDash(s.borderDash||c.borderDash),l.lineDashOffset=s.borderDashOffset||c.borderDashOffset,l.lineJoin=s.borderJoinStyle||c.borderJoinStyle,l.lineWidth=s.borderWidth||c.borderWidth,l.strokeStyle=s.borderColor||o.defaultColor,l.beginPath(),h=-1,t=0;t<d.length;++t)e=d[t],n=r.previousItem(d,t),i=e._view,0===t?i.skip||(l.moveTo(i.x,i.y),h=t):(n=-1===h?n:d[h],i.skip||(h!==t-1&&!u||-1===h?l.moveTo(i.x,i.y):r.canvas.lineTo(l,n._view,e._view),h=t));l.stroke(),l.restore()}})},{25:25,26:26,45:45}],38:[function(t,e,n){"use strict";function i(t){var e=this._view;return!!e&&Math.pow(t-e.x,2)<Math.pow(e.radius+e.hitRadius,2)}var a=t(25),r=t(26),o=t(45),s=a.global.defaultColor;a._set("global",{elements:{point:{radius:3,pointStyle:"circle",backgroundColor:s,borderColor:s,borderWidth:1,hitRadius:1,hoverRadius:4,hoverBorderWidth:1}}}),e.exports=r.extend({inRange:function(t,e){var n=this._view;return!!n&&Math.pow(t-n.x,2)+Math.pow(e-n.y,2)<Math.pow(n.hitRadius+n.radius,2)},inLabelRange:i,inXRange:i,inYRange:function(t){var e=this._view;return!!e&&Math.pow(t-e.y,2)<Math.pow(e.radius+e.hitRadius,2)},getCenterPoint:function(){var t=this._view;return{x:t.x,y:t.y}},getArea:function(){return Math.PI*Math.pow(this._view.radius,2)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y,padding:t.radius+t.borderWidth}},draw:function(t){var e=this._view,n=this._model,i=this._chart.ctx,r=e.pointStyle,l=e.radius,u=e.x,d=e.y,c=o.color,h=0;e.skip||(i.strokeStyle=e.borderColor||s,i.lineWidth=o.valueOrDefault(e.borderWidth,a.global.elements.point.borderWidth),i.fillStyle=e.backgroundColor||s,void 0!==t&&(n.x<t.left||1.01*t.right<n.x||n.y<t.top||1.01*t.bottom<n.y)&&(n.x<t.left?h=(u-n.x)/(t.left-n.x):1.01*t.right<n.x?h=(n.x-u)/(n.x-t.right):n.y<t.top?h=(d-n.y)/(t.top-n.y):1.01*t.bottom<n.y&&(h=(n.y-d)/(n.y-t.bottom)),h=Math.round(100*h)/100,i.strokeStyle=c(i.strokeStyle).alpha(h).rgbString(),i.fillStyle=c(i.fillStyle).alpha(h).rgbString()),o.canvas.drawPoint(i,r,l,u,d))}})},{25:25,26:26,45:45}],39:[function(t,e,n){"use strict";function i(t){return void 0!==t._view.width}function a(t){var e,n,a,r,o=t._view;if(i(t)){var s=o.width/2;e=o.x-s,n=o.x+s,a=Math.min(o.y,o.base),r=Math.max(o.y,o.base)}else{var l=o.height/2;e=Math.min(o.x,o.base),n=Math.max(o.x,o.base),a=o.y-l,r=o.y+l}return{left:e,top:a,right:n,bottom:r}}var r=t(25),o=t(26);r._set("global",{elements:{rectangle:{backgroundColor:r.global.defaultColor,borderColor:r.global.defaultColor,borderSkipped:"bottom",borderWidth:0}}}),e.exports=o.extend({draw:function(){function t(t){return v[(y+t)%4]}var e,n,i,a,r,o,s,l=this._chart.ctx,u=this._view,d=u.borderWidth;if(u.horizontal?(e=u.base,n=u.x,i=u.y-u.height/2,a=u.y+u.height/2,r=n>e?1:-1,o=1,s=u.borderSkipped||"left"):(e=u.x-u.width/2,n=u.x+u.width/2,i=u.y,r=1,o=(a=u.base)>i?1:-1,s=u.borderSkipped||"bottom"),d){var c=Math.min(Math.abs(e-n),Math.abs(i-a)),h=(d=d>c?c:d)/2,f=e+("left"!==s?h*r:0),g=n+("right"!==s?-h*r:0),m=i+("top"!==s?h*o:0),p=a+("bottom"!==s?-h*o:0);f!==g&&(i=m,a=p),m!==p&&(e=f,n=g)}l.beginPath(),l.fillStyle=u.backgroundColor,l.strokeStyle=u.borderColor,l.lineWidth=d;var v=[[e,a],[e,i],[n,i],[n,a]],y=["bottom","left","top","right"].indexOf(s,0);-1===y&&(y=0);var b=t(0);l.moveTo(b[0],b[1]);for(var x=1;x<4;x++)b=t(x),l.lineTo(b[0],b[1]);l.fill(),d&&l.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var n=!1;if(this._view){var i=a(this);n=t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}return n},inLabelRange:function(t,e){var n=this;if(!n._view)return!1;var r=a(n);return i(n)?t>=r.left&&t<=r.right:e>=r.top&&e<=r.bottom},inXRange:function(t){var e=a(this);return t>=e.left&&t<=e.right},inYRange:function(t){var e=a(this);return t>=e.top&&t<=e.bottom},getCenterPoint:function(){var t,e,n=this._view;return i(this)?(t=n.x,e=(n.y+n.base)/2):(t=(n.x+n.base)/2,e=n.y),{x:t,y:e}},getArea:function(){var t=this._view;return t.width*Math.abs(t.y-t.base)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})},{25:25,26:26}],40:[function(t,e,n){"use strict";e.exports={},e.exports.Arc=t(36),e.exports.Line=t(37),e.exports.Point=t(38),e.exports.Rectangle=t(39)},{36:36,37:37,38:38,39:39}],41:[function(t,e,n){"use strict";var i=t(42),n=e.exports={clear:function(t){t.ctx.clearRect(0,0,t.width,t.height)},roundedRect:function(t,e,n,i,a,r){if(r){var o=Math.min(r,i/2),s=Math.min(r,a/2);t.moveTo(e+o,n),t.lineTo(e+i-o,n),t.quadraticCurveTo(e+i,n,e+i,n+s),t.lineTo(e+i,n+a-s),t.quadraticCurveTo(e+i,n+a,e+i-o,n+a),t.lineTo(e+o,n+a),t.quadraticCurveTo(e,n+a,e,n+a-s),t.lineTo(e,n+s),t.quadraticCurveTo(e,n,e+o,n)}else t.rect(e,n,i,a)},drawPoint:function(t,e,n,i,a){var r,o,s,l,u,d;if(!e||"object"!=typeof e||"[object HTMLImageElement]"!==(r=e.toString())&&"[object HTMLCanvasElement]"!==r){if(!(isNaN(n)||n<=0)){switch(e){default:t.beginPath(),t.arc(i,a,n,0,2*Math.PI),t.closePath(),t.fill();break;case"triangle":t.beginPath(),u=(o=3*n/Math.sqrt(3))*Math.sqrt(3)/2,t.moveTo(i-o/2,a+u/3),t.lineTo(i+o/2,a+u/3),t.lineTo(i,a-2*u/3),t.closePath(),t.fill();break;case"rect":d=1/Math.SQRT2*n,t.beginPath(),t.fillRect(i-d,a-d,2*d,2*d),t.strokeRect(i-d,a-d,2*d,2*d);break;case"rectRounded":var c=n/Math.SQRT2,h=i-c,f=a-c,g=Math.SQRT2*n;t.beginPath(),this.roundedRect(t,h,f,g,g,n/2),t.closePath(),t.fill();break;case"rectRot":d=1/Math.SQRT2*n,t.beginPath(),t.moveTo(i-d,a),t.lineTo(i,a+d),t.lineTo(i+d,a),t.lineTo(i,a-d),t.closePath(),t.fill();break;case"cross":t.beginPath(),t.moveTo(i,a+n),t.lineTo(i,a-n),t.moveTo(i-n,a),t.lineTo(i+n,a),t.closePath();break;case"crossRot":t.beginPath(),s=Math.cos(Math.PI/4)*n,l=Math.sin(Math.PI/4)*n,t.moveTo(i-s,a-l),t.lineTo(i+s,a+l),t.moveTo(i-s,a+l),t.lineTo(i+s,a-l),t.closePath();break;case"star":t.beginPath(),t.moveTo(i,a+n),t.lineTo(i,a-n),t.moveTo(i-n,a),t.lineTo(i+n,a),s=Math.cos(Math.PI/4)*n,l=Math.sin(Math.PI/4)*n,t.moveTo(i-s,a-l),t.lineTo(i+s,a+l),t.moveTo(i-s,a+l),t.lineTo(i+s,a-l),t.closePath();break;case"line":t.beginPath(),t.moveTo(i-n,a),t.lineTo(i+n,a),t.closePath();break;case"dash":t.beginPath(),t.moveTo(i,a),t.lineTo(i+n,a),t.closePath()}t.stroke()}}else t.drawImage(e,i-e.width/2,a-e.height/2,e.width,e.height)},clipArea:function(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()},unclipArea:function(t){t.restore()},lineTo:function(t,e,n,i){if(n.steppedLine)return"after"===n.steppedLine&&!i||"after"!==n.steppedLine&&i?t.lineTo(e.x,n.y):t.lineTo(n.x,e.y),void t.lineTo(n.x,n.y);n.tension?t.bezierCurveTo(i?e.controlPointPreviousX:e.controlPointNextX,i?e.controlPointPreviousY:e.controlPointNextY,i?n.controlPointNextX:n.controlPointPreviousX,i?n.controlPointNextY:n.controlPointPreviousY,n.x,n.y):t.lineTo(n.x,n.y)}};i.clear=n.clear,i.drawRoundedRectangle=function(t){t.beginPath(),n.roundedRect.apply(n,arguments),t.closePath()}},{42:42}],42:[function(t,e,n){"use strict";var i={noop:function(){},uid:function(){var t=0;return function(){return t++}}(),isNullOrUndef:function(t){return null===t||void 0===t},isArray:Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)},valueOrDefault:function(t,e){return void 0===t?e:t},valueAtIndexOrDefault:function(t,e,n){return i.valueOrDefault(i.isArray(t)?t[e]:t,n)},callback:function(t,e,n){if(t&&"function"==typeof t.call)return t.apply(n,e)},each:function(t,e,n,a){var r,o,s;if(i.isArray(t))if(o=t.length,a)for(r=o-1;r>=0;r--)e.call(n,t[r],r);else for(r=0;r<o;r++)e.call(n,t[r],r);else if(i.isObject(t))for(o=(s=Object.keys(t)).length,r=0;r<o;r++)e.call(n,t[s[r]],s[r])},arrayEquals:function(t,e){var n,a,r,o;if(!t||!e||t.length!==e.length)return!1;for(n=0,a=t.length;n<a;++n)if(r=t[n],o=e[n],r instanceof Array&&o instanceof Array){if(!i.arrayEquals(r,o))return!1}else if(r!==o)return!1;return!0},clone:function(t){if(i.isArray(t))return t.map(i.clone);if(i.isObject(t)){for(var e={},n=Object.keys(t),a=n.length,r=0;r<a;++r)e[n[r]]=i.clone(t[n[r]]);return e}return t},_merger:function(t,e,n,a){var r=e[t],o=n[t];i.isObject(r)&&i.isObject(o)?i.merge(r,o,a):e[t]=i.clone(o)},_mergerIf:function(t,e,n){var a=e[t],r=n[t];i.isObject(a)&&i.isObject(r)?i.mergeIf(a,r):e.hasOwnProperty(t)||(e[t]=i.clone(r))},merge:function(t,e,n){var a,r,o,s,l,u=i.isArray(e)?e:[e],d=u.length;if(!i.isObject(t))return t;for(a=(n=n||{}).merger||i._merger,r=0;r<d;++r)if(e=u[r],i.isObject(e))for(l=0,s=(o=Object.keys(e)).length;l<s;++l)a(o[l],t,e,n);return t},mergeIf:function(t,e){return i.merge(t,e,{merger:i._mergerIf})},extend:function(t){for(var e=1,n=arguments.length;e<n;++e)i.each(arguments[e],function(e,n){t[n]=e});return t},inherits:function(t){var e=this,n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=n};return a.prototype=e.prototype,n.prototype=new a,n.extend=i.inherits,t&&i.extend(n.prototype,t),n.__super__=e.prototype,n}};e.exports=i,i.callCallback=i.callback,i.indexOf=function(t,e,n){return Array.prototype.indexOf.call(t,e,n)},i.getValueOrDefault=i.valueOrDefault,i.getValueAtIndexOrDefault=i.valueAtIndexOrDefault},{}],43:[function(t,e,n){"use strict";var i=t(42),a={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return(t-=1)*t*t+1},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-((t-=1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return(t-=1)*t*t*t*t+1},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return 1-Math.cos(t*(Math.PI/2))},easeOutSine:function(t){return Math.sin(t*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:1-Math.pow(2,-10*t)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t))},easeInCirc:function(t){return t>=1?t:-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-(t-=1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e=1.70158,n=0,i=1;return 0===t?0:1===t?1:(n||(n=.3),i<1?(i=1,e=n/4):e=n/(2*Math.PI)*Math.asin(1/i),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n))},easeOutElastic:function(t){var e=1.70158,n=0,i=1;return 0===t?0:1===t?1:(n||(n=.3),i<1?(i=1,e=n/4):e=n/(2*Math.PI)*Math.asin(1/i),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},easeInOutElastic:function(t){var e=1.70158,n=0,i=1;return 0===t?0:2==(t/=.5)?1:(n||(n=.45),i<1?(i=1,e=n/4):e=n/(2*Math.PI)*Math.asin(1/i),t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},easeInBack:function(t){var e=1.70158;return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:function(t){return 1-a.easeOutBounce(1-t)},easeOutBounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInOutBounce:function(t){return t<.5?.5*a.easeInBounce(2*t):.5*a.easeOutBounce(2*t-1)+.5}};e.exports={effects:a},i.easingEffects=a},{42:42}],44:[function(t,e,n){"use strict";var i=t(42);e.exports={toLineHeight:function(t,e){var n=(""+t).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);if(!n||"normal"===n[1])return 1.2*e;switch(t=+n[2],n[3]){case"px":return t;case"%":t/=100}return e*t},toPadding:function(t){var e,n,a,r;return i.isObject(t)?(e=+t.top||0,n=+t.right||0,a=+t.bottom||0,r=+t.left||0):e=n=a=r=+t||0,{top:e,right:n,bottom:a,left:r,height:e+a,width:r+n}},resolve:function(t,e,n){var a,r,o;for(a=0,r=t.length;a<r;++a)if(void 0!==(o=t[a])&&(void 0!==e&&"function"==typeof o&&(o=o(e)),void 0!==n&&i.isArray(o)&&(o=o[n]),void 0!==o))return o}}},{42:42}],45:[function(t,e,n){"use strict";e.exports=t(42),e.exports.easing=t(43),e.exports.canvas=t(41),e.exports.options=t(44)},{41:41,42:42,43:43,44:44}],46:[function(t,e,n){e.exports={acquireContext:function(t){return t&&t.canvas&&(t=t.canvas),t&&t.getContext("2d")||null}}},{}],47:[function(t,e,n){"use strict";function i(t,e){var n=p.getStyle(t,e),i=n&&n.match(/^(\d+)(\.\d+)?px$/);return i?Number(i[1]):void 0}function a(t,e){var n=t.style,a=t.getAttribute("height"),r=t.getAttribute("width");if(t[v]={initial:{height:a,width:r,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",null===r||""===r){var o=i(t,"width");void 0!==o&&(t.width=o)}if(null===a||""===a)if(""===t.style.height)t.height=t.width/(e.options.aspectRatio||2);else{var s=i(t,"height");void 0!==o&&(t.height=s)}return t}function r(t,e,n){t.addEventListener(e,n,w)}function o(t,e,n){t.removeEventListener(e,n,w)}function s(t,e,n,i,a){return{type:t,chart:e,native:a||null,x:void 0!==n?n:null,y:void 0!==i?i:null}}function l(t,e){var n=k[t.type]||t.type,i=p.getRelativePosition(t,e);return s(n,e,i.x,i.y,t)}function u(t,e){var n=!1,i=[];return function(){i=Array.prototype.slice.call(arguments),e=e||this,n||(n=!0,p.requestAnimFrame.call(window,function(){n=!1,t.apply(e,i)}))}}function d(t){var e=document.createElement("div"),n=y+"size-monitor",i="position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1;";e.style.cssText=i,e.className=n,e.innerHTML='<div class="'+n+'-expand" style="'+i+'"><div style="position:absolute;width:1000000px;height:1000000px;left:0;top:0"></div></div><div class="'+n+'-shrink" style="'+i+'"><div style="position:absolute;width:200%;height:200%;left:0; top:0"></div></div>';var a=e.childNodes[0],o=e.childNodes[1];e._reset=function(){a.scrollLeft=1e6,a.scrollTop=1e6,o.scrollLeft=1e6,o.scrollTop=1e6};var s=function(){e._reset(),t()};return r(a,"scroll",s.bind(a,"expand")),r(o,"scroll",s.bind(o,"shrink")),e}function c(t,e){var n=t[v]||(t[v]={}),i=n.renderProxy=function(t){t.animationName===x&&e()};p.each(_,function(e){r(t,e,i)}),n.reflow=!!t.offsetParent,t.classList.add(b)}function h(t){var e=t[v]||{},n=e.renderProxy;n&&(p.each(_,function(e){o(t,e,n)}),delete e.renderProxy),t.classList.remove(b)}function f(t,e,n){var i=t[v]||(t[v]={}),a=i.resizer=d(u(function(){if(i.resizer)return e(s("resize",n))}));c(t,function(){if(i.resizer){var e=t.parentNode;e&&e!==a.parentNode&&e.insertBefore(a,e.firstChild),a._reset()}})}function g(t){var e=t[v]||{},n=e.resizer;delete e.resizer,h(t),n&&n.parentNode&&n.parentNode.removeChild(n)}function m(t,e){var n=t._style||document.createElement("style");t._style||(t._style=n,e="/* Chart.js */\n"+e,n.setAttribute("type","text/css"),document.getElementsByTagName("head")[0].appendChild(n)),n.appendChild(document.createTextNode(e))}var p=t(45),v="$chartjs",y="chartjs-",b=y+"render-monitor",x=y+"render-animation",_=["animationstart","webkitAnimationStart"],k={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},w=!!function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("e",null,e)}catch(t){}return t}()&&{passive:!0};e.exports={_enabled:"undefined"!=typeof window&&"undefined"!=typeof document,initialize:function(){var t="from{opacity:0.99}to{opacity:1}";m(this,"@-webkit-keyframes "+x+"{"+t+"}@keyframes "+x+"{"+t+"}."+b+"{-webkit-animation:"+x+" 0.001s;animation:"+x+" 0.001s;}")},acquireContext:function(t,e){"string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas);var n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(a(t,e),n):null},releaseContext:function(t){var e=t.canvas;if(e[v]){var n=e[v].initial;["height","width"].forEach(function(t){var i=n[t];p.isNullOrUndef(i)?e.removeAttribute(t):e.setAttribute(t,i)}),p.each(n.style||{},function(t,n){e.style[n]=t}),e.width=e.width,delete e[v]}},addEventListener:function(t,e,n){var i=t.canvas;if("resize"!==e){var a=n[v]||(n[v]={});r(i,e,(a.proxies||(a.proxies={}))[t.id+"_"+e]=function(e){n(l(e,t))})}else f(i,n,t)},removeEventListener:function(t,e,n){var i=t.canvas;if("resize"!==e){var a=((n[v]||{}).proxies||{})[t.id+"_"+e];a&&o(i,e,a)}else g(i)}},p.addEvent=r,p.removeEvent=o},{45:45}],48:[function(t,e,n){"use strict";var i=t(45),a=t(46),r=t(47),o=r._enabled?r:a;e.exports=i.extend({initialize:function(){},acquireContext:function(){},releaseContext:function(){},addEventListener:function(){},removeEventListener:function(){}},o)},{45:45,46:46,47:47}],49:[function(t,e,n){"use strict";var i=t(25),a=t(40),r=t(45);i._set("global",{plugins:{filler:{propagate:!0}}}),e.exports=function(){function t(t,e,n){var i,a=t._model||{},r=a.fill;if(void 0===r&&(r=!!a.backgroundColor),!1===r||null===r)return!1;if(!0===r)return"origin";if(i=parseFloat(r,10),isFinite(i)&&Math.floor(i)===i)return"-"!==r[0]&&"+"!==r[0]||(i=e+i),!(i===e||i<0||i>=n)&&i;switch(r){case"bottom":return"start";case"top":return"end";case"zero":return"origin";case"origin":case"start":case"end":return r;default:return!1}}function e(t){var e,n=t.el._model||{},i=t.el._scale||{},a=t.fill,r=null;if(isFinite(a))return null;if("start"===a?r=void 0===n.scaleBottom?i.bottom:n.scaleBottom:"end"===a?r=void 0===n.scaleTop?i.top:n.scaleTop:void 0!==n.scaleZero?r=n.scaleZero:i.getBasePosition?r=i.getBasePosition():i.getBasePixel&&(r=i.getBasePixel()),void 0!==r&&null!==r){if(void 0!==r.x&&void 0!==r.y)return r;if("number"==typeof r&&isFinite(r))return e=i.isHorizontal(),{x:e?r:null,y:e?null:r}}return null}function n(t,e,n){var i,a=t[e].fill,r=[e];if(!n)return a;for(;!1!==a&&-1===r.indexOf(a);){if(!isFinite(a))return a;if(!(i=t[a]))return!1;if(i.visible)return a;r.push(a),a=i.fill}return!1}function o(t){var e=t.fill,n="dataset";return!1===e?null:(isFinite(e)||(n="boundary"),d[n](t))}function s(t){return t&&!t.skip}function l(t,e,n,i,a){var o;if(i&&a){for(t.moveTo(e[0].x,e[0].y),o=1;o<i;++o)r.canvas.lineTo(t,e[o-1],e[o]);for(t.lineTo(n[a-1].x,n[a-1].y),o=a-1;o>0;--o)r.canvas.lineTo(t,n[o],n[o-1],!0)}}function u(t,e,n,i,a,r){var o,u,d,c,h,f,g,m=e.length,p=i.spanGaps,v=[],y=[],b=0,x=0;for(t.beginPath(),o=0,u=m+!!r;o<u;++o)h=n(c=e[d=o%m]._view,d,i),f=s(c),g=s(h),f&&g?(b=v.push(c),x=y.push(h)):b&&x&&(p?(f&&v.push(c),g&&y.push(h)):(l(t,v,y,b,x),b=x=0,v=[],y=[]));l(t,v,y,b,x),t.closePath(),t.fillStyle=a,t.fill()}var d={dataset:function(t){var e=t.fill,n=t.chart,i=n.getDatasetMeta(e),a=i&&n.isDatasetVisible(e)&&i.dataset._children||[],r=a.length||0;return r?function(t,e){return e<r&&a[e]._view||null}:null},boundary:function(t){var e=t.boundary,n=e?e.x:null,i=e?e.y:null;return function(t){return{x:null===n?t.x:n,y:null===i?t.y:i}}}};return{id:"filler",afterDatasetsUpdate:function(i,r){var s,l,u,d,c=(i.data.datasets||[]).length,h=r.propagate,f=[];for(l=0;l<c;++l)d=null,(u=(s=i.getDatasetMeta(l)).dataset)&&u._model&&u instanceof a.Line&&(d={visible:i.isDatasetVisible(l),fill:t(u,l,c),chart:i,el:u}),s.$filler=d,f.push(d);for(l=0;l<c;++l)(d=f[l])&&(d.fill=n(f,l,h),d.boundary=e(d),d.mapper=o(d))},beforeDatasetDraw:function(t,e){var n=e.meta.$filler;if(n){var a=t.ctx,o=n.el,s=o._view,l=o._children||[],d=n.mapper,c=s.backgroundColor||i.global.defaultColor;d&&c&&l.length&&(r.canvas.clipArea(a,t.chartArea),u(a,l,d,s,c,o._loop),r.canvas.unclipArea(a))}}}}},{25:25,40:40,45:45}],50:[function(t,e,n){"use strict";var i=t(25),a=t(26),r=t(45);i._set("global",{legend:{display:!0,position:"top",fullWidth:!0,reverse:!1,weight:1e3,onClick:function(t,e){var n=e.datasetIndex,i=this.chart,a=i.getDatasetMeta(n);a.hidden=null===a.hidden?!i.data.datasets[n].hidden:null,i.update()},onHover:null,labels:{boxWidth:40,padding:10,generateLabels:function(t){var e=t.data;return r.isArray(e.datasets)?e.datasets.map(function(e,n){return{text:e.label,fillStyle:r.isArray(e.backgroundColor)?e.backgroundColor[0]:e.backgroundColor,hidden:!t.isDatasetVisible(n),lineCap:e.borderCapStyle,lineDash:e.borderDash,lineDashOffset:e.borderDashOffset,lineJoin:e.borderJoinStyle,lineWidth:e.borderWidth,strokeStyle:e.borderColor,pointStyle:e.pointStyle,datasetIndex:n}},this):[]}}},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');for(var n=0;n<t.data.datasets.length;n++)e.push('<li><span style="background-color:'+t.data.datasets[n].backgroundColor+'"></span>'),t.data.datasets[n].label&&e.push(t.data.datasets[n].label),e.push("</li>");return e.push("</ul>"),e.join("")}}),e.exports=function(t){function e(t,e){return t.usePointStyle?e*Math.SQRT2:t.boxWidth}function n(e,n){var i=new t.Legend({ctx:e.ctx,options:n,chart:e});o.configure(e,i,n),o.addBox(e,i),e.legend=i}var o=t.layoutService,s=r.noop;return t.Legend=a.extend({initialize:function(t){r.extend(this,t),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:s,update:function(t,e,n){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=n,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:s,beforeSetDimensions:s,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:s,beforeBuildLabels:s,buildLabels:function(){var t=this,e=t.options.labels||{},n=r.callback(e.generateLabels,[t.chart],t)||[];e.filter&&(n=n.filter(function(n){return e.filter(n,t.chart.data)})),t.options.reverse&&n.reverse(),t.legendItems=n},afterBuildLabels:s,beforeFit:s,fit:function(){var t=this,n=t.options,a=n.labels,o=n.display,s=t.ctx,l=i.global,u=r.valueOrDefault,d=u(a.fontSize,l.defaultFontSize),c=u(a.fontStyle,l.defaultFontStyle),h=u(a.fontFamily,l.defaultFontFamily),f=r.fontString(d,c,h),g=t.legendHitBoxes=[],m=t.minSize,p=t.isHorizontal();if(p?(m.width=t.maxWidth,m.height=o?10:0):(m.width=o?10:0,m.height=t.maxHeight),o)if(s.font=f,p){var v=t.lineWidths=[0],y=t.legendItems.length?d+a.padding:0;s.textAlign="left",s.textBaseline="top",r.each(t.legendItems,function(n,i){var r=e(a,d)+d/2+s.measureText(n.text).width;v[v.length-1]+r+a.padding>=t.width&&(y+=d+a.padding,v[v.length]=t.left),g[i]={left:0,top:0,width:r,height:d},v[v.length-1]+=r+a.padding}),m.height+=y}else{var b=a.padding,x=t.columnWidths=[],_=a.padding,k=0,w=0,M=d+b;r.each(t.legendItems,function(t,n){var i=e(a,d)+d/2+s.measureText(t.text).width;w+M>m.height&&(_+=k+a.padding,x.push(k),k=0,w=0),k=Math.max(k,i),w+=M,g[n]={left:0,top:0,width:i,height:d}}),_+=k,x.push(k),m.width+=_}t.width=m.width,t.height=m.height},afterFit:s,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var t=this,n=t.options,a=n.labels,o=i.global,s=o.elements.line,l=t.width,u=t.lineWidths;if(n.display){var d,c=t.ctx,h=r.valueOrDefault,f=h(a.fontColor,o.defaultFontColor),g=h(a.fontSize,o.defaultFontSize),m=h(a.fontStyle,o.defaultFontStyle),p=h(a.fontFamily,o.defaultFontFamily),v=r.fontString(g,m,p);c.textAlign="left",c.textBaseline="middle",c.lineWidth=.5,c.strokeStyle=f,c.fillStyle=f,c.font=v;var y=e(a,g),b=t.legendHitBoxes,x=function(t,e,i){if(!(isNaN(y)||y<=0)){c.save(),c.fillStyle=h(i.fillStyle,o.defaultColor),c.lineCap=h(i.lineCap,s.borderCapStyle),c.lineDashOffset=h(i.lineDashOffset,s.borderDashOffset),c.lineJoin=h(i.lineJoin,s.borderJoinStyle),c.lineWidth=h(i.lineWidth,s.borderWidth),c.strokeStyle=h(i.strokeStyle,o.defaultColor);var a=0===h(i.lineWidth,s.borderWidth);if(c.setLineDash&&c.setLineDash(h(i.lineDash,s.borderDash)),n.labels&&n.labels.usePointStyle){var l=g*Math.SQRT2/2,u=l/Math.SQRT2,d=t+u,f=e+u;r.canvas.drawPoint(c,i.pointStyle,l,d,f)}else a||c.strokeRect(t,e,y,g),c.fillRect(t,e,y,g);c.restore()}},_=function(t,e,n,i){var a=g/2,r=y+a+t,o=e+a;c.fillText(n.text,r,o),n.hidden&&(c.beginPath(),c.lineWidth=2,c.moveTo(r,o),c.lineTo(r+i,o),c.stroke())},k=t.isHorizontal();d=k?{x:t.left+(l-u[0])/2,y:t.top+a.padding,line:0}:{x:t.left+a.padding,y:t.top+a.padding,line:0};var w=g+a.padding;r.each(t.legendItems,function(e,n){var i=c.measureText(e.text).width,r=y+g/2+i,o=d.x,s=d.y;k?o+r>=l&&(s=d.y+=w,d.line++,o=d.x=t.left+(l-u[d.line])/2):s+w>t.bottom&&(o=d.x=o+t.columnWidths[d.line]+a.padding,s=d.y=t.top+a.padding,d.line++),x(o,s,e),b[n].left=o,b[n].top=s,_(o,s,e,i),k?d.x+=r+a.padding:d.y+=w})}},handleEvent:function(t){var e=this,n=e.options,i="mouseup"===t.type?"click":t.type,a=!1;if("mousemove"===i){if(!n.onHover)return}else{if("click"!==i)return;if(!n.onClick)return}var r=t.x,o=t.y;if(r>=e.left&&r<=e.right&&o>=e.top&&o<=e.bottom)for(var s=e.legendHitBoxes,l=0;l<s.length;++l){var u=s[l];if(r>=u.left&&r<=u.left+u.width&&o>=u.top&&o<=u.top+u.height){if("click"===i){n.onClick.call(e,t.native,e.legendItems[l]),a=!0;break}if("mousemove"===i){n.onHover.call(e,t.native,e.legendItems[l]),a=!0;break}}}return a}}),{id:"legend",beforeInit:function(t){var e=t.options.legend;e&&n(t,e)},beforeUpdate:function(t){var e=t.options.legend,a=t.legend;e?(r.mergeIf(e,i.global.legend),a?(o.configure(t,a,e),a.options=e):n(t,e)):a&&(o.removeBox(t,a),delete t.legend)},afterEvent:function(t,e){var n=t.legend;n&&n.handleEvent(e)}}}},{25:25,26:26,45:45}],51:[function(t,e,n){"use strict";var i=t(25),a=t(26),r=t(45);i._set("global",{title:{display:!1,fontStyle:"bold",fullWidth:!0,lineHeight:1.2,padding:10,position:"top",text:"",weight:2e3}}),e.exports=function(t){function e(e,i){var a=new t.Title({ctx:e.ctx,options:i,chart:e});n.configure(e,a,i),n.addBox(e,a),e.titleBlock=a}var n=t.layoutService,o=r.noop;return t.Title=a.extend({initialize:function(t){var e=this;r.extend(e,t),e.legendHitBoxes=[]},beforeUpdate:o,update:function(t,e,n){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=n,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:o,beforeSetDimensions:o,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:o,beforeBuildLabels:o,buildLabels:o,afterBuildLabels:o,beforeFit:o,fit:function(){var t=this,e=r.valueOrDefault,n=t.options,a=n.display,o=e(n.fontSize,i.global.defaultFontSize),s=t.minSize,l=r.isArray(n.text)?n.text.length:1,u=r.options.toLineHeight(n.lineHeight,o),d=a?l*u+2*n.padding:0;t.isHorizontal()?(s.width=t.maxWidth,s.height=d):(s.width=d,s.height=t.maxHeight),t.width=s.width,t.height=s.height},afterFit:o,isHorizontal:function(){var t=this.options.position;return"top"===t||"bottom"===t},draw:function(){var t=this,e=t.ctx,n=r.valueOrDefault,a=t.options,o=i.global;if(a.display){var s,l,u,d=n(a.fontSize,o.defaultFontSize),c=n(a.fontStyle,o.defaultFontStyle),h=n(a.fontFamily,o.defaultFontFamily),f=r.fontString(d,c,h),g=r.options.toLineHeight(a.lineHeight,d),m=g/2+a.padding,p=0,v=t.top,y=t.left,b=t.bottom,x=t.right;e.fillStyle=n(a.fontColor,o.defaultFontColor),e.font=f,t.isHorizontal()?(l=y+(x-y)/2,u=v+m,s=x-y):(l="left"===a.position?y+m:x-m,u=v+(b-v)/2,s=b-v,p=Math.PI*("left"===a.position?-.5:.5)),e.save(),e.translate(l,u),e.rotate(p),e.textAlign="center",e.textBaseline="middle";var _=a.text;if(r.isArray(_))for(var k=0,w=0;w<_.length;++w)e.fillText(_[w],0,k,s),k+=g;else e.fillText(_,0,0,s);e.restore()}}}),{id:"title",beforeInit:function(t){var n=t.options.title;n&&e(t,n)},beforeUpdate:function(a){var o=a.options.title,s=a.titleBlock;o?(r.mergeIf(o,i.global.title),s?(n.configure(a,s,o),s.options=o):e(a,o)):s&&(t.layoutService.removeBox(a,s),delete a.titleBlock)}}}},{25:25,26:26,45:45}],52:[function(t,e,n){"use strict";e.exports=function(t){var e=t.Scale.extend({getLabels:function(){var t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels},determineDataLimits:function(){var t=this,e=t.getLabels();t.minIndex=0,t.maxIndex=e.length-1;var n;void 0!==t.options.ticks.min&&(n=e.indexOf(t.options.ticks.min),t.minIndex=-1!==n?n:t.minIndex),void 0!==t.options.ticks.max&&(n=e.indexOf(t.options.ticks.max),t.maxIndex=-1!==n?n:t.maxIndex),t.min=e[t.minIndex],t.max=e[t.maxIndex]},buildTicks:function(){var t=this,e=t.getLabels();t.ticks=0===t.minIndex&&t.maxIndex===e.length-1?e:e.slice(t.minIndex,t.maxIndex+1)},getLabelForIndex:function(t,e){var n=this,i=n.chart.data,a=n.isHorizontal();return i.yLabels&&!a?n.getRightValue(i.datasets[e].data[t]):n.ticks[t-n.minIndex]},getPixelForValue:function(t,e){var n,i=this,a=i.options.offset,r=Math.max(i.maxIndex+1-i.minIndex-(a?0:1),1);if(void 0!==t&&null!==t&&(n=i.isHorizontal()?t.x:t.y),void 0!==n||void 0!==t&&isNaN(e)){var o=i.getLabels();t=n||t;var s=o.indexOf(t);e=-1!==s?s:e}if(i.isHorizontal()){var l=i.width/r,u=l*(e-i.minIndex);return a&&(u+=l/2),i.left+Math.round(u)}var d=i.height/r,c=d*(e-i.minIndex);return a&&(c+=d/2),i.top+Math.round(c)},getPixelForTick:function(t){return this.getPixelForValue(this.ticks[t],t+this.minIndex,null)},getValueForPixel:function(t){var e=this,n=e.options.offset,i=Math.max(e._ticks.length-(n?0:1),1),a=e.isHorizontal(),r=(a?e.width:e.height)/i;return t-=a?e.left:e.top,n&&(t-=r/2),(t<=0?0:Math.round(t/r))+e.minIndex},getBasePixel:function(){return this.bottom}});t.scaleService.registerScaleType("category",e,{position:"bottom"})}},{}],53:[function(t,e,n){"use strict";var i=t(25),a=t(45),r=t(34);e.exports=function(t){var e={position:"left",ticks:{callback:r.formatters.linear}},n=t.LinearScaleBase.extend({determineDataLimits:function(){function t(t){return o?t.xAxisID===e.id:t.yAxisID===e.id}var e=this,n=e.options,i=e.chart,r=i.data.datasets,o=e.isHorizontal();e.min=null,e.max=null;var s=n.stacked;if(void 0===s&&a.each(r,function(e,n){if(!s){var a=i.getDatasetMeta(n);i.isDatasetVisible(n)&&t(a)&&void 0!==a.stack&&(s=!0)}}),n.stacked||s){var l={};a.each(r,function(r,o){var s=i.getDatasetMeta(o),u=[s.type,void 0===n.stacked&&void 0===s.stack?o:"",s.stack].join(".");void 0===l[u]&&(l[u]={positiveValues:[],negativeValues:[]});var d=l[u].positiveValues,c=l[u].negativeValues;i.isDatasetVisible(o)&&t(s)&&a.each(r.data,function(t,i){var a=+e.getRightValue(t);isNaN(a)||s.data[i].hidden||(d[i]=d[i]||0,c[i]=c[i]||0,n.relativePoints?d[i]=100:a<0?c[i]+=a:d[i]+=a)})}),a.each(l,function(t){var n=t.positiveValues.concat(t.negativeValues),i=a.min(n),r=a.max(n);e.min=null===e.min?i:Math.min(e.min,i),e.max=null===e.max?r:Math.max(e.max,r)})}else a.each(r,function(n,r){var o=i.getDatasetMeta(r);i.isDatasetVisible(r)&&t(o)&&a.each(n.data,function(t,n){var i=+e.getRightValue(t);isNaN(i)||o.data[n].hidden||(null===e.min?e.min=i:i<e.min&&(e.min=i),null===e.max?e.max=i:i>e.max&&(e.max=i))})});e.min=isFinite(e.min)&&!isNaN(e.min)?e.min:0,e.max=isFinite(e.max)&&!isNaN(e.max)?e.max:1,this.handleTickRangeOptions()},getTickLimit:function(){var t,e=this,n=e.options.ticks;if(e.isHorizontal())t=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(e.width/50));else{var r=a.valueOrDefault(n.fontSize,i.global.defaultFontSize);t=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(e.height/(2*r)))}return t},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t){var e,n=this,i=n.start,a=+n.getRightValue(t),r=n.end-i;return n.isHorizontal()?(e=n.left+n.width/r*(a-i),Math.round(e)):(e=n.bottom-n.height/r*(a-i),Math.round(e))},getValueForPixel:function(t){var e=this,n=e.isHorizontal(),i=n?e.width:e.height,a=(n?t-e.left:e.bottom-t)/i;return e.start+(e.end-e.start)*a},getPixelForTick:function(t){return this.getPixelForValue(this.ticksAsNumbers[t])}});t.scaleService.registerScaleType("linear",n,e)}},{25:25,34:34,45:45}],54:[function(t,e,n){"use strict";var i=t(45),a=t(34);e.exports=function(t){var e=i.noop;t.LinearScaleBase=t.Scale.extend({getRightValue:function(e){return"string"==typeof e?+e:t.Scale.prototype.getRightValue.call(this,e)},handleTickRangeOptions:function(){var t=this,e=t.options.ticks;if(e.beginAtZero){var n=i.sign(t.min),a=i.sign(t.max);n<0&&a<0?t.max=0:n>0&&a>0&&(t.min=0)}var r=void 0!==e.min||void 0!==e.suggestedMin,o=void 0!==e.max||void 0!==e.suggestedMax;void 0!==e.min?t.min=e.min:void 0!==e.suggestedMin&&(null===t.min?t.min=e.suggestedMin:t.min=Math.min(t.min,e.suggestedMin)),void 0!==e.max?t.max=e.max:void 0!==e.suggestedMax&&(null===t.max?t.max=e.suggestedMax:t.max=Math.max(t.max,e.suggestedMax)),r!==o&&t.min>=t.max&&(r?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)},getTickLimit:e,handleDirectionalChanges:e,buildTicks:function(){var t=this,e=t.options.ticks,n=t.getTickLimit(),r={maxTicks:n=Math.max(2,n),min:e.min,max:e.max,stepSize:i.valueOrDefault(e.fixedStepSize,e.stepSize)},o=t.ticks=a.generators.linear(r,t);t.handleDirectionalChanges(),t.max=i.max(o),t.min=i.min(o),e.reverse?(o.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max)},convertTicksToLabels:function(){var e=this;e.ticksAsNumbers=e.ticks.slice(),e.zeroLineIndex=e.ticks.indexOf(0),t.Scale.prototype.convertTicksToLabels.call(e)}})}},{34:34,45:45}],55:[function(t,e,n){"use strict";var i=t(45),a=t(34);e.exports=function(t){var e={position:"left",ticks:{callback:a.formatters.logarithmic}},n=t.Scale.extend({determineDataLimits:function(){function t(t){return l?t.xAxisID===e.id:t.yAxisID===e.id}var e=this,n=e.options,a=n.ticks,r=e.chart,o=r.data.datasets,s=i.valueOrDefault,l=e.isHorizontal();e.min=null,e.max=null,e.minNotZero=null;var u=n.stacked;if(void 0===u&&i.each(o,function(e,n){if(!u){var i=r.getDatasetMeta(n);r.isDatasetVisible(n)&&t(i)&&void 0!==i.stack&&(u=!0)}}),n.stacked||u){var d={};i.each(o,function(a,o){var s=r.getDatasetMeta(o),l=[s.type,void 0===n.stacked&&void 0===s.stack?o:"",s.stack].join(".");r.isDatasetVisible(o)&&t(s)&&(void 0===d[l]&&(d[l]=[]),i.each(a.data,function(t,i){var a=d[l],r=+e.getRightValue(t);isNaN(r)||s.data[i].hidden||(a[i]=a[i]||0,n.relativePoints?a[i]=100:a[i]+=r)}))}),i.each(d,function(t){var n=i.min(t),a=i.max(t);e.min=null===e.min?n:Math.min(e.min,n),e.max=null===e.max?a:Math.max(e.max,a)})}else i.each(o,function(n,a){var o=r.getDatasetMeta(a);r.isDatasetVisible(a)&&t(o)&&i.each(n.data,function(t,n){var i=+e.getRightValue(t);isNaN(i)||o.data[n].hidden||(null===e.min?e.min=i:i<e.min&&(e.min=i),null===e.max?e.max=i:i>e.max&&(e.max=i),0!==i&&(null===e.minNotZero||i<e.minNotZero)&&(e.minNotZero=i))})});e.min=s(a.min,e.min),e.max=s(a.max,e.max),e.min===e.max&&(0!==e.min&&null!==e.min?(e.min=Math.pow(10,Math.floor(i.log10(e.min))-1),e.max=Math.pow(10,Math.floor(i.log10(e.max))+1)):(e.min=1,e.max=10))},buildTicks:function(){var t=this,e=t.options.ticks,n={min:e.min,max:e.max},r=t.ticks=a.generators.logarithmic(n,t);t.isHorizontal()||r.reverse(),t.max=i.max(r),t.min=i.min(r),e.reverse?(r.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max)},convertTicksToLabels:function(){this.tickValues=this.ticks.slice(),t.Scale.prototype.convertTicksToLabels.call(this)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForTick:function(t){return this.getPixelForValue(this.tickValues[t])},getPixelForValue:function(t){var e,n,a,r=this,o=r.start,s=+r.getRightValue(t),l=r.options.ticks;return r.isHorizontal()?(a=i.log10(r.end)-i.log10(o),0===s?n=r.left:(e=r.width,n=r.left+e/a*(i.log10(s)-i.log10(o)))):(e=r.height,0!==o||l.reverse?0===r.end&&l.reverse?(a=i.log10(r.start)-i.log10(r.minNotZero),n=s===r.end?r.top:s===r.minNotZero?r.top+.02*e:r.top+.02*e+.98*e/a*(i.log10(s)-i.log10(r.minNotZero))):0===s?n=l.reverse?r.top:r.bottom:(a=i.log10(r.end)-i.log10(o),e=r.height,n=r.bottom-e/a*(i.log10(s)-i.log10(o))):(a=i.log10(r.end)-i.log10(r.minNotZero),n=s===o?r.bottom:s===r.minNotZero?r.bottom-.02*e:r.bottom-.02*e-.98*e/a*(i.log10(s)-i.log10(r.minNotZero)))),n},getValueForPixel:function(t){var e,n,a=this,r=i.log10(a.end)-i.log10(a.start);return a.isHorizontal()?(n=a.width,e=a.start*Math.pow(10,(t-a.left)*r/n)):(n=a.height,e=Math.pow(10,(a.bottom-t)*r/n)/a.start),e}});t.scaleService.registerScaleType("logarithmic",n,e)}},{34:34,45:45}],56:[function(t,e,n){"use strict";var i=t(25),a=t(45),r=t(34);e.exports=function(t){function e(t){var e=t.options;return e.angleLines.display||e.pointLabels.display?t.chart.data.labels.length:0}function n(t){var e=t.options.pointLabels,n=a.valueOrDefault(e.fontSize,p.defaultFontSize),i=a.valueOrDefault(e.fontStyle,p.defaultFontStyle),r=a.valueOrDefault(e.fontFamily,p.defaultFontFamily);return{size:n,style:i,family:r,font:a.fontString(n,i,r)}}function o(t,e,n){return a.isArray(n)?{w:a.longestText(t,t.font,n),h:n.length*e+1.5*(n.length-1)*e}:{w:t.measureText(n).width,h:e}}function s(t,e,n,i,a){return t===i||t===a?{start:e-n/2,end:e+n/2}:t<i||t>a?{start:e-n-5,end:e}:{start:e,end:e+n+5}}function l(t){var i,r,l,u=n(t),d=Math.min(t.height/2,t.width/2),c={r:t.width,l:0,t:t.height,b:0},h={};t.ctx.font=u.font,t._pointLabelSizes=[];var f=e(t);for(i=0;i<f;i++){l=t.getPointPosition(i,d),r=o(t.ctx,u.size,t.pointLabels[i]||""),t._pointLabelSizes[i]=r;var g=t.getIndexAngle(i),m=a.toDegrees(g)%360,p=s(m,l.x,r.w,0,180),v=s(m,l.y,r.h,90,270);p.start<c.l&&(c.l=p.start,h.l=g),p.end>c.r&&(c.r=p.end,h.r=g),v.start<c.t&&(c.t=v.start,h.t=g),v.end>c.b&&(c.b=v.end,h.b=g)}t.setReductions(d,c,h)}function u(t){var e=Math.min(t.height/2,t.width/2);t.drawingArea=Math.round(e),t.setCenterPoint(0,0,0,0)}function d(t){return 0===t||180===t?"center":t<180?"left":"right"}function c(t,e,n,i){if(a.isArray(e))for(var r=n.y,o=1.5*i,s=0;s<e.length;++s)t.fillText(e[s],n.x,r),r+=o;else t.fillText(e,n.x,n.y)}function h(t,e,n){90===t||270===t?n.y-=e.h/2:(t>270||t<90)&&(n.y-=e.h)}function f(t){var i=t.ctx,r=a.valueOrDefault,o=t.options,s=o.angleLines,l=o.pointLabels;i.lineWidth=s.lineWidth,i.strokeStyle=s.color;var u=t.getDistanceFromCenterForValue(o.ticks.reverse?t.min:t.max),f=n(t);i.textBaseline="top";for(var g=e(t)-1;g>=0;g--){if(s.display){var m=t.getPointPosition(g,u);i.beginPath(),i.moveTo(t.xCenter,t.yCenter),i.lineTo(m.x,m.y),i.stroke(),i.closePath()}if(l.display){var v=t.getPointPosition(g,u+5),y=r(l.fontColor,p.defaultFontColor);i.font=f.font,i.fillStyle=y;var b=t.getIndexAngle(g),x=a.toDegrees(b);i.textAlign=d(x),h(x,t._pointLabelSizes[g],v),c(i,t.pointLabels[g]||"",v,f.size)}}}function g(t,n,i,r){var o=t.ctx;if(o.strokeStyle=a.valueAtIndexOrDefault(n.color,r-1),o.lineWidth=a.valueAtIndexOrDefault(n.lineWidth,r-1),t.options.gridLines.circular)o.beginPath(),o.arc(t.xCenter,t.yCenter,i,0,2*Math.PI),o.closePath(),o.stroke();else{var s=e(t);if(0===s)return;o.beginPath();var l=t.getPointPosition(0,i);o.moveTo(l.x,l.y);for(var u=1;u<s;u++)l=t.getPointPosition(u,i),o.lineTo(l.x,l.y);o.closePath(),o.stroke()}}function m(t){return a.isNumber(t)?t:0}var p=i.global,v={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},gridLines:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:r.formatters.linear},pointLabels:{display:!0,fontSize:10,callback:function(t){return t}}},y=t.LinearScaleBase.extend({setDimensions:function(){var t=this,e=t.options,n=e.ticks;t.width=t.maxWidth,t.height=t.maxHeight,t.xCenter=Math.round(t.width/2),t.yCenter=Math.round(t.height/2);var i=a.min([t.height,t.width]),r=a.valueOrDefault(n.fontSize,p.defaultFontSize);t.drawingArea=e.display?i/2-(r/2+n.backdropPaddingY):i/2},determineDataLimits:function(){var t=this,e=t.chart,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;a.each(e.data.datasets,function(r,o){if(e.isDatasetVisible(o)){var s=e.getDatasetMeta(o);a.each(r.data,function(e,a){var r=+t.getRightValue(e);isNaN(r)||s.data[a].hidden||(n=Math.min(r,n),i=Math.max(r,i))})}}),t.min=n===Number.POSITIVE_INFINITY?0:n,t.max=i===Number.NEGATIVE_INFINITY?0:i,t.handleTickRangeOptions()},getTickLimit:function(){var t=this.options.ticks,e=a.valueOrDefault(t.fontSize,p.defaultFontSize);return Math.min(t.maxTicksLimit?t.maxTicksLimit:11,Math.ceil(this.drawingArea/(1.5*e)))},convertTicksToLabels:function(){var e=this;t.LinearScaleBase.prototype.convertTicksToLabels.call(e),e.pointLabels=e.chart.data.labels.map(e.options.pointLabels.callback,e)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},fit:function(){this.options.pointLabels.display?l(this):u(this)},setReductions:function(t,e,n){var i=this,a=e.l/Math.sin(n.l),r=Math.max(e.r-i.width,0)/Math.sin(n.r),o=-e.t/Math.cos(n.t),s=-Math.max(e.b-i.height,0)/Math.cos(n.b);a=m(a),r=m(r),o=m(o),s=m(s),i.drawingArea=Math.min(Math.round(t-(a+r)/2),Math.round(t-(o+s)/2)),i.setCenterPoint(a,r,o,s)},setCenterPoint:function(t,e,n,i){var a=this,r=a.width-e-a.drawingArea,o=t+a.drawingArea,s=n+a.drawingArea,l=a.height-i-a.drawingArea;a.xCenter=Math.round((o+r)/2+a.left),a.yCenter=Math.round((s+l)/2+a.top)},getIndexAngle:function(t){return t*(2*Math.PI/e(this))+(this.chart.options&&this.chart.options.startAngle?this.chart.options.startAngle:0)*Math.PI*2/360},getDistanceFromCenterForValue:function(t){var e=this;if(null===t)return 0;var n=e.drawingArea/(e.max-e.min);return e.options.ticks.reverse?(e.max-t)*n:(t-e.min)*n},getPointPosition:function(t,e){var n=this,i=n.getIndexAngle(t)-Math.PI/2;return{x:Math.round(Math.cos(i)*e)+n.xCenter,y:Math.round(Math.sin(i)*e)+n.yCenter}},getPointPositionForValue:function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))},getBasePosition:function(){var t=this,e=t.min,n=t.max;return t.getPointPositionForValue(0,t.beginAtZero?0:e<0&&n<0?n:e>0&&n>0?e:0)},draw:function(){var t=this,e=t.options,n=e.gridLines,i=e.ticks,r=a.valueOrDefault;if(e.display){var o=t.ctx,s=this.getIndexAngle(0),l=r(i.fontSize,p.defaultFontSize),u=r(i.fontStyle,p.defaultFontStyle),d=r(i.fontFamily,p.defaultFontFamily),c=a.fontString(l,u,d);a.each(t.ticks,function(e,a){if(a>0||i.reverse){var u=t.getDistanceFromCenterForValue(t.ticksAsNumbers[a]);if(n.display&&0!==a&&g(t,n,u,a),i.display){var d=r(i.fontColor,p.defaultFontColor);if(o.font=c,o.save(),o.translate(t.xCenter,t.yCenter),o.rotate(s),i.showLabelBackdrop){var h=o.measureText(e).width;o.fillStyle=i.backdropColor,o.fillRect(-h/2-i.backdropPaddingX,-u-l/2-i.backdropPaddingY,h+2*i.backdropPaddingX,l+2*i.backdropPaddingY)}o.textAlign="center",o.textBaseline="middle",o.fillStyle=d,o.fillText(e,0,-u),o.restore()}}}),(e.angleLines.display||e.pointLabels.display)&&f(t)}}});t.scaleService.registerScaleType("radialLinear",y,v)}},{25:25,34:34,45:45}],57:[function(t,e,n){"use strict";function i(t,e){return t-e}function a(t){var e,n,i,a={},r=[];for(e=0,n=t.length;e<n;++e)a[i=t[e]]||(a[i]=!0,r.push(i));return r}function r(t,e,n,i){if("linear"===i||!t.length)return[{time:e,pos:0},{time:n,pos:1}];var a,r,o,s,l,u=[],d=[e];for(a=0,r=t.length;a<r;++a)(s=t[a])>e&&s<n&&d.push(s);for(d.push(n),a=0,r=d.length;a<r;++a)l=d[a+1],o=d[a-1],s=d[a],void 0!==o&&void 0!==l&&Math.round((l+o)/2)===s||u.push({time:s,pos:a/(r-1)});return u}function o(t,e,n){for(var i,a,r,o=0,s=t.length-1;o>=0&&o<=s;){if(i=o+s>>1,a=t[i-1]||null,r=t[i],!a)return{lo:null,hi:r};if(r[e]<n)o=i+1;else{if(!(a[e]>n))return{lo:a,hi:r};s=i-1}}return{lo:r,hi:null}}function s(t,e,n,i){var a=o(t,e,n),r=a.lo?a.hi?a.lo:t[t.length-2]:t[0],s=a.lo?a.hi?a.hi:t[t.length-1]:t[1],l=s[e]-r[e],u=l?(n-r[e])/l:0,d=(s[i]-r[i])*u;return r[i]+d}function l(t,e){var n=e.parser,i=e.parser||e.format;return"function"==typeof n?n(t):"string"==typeof t&&"string"==typeof i?v(t,i):(t instanceof v||(t=v(t)),t.isValid()?t:"function"==typeof i?i(t):t)}function u(t,e){if(b.isNullOrUndef(t))return null;var n=e.options.time,i=l(e.getRightValue(t),n);return i.isValid()?(n.round&&i.startOf(n.round),i.valueOf()):null}function d(t,e,n,i){var a,r,o,s=e-t,l=k[n],u=l.size,d=l.steps;if(!d)return Math.ceil(s/((i||1)*u));for(a=0,r=d.length;a<r&&(o=d[a],!(Math.ceil(s/(u*o))<=i));++a);return o}function c(t,e,n,i){var a,r,o,s=w.length;for(a=w.indexOf(t);a<s-1;++a)if(r=k[w[a]],o=r.steps?r.steps[r.steps.length-1]:_,r.common&&Math.ceil((n-e)/(o*r.size))<=i)return w[a];return w[s-1]}function h(t,e,n,i){var a,r,o=v.duration(v(i).diff(v(n)));for(a=w.length-1;a>=w.indexOf(e);a--)if(r=w[a],k[r].common&&o.as(r)>=t.length)return r;return w[e?w.indexOf(e):0]}function f(t){for(var e=w.indexOf(t)+1,n=w.length;e<n;++e)if(k[w[e]].common)return w[e]}function g(t,e,n,i){var a,r=i.time,o=r.unit||c(r.minUnit,t,e,n),s=f(o),l=b.valueOrDefault(r.stepSize,r.unitStepSize),u="week"===o&&r.isoWeekday,h=i.ticks.major.enabled,g=k[o],m=v(t),p=v(e),y=[];for(l||(l=d(t,e,o,n)),u&&(m=m.isoWeekday(u),p=p.isoWeekday(u)),m=m.startOf(u?"day":o),(p=p.startOf(u?"day":o))<e&&p.add(1,o),a=v(m),h&&s&&!u&&!r.round&&(a.startOf(s),a.add(~~((m-a)/(g.size*l))*l,o));a<p;a.add(l,o))y.push(+a);return y.push(+a),y}function m(t,e,n,i,a){var r,o,l=0,u=0;return a.offset&&e.length&&(a.time.min||(r=e.length>1?e[1]:i,o=e[0],l=(s(t,"time",r,"pos")-s(t,"time",o,"pos"))/2),a.time.max||(r=e[e.length-1],o=e.length>1?e[e.length-2]:n,u=(s(t,"time",r,"pos")-s(t,"time",o,"pos"))/2)),{left:l,right:u}}function p(t,e){var n,i,a,r,o=[];for(n=0,i=t.length;n<i;++n)a=t[n],r=!!e&&a===+v(a).startOf(e),o.push({value:a,major:r});return o}var v=t(6);v="function"==typeof v?v:window.moment;var y=t(25),b=t(45),x=Number.MIN_SAFE_INTEGER||-9007199254740991,_=Number.MAX_SAFE_INTEGER||9007199254740991,k={millisecond:{common:!0,size:1,steps:[1,2,5,10,20,50,100,250,500]},second:{common:!0,size:1e3,steps:[1,2,5,10,30]},minute:{common:!0,size:6e4,steps:[1,2,5,10,30]},hour:{common:!0,size:36e5,steps:[1,2,3,6,12]},day:{common:!0,size:864e5,steps:[1,2,5]},week:{common:!1,size:6048e5,steps:[1,2,3,4]},month:{common:!0,size:2628e6,steps:[1,2,3]},quarter:{common:!1,size:7884e6,steps:[1,2,3,4]},year:{common:!0,size:3154e7}},w=Object.keys(k);e.exports=function(t){var e=t.Scale.extend({initialize:function(){if(!v)throw new Error("Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com");this.mergeTicksOptions(),t.Scale.prototype.initialize.call(this)},update:function(){var e=this,n=e.options;return n.time&&n.time.format&&console.warn("options.time.format is deprecated and replaced by options.time.parser."),t.Scale.prototype.update.apply(e,arguments)},getRightValue:function(e){return e&&void 0!==e.t&&(e=e.t),t.Scale.prototype.getRightValue.call(this,e)},determineDataLimits:function(){var t,e,n,r,o,s,l=this,d=l.chart,c=l.options.time,h=_,f=x,g=[],m=[],p=[];for(t=0,n=d.data.labels.length;t<n;++t)p.push(u(d.data.labels[t],l));for(t=0,n=(d.data.datasets||[]).length;t<n;++t)if(d.isDatasetVisible(t))if(o=d.data.datasets[t].data,b.isObject(o[0]))for(m[t]=[],e=0,r=o.length;e<r;++e)s=u(o[e],l),g.push(s),m[t][e]=s;else g.push.apply(g,p),m[t]=p.slice(0);else m[t]=[];p.length&&(p=a(p).sort(i),h=Math.min(h,p[0]),f=Math.max(f,p[p.length-1])),g.length&&(g=a(g).sort(i),h=Math.min(h,g[0]),f=Math.max(f,g[g.length-1])),h=u(c.min,l)||h,f=u(c.max,l)||f,h=h===_?+v().startOf("day"):h,f=f===x?+v().endOf("day")+1:f,l.min=Math.min(h,f),l.max=Math.max(h+1,f),l._horizontal=l.isHorizontal(),l._table=[],l._timestamps={data:g,datasets:m,labels:p}},buildTicks:function(){var t,e,n,i=this,a=i.min,o=i.max,s=i.options,l=s.time,d=[],c=[];switch(s.ticks.source){case"data":d=i._timestamps.data;break;case"labels":d=i._timestamps.labels;break;case"auto":default:d=g(a,o,i.getLabelCapacity(a),s)}for("ticks"===s.bounds&&d.length&&(a=d[0],o=d[d.length-1]),a=u(l.min,i)||a,o=u(l.max,i)||o,t=0,e=d.length;t<e;++t)(n=d[t])>=a&&n<=o&&c.push(n);return i.min=a,i.max=o,i._unit=l.unit||h(c,l.minUnit,i.min,i.max),i._majorUnit=f(i._unit),i._table=r(i._timestamps.data,a,o,s.distribution),i._offsets=m(i._table,c,a,o,s),p(c,i._majorUnit)},getLabelForIndex:function(t,e){var n=this,i=n.chart.data,a=n.options.time,r=i.labels&&t<i.labels.length?i.labels[t]:"",o=i.datasets[e].data[t];return b.isObject(o)&&(r=n.getRightValue(o)),a.tooltipFormat&&(r=l(r,a).format(a.tooltipFormat)),r},tickFormatFunction:function(t,e,n,i){var a=this,r=a.options,o=t.valueOf(),s=r.time.displayFormats,l=s[a._unit],u=a._majorUnit,d=s[u],c=t.clone().startOf(u).valueOf(),h=r.ticks.major,f=h.enabled&&u&&d&&o===c,g=t.format(i||(f?d:l)),m=f?h:r.ticks.minor,p=b.valueOrDefault(m.callback,m.userCallback);return p?p(g,e,n):g},convertTicksToLabels:function(t){var e,n,i=[];for(e=0,n=t.length;e<n;++e)i.push(this.tickFormatFunction(v(t[e].value),e,t));return i},getPixelForOffset:function(t){var e=this,n=e._horizontal?e.width:e.height,i=e._horizontal?e.left:e.top,a=s(e._table,"time",t,"pos");return i+n*(e._offsets.left+a)/(e._offsets.left+1+e._offsets.right)},getPixelForValue:function(t,e,n){var i=this,a=null;if(void 0!==e&&void 0!==n&&(a=i._timestamps.datasets[n][e]),null===a&&(a=u(t,i)),null!==a)return i.getPixelForOffset(a)},getPixelForTick:function(t){var e=this.getTicks();return t>=0&&t<e.length?this.getPixelForOffset(e[t].value):null},getValueForPixel:function(t){var e=this,n=e._horizontal?e.width:e.height,i=e._horizontal?e.left:e.top,a=(n?(t-i)/n:0)*(e._offsets.left+1+e._offsets.left)-e._offsets.right,r=s(e._table,"pos",a,"time");return v(r)},getLabelWidth:function(t){var e=this,n=e.options.ticks,i=e.ctx.measureText(t).width,a=b.toRadians(n.maxRotation),r=Math.cos(a),o=Math.sin(a);return i*r+b.valueOrDefault(n.fontSize,y.global.defaultFontSize)*o},getLabelCapacity:function(t){var e=this,n=e.options.time.displayFormats.millisecond,i=e.tickFormatFunction(v(t),0,[],n),a=e.getLabelWidth(i),r=e.isHorizontal()?e.width:e.height;return Math.floor(r/a)}});t.scaleService.registerScaleType("time",e,{position:"bottom",distribution:"linear",bounds:"data",time:{parser:!1,format:!1,unit:!1,round:!1,displayFormat:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm a",hour:"hA",day:"MMM D",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"}},ticks:{autoSkip:!1,source:"auto",major:{enabled:!1}}})}},{25:25,45:45,6:6}]},{},[7])(7)}); \ No newline at end of file
diff --git a/main/survey/js/ChartJS/Chart.js b/main/survey/js/ChartJS/Chart.js
new file mode 100644
index 0000000..633218f
--- /dev/null
+++ b/main/survey/js/ChartJS/Chart.js
@@ -0,0 +1,14145 @@
+/*!
+ * Chart.js
+ * http://chartjs.org/
+ * Version: 2.7.1
+ *
+ * Copyright 2017 Nick Downie
+ * Released under the MIT license
+ * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
+ */
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Chart = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+
+},{}],2:[function(require,module,exports){
+/* MIT license */
+var colorNames = require(6);
+
+module.exports = {
+ getRgba: getRgba,
+ getHsla: getHsla,
+ getRgb: getRgb,
+ getHsl: getHsl,
+ getHwb: getHwb,
+ getAlpha: getAlpha,
+
+ hexString: hexString,
+ rgbString: rgbString,
+ rgbaString: rgbaString,
+ percentString: percentString,
+ percentaString: percentaString,
+ hslString: hslString,
+ hslaString: hslaString,
+ hwbString: hwbString,
+ keyword: keyword
+}
+
+function getRgba(string) {
+ if (!string) {
+ return;
+ }
+ var abbr = /^#([a-fA-F0-9]{3})$/i,
+ hex = /^#([a-fA-F0-9]{6})$/i,
+ rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i,
+ per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i,
+ keyword = /(\w+)/;
+
+ var rgb = [0, 0, 0],
+ a = 1,
+ match = string.match(abbr);
+ if (match) {
+ match = match[1];
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = parseInt(match[i] + match[i], 16);
+ }
+ }
+ else if (match = string.match(hex)) {
+ match = match[1];
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = parseInt(match.slice(i * 2, i * 2 + 2), 16);
+ }
+ }
+ else if (match = string.match(rgba)) {
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = parseInt(match[i + 1]);
+ }
+ a = parseFloat(match[4]);
+ }
+ else if (match = string.match(per)) {
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
+ }
+ a = parseFloat(match[4]);
+ }
+ else if (match = string.match(keyword)) {
+ if (match[1] == "transparent") {
+ return [0, 0, 0, 0];
+ }
+ rgb = colorNames[match[1]];
+ if (!rgb) {
+ return;
+ }
+ }
+
+ for (var i = 0; i < rgb.length; i++) {
+ rgb[i] = scale(rgb[i], 0, 255);
+ }
+ if (!a && a != 0) {
+ a = 1;
+ }
+ else {
+ a = scale(a, 0, 1);
+ }
+ rgb[3] = a;
+ return rgb;
+}
+
+function getHsla(string) {
+ if (!string) {
+ return;
+ }
+ var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
+ var match = string.match(hsl);
+ if (match) {
+ var alpha = parseFloat(match[4]);
+ var h = scale(parseInt(match[1]), 0, 360),
+ s = scale(parseFloat(match[2]), 0, 100),
+ l = scale(parseFloat(match[3]), 0, 100),
+ a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
+ return [h, s, l, a];
+ }
+}
+
+function getHwb(string) {
+ if (!string) {
+ return;
+ }
+ var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
+ var match = string.match(hwb);
+ if (match) {
+ var alpha = parseFloat(match[4]);
+ var h = scale(parseInt(match[1]), 0, 360),
+ w = scale(parseFloat(match[2]), 0, 100),
+ b = scale(parseFloat(match[3]), 0, 100),
+ a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
+ return [h, w, b, a];
+ }
+}
+
+function getRgb(string) {
+ var rgba = getRgba(string);
+ return rgba && rgba.slice(0, 3);
+}
+
+function getHsl(string) {
+ var hsla = getHsla(string);
+ return hsla && hsla.slice(0, 3);
+}
+
+function getAlpha(string) {
+ var vals = getRgba(string);
+ if (vals) {
+ return vals[3];
+ }
+ else if (vals = getHsla(string)) {
+ return vals[3];
+ }
+ else if (vals = getHwb(string)) {
+ return vals[3];
+ }
+}
+
+// generators
+function hexString(rgb) {
+ return "#" + hexDouble(rgb[0]) + hexDouble(rgb[1])
+ + hexDouble(rgb[2]);
+}
+
+function rgbString(rgba, alpha) {
+ if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
+ return rgbaString(rgba, alpha);
+ }
+ return "rgb(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2] + ")";
+}
+
+function rgbaString(rgba, alpha) {
+ if (alpha === undefined) {
+ alpha = (rgba[3] !== undefined ? rgba[3] : 1);
+ }
+ return "rgba(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2]
+ + ", " + alpha + ")";
+}
+
+function percentString(rgba, alpha) {
+ if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
+ return percentaString(rgba, alpha);
+ }
+ var r = Math.round(rgba[0]/255 * 100),
+ g = Math.round(rgba[1]/255 * 100),
+ b = Math.round(rgba[2]/255 * 100);
+
+ return "rgb(" + r + "%, " + g + "%, " + b + "%)";
+}
+
+function percentaString(rgba, alpha) {
+ var r = Math.round(rgba[0]/255 * 100),
+ g = Math.round(rgba[1]/255 * 100),
+ b = Math.round(rgba[2]/255 * 100);
+ return "rgba(" + r + "%, " + g + "%, " + b + "%, " + (alpha || rgba[3] || 1) + ")";
+}
+
+function hslString(hsla, alpha) {
+ if (alpha < 1 || (hsla[3] && hsla[3] < 1)) {
+ return hslaString(hsla, alpha);
+ }
+ return "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)";
+}
+
+function hslaString(hsla, alpha) {
+ if (alpha === undefined) {
+ alpha = (hsla[3] !== undefined ? hsla[3] : 1);
+ }
+ return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, "
+ + alpha + ")";
+}
+
+// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
+// (hwb have alpha optional & 1 is default value)
+function hwbString(hwb, alpha) {
+ if (alpha === undefined) {
+ alpha = (hwb[3] !== undefined ? hwb[3] : 1);
+ }
+ return "hwb(" + hwb[0] + ", " + hwb[1] + "%, " + hwb[2] + "%"
+ + (alpha !== undefined && alpha !== 1 ? ", " + alpha : "") + ")";
+}
+
+function keyword(rgb) {
+ return reverseNames[rgb.slice(0, 3)];
+}
+
+// helpers
+function scale(num, min, max) {
+ return Math.min(Math.max(min, num), max);
+}
+
+function hexDouble(num) {
+ var str = num.toString(16).toUpperCase();
+ return (str.length < 2) ? "0" + str : str;
+}
+
+
+//create a list of reverse color names
+var reverseNames = {};
+for (var name in colorNames) {
+ reverseNames[colorNames[name]] = name;
+}
+
+},{"6":6}],3:[function(require,module,exports){
+/* MIT license */
+var convert = require(5);
+var string = require(2);
+
+var Color = function (obj) {
+ if (obj instanceof Color) {
+ return obj;
+ }
+ if (!(this instanceof Color)) {
+ return new Color(obj);
+ }
+
+ this.valid = false;
+ this.values = {
+ rgb: [0, 0, 0],
+ hsl: [0, 0, 0],
+ hsv: [0, 0, 0],
+ hwb: [0, 0, 0],
+ cmyk: [0, 0, 0, 0],
+ alpha: 1
+ };
+
+ // parse Color() argument
+ var vals;
+ if (typeof obj === 'string') {
+ vals = string.getRgba(obj);
+ if (vals) {
+ this.setValues('rgb', vals);
+ } else if (vals = string.getHsla(obj)) {
+ this.setValues('hsl', vals);
+ } else if (vals = string.getHwb(obj)) {
+ this.setValues('hwb', vals);
+ }
+ } else if (typeof obj === 'object') {
+ vals = obj;
+ if (vals.r !== undefined || vals.red !== undefined) {
+ this.setValues('rgb', vals);
+ } else if (vals.l !== undefined || vals.lightness !== undefined) {
+ this.setValues('hsl', vals);
+ } else if (vals.v !== undefined || vals.value !== undefined) {
+ this.setValues('hsv', vals);
+ } else if (vals.w !== undefined || vals.whiteness !== undefined) {
+ this.setValues('hwb', vals);
+ } else if (vals.c !== undefined || vals.cyan !== undefined) {
+ this.setValues('cmyk', vals);
+ }
+ }
+};
+
+Color.prototype = {
+ isValid: function () {
+ return this.valid;
+ },
+ rgb: function () {
+ return this.setSpace('rgb', arguments);
+ },
+ hsl: function () {
+ return this.setSpace('hsl', arguments);
+ },
+ hsv: function () {
+ return this.setSpace('hsv', arguments);
+ },
+ hwb: function () {
+ return this.setSpace('hwb', arguments);
+ },
+ cmyk: function () {
+ return this.setSpace('cmyk', arguments);
+ },
+
+ rgbArray: function () {
+ return this.values.rgb;
+ },
+ hslArray: function () {
+ return this.values.hsl;
+ },
+ hsvArray: function () {
+ return this.values.hsv;
+ },
+ hwbArray: function () {
+ var values = this.values;
+ if (values.alpha !== 1) {
+ return values.hwb.concat([values.alpha]);
+ }
+ return values.hwb;
+ },
+ cmykArray: function () {
+ return this.values.cmyk;
+ },
+ rgbaArray: function () {
+ var values = this.values;
+ return values.rgb.concat([values.alpha]);
+ },
+ hslaArray: function () {
+ var values = this.values;
+ return values.hsl.concat([values.alpha]);
+ },
+ alpha: function (val) {
+ if (val === undefined) {
+ return this.values.alpha;
+ }
+ this.setValues('alpha', val);
+ return this;
+ },
+
+ red: function (val) {
+ return this.setChannel('rgb', 0, val);
+ },
+ green: function (val) {
+ return this.setChannel('rgb', 1, val);
+ },
+ blue: function (val) {
+ return this.setChannel('rgb', 2, val);
+ },
+ hue: function (val) {
+ if (val) {
+ val %= 360;
+ val = val < 0 ? 360 + val : val;
+ }
+ return this.setChannel('hsl', 0, val);
+ },
+ saturation: function (val) {
+ return this.setChannel('hsl', 1, val);
+ },
+ lightness: function (val) {
+ return this.setChannel('hsl', 2, val);
+ },
+ saturationv: function (val) {
+ return this.setChannel('hsv', 1, val);
+ },
+ whiteness: function (val) {
+ return this.setChannel('hwb', 1, val);
+ },
+ blackness: function (val) {
+ return this.setChannel('hwb', 2, val);
+ },
+ value: function (val) {
+ return this.setChannel('hsv', 2, val);
+ },
+ cyan: function (val) {
+ return this.setChannel('cmyk', 0, val);
+ },
+ magenta: function (val) {
+ return this.setChannel('cmyk', 1, val);
+ },
+ yellow: function (val) {
+ return this.setChannel('cmyk', 2, val);
+ },
+ black: function (val) {
+ return this.setChannel('cmyk', 3, val);
+ },
+
+ hexString: function () {
+ return string.hexString(this.values.rgb);
+ },
+ rgbString: function () {
+ return string.rgbString(this.values.rgb, this.values.alpha);
+ },
+ rgbaString: function () {
+ return string.rgbaString(this.values.rgb, this.values.alpha);
+ },
+ percentString: function () {
+ return string.percentString(this.values.rgb, this.values.alpha);
+ },
+ hslString: function () {
+ return string.hslString(this.values.hsl, this.values.alpha);
+ },
+ hslaString: function () {
+ return string.hslaString(this.values.hsl, this.values.alpha);
+ },
+ hwbString: function () {
+ return string.hwbString(this.values.hwb, this.values.alpha);
+ },
+ keyword: function () {
+ return string.keyword(this.values.rgb, this.values.alpha);
+ },
+
+ rgbNumber: function () {
+ var rgb = this.values.rgb;
+ return (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
+ },
+
+ luminosity: function () {
+ // http://www.w3.org/TR/WCAG20/#relativeluminancedef
+ var rgb = this.values.rgb;
+ var lum = [];
+ for (var i = 0; i < rgb.length; i++) {
+ var chan = rgb[i] / 255;
+ lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
+ }
+ return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
+ },
+
+ contrast: function (color2) {
+ // http://www.w3.org/TR/WCAG20/#contrast-ratiodef
+ var lum1 = this.luminosity();
+ var lum2 = color2.luminosity();
+ if (lum1 > lum2) {
+ return (lum1 + 0.05) / (lum2 + 0.05);
+ }
+ return (lum2 + 0.05) / (lum1 + 0.05);
+ },
+
+ level: function (color2) {
+ var contrastRatio = this.contrast(color2);
+ if (contrastRatio >= 7.1) {
+ return 'AAA';
+ }
+
+ return (contrastRatio >= 4.5) ? 'AA' : '';
+ },
+
+ dark: function () {
+ // YIQ equation from http://24ways.org/2010/calculating-color-contrast
+ var rgb = this.values.rgb;
+ var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
+ return yiq < 128;
+ },
+
+ light: function () {
+ return !this.dark();
+ },
+
+ negate: function () {
+ var rgb = [];
+ for (var i = 0; i < 3; i++) {
+ rgb[i] = 255 - this.values.rgb[i];
+ }
+ this.setValues('rgb', rgb);
+ return this;
+ },
+
+ lighten: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[2] += hsl[2] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ darken: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[2] -= hsl[2] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ saturate: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[1] += hsl[1] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ desaturate: function (ratio) {
+ var hsl = this.values.hsl;
+ hsl[1] -= hsl[1] * ratio;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ whiten: function (ratio) {
+ var hwb = this.values.hwb;
+ hwb[1] += hwb[1] * ratio;
+ this.setValues('hwb', hwb);
+ return this;
+ },
+
+ blacken: function (ratio) {
+ var hwb = this.values.hwb;
+ hwb[2] += hwb[2] * ratio;
+ this.setValues('hwb', hwb);
+ return this;
+ },
+
+ greyscale: function () {
+ var rgb = this.values.rgb;
+ // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
+ var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
+ this.setValues('rgb', [val, val, val]);
+ return this;
+ },
+
+ clearer: function (ratio) {
+ var alpha = this.values.alpha;
+ this.setValues('alpha', alpha - (alpha * ratio));
+ return this;
+ },
+
+ opaquer: function (ratio) {
+ var alpha = this.values.alpha;
+ this.setValues('alpha', alpha + (alpha * ratio));
+ return this;
+ },
+
+ rotate: function (degrees) {
+ var hsl = this.values.hsl;
+ var hue = (hsl[0] + degrees) % 360;
+ hsl[0] = hue < 0 ? 360 + hue : hue;
+ this.setValues('hsl', hsl);
+ return this;
+ },
+
+ /**
+ * Ported from sass implementation in C
+ * https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
+ */
+ mix: function (mixinColor, weight) {
+ var color1 = this;
+ var color2 = mixinColor;
+ var p = weight === undefined ? 0.5 : weight;
+
+ var w = 2 * p - 1;
+ var a = color1.alpha() - color2.alpha();
+
+ var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
+ var w2 = 1 - w1;
+
+ return this
+ .rgb(
+ w1 * color1.red() + w2 * color2.red(),
+ w1 * color1.green() + w2 * color2.green(),
+ w1 * color1.blue() + w2 * color2.blue()
+ )
+ .alpha(color1.alpha() * p + color2.alpha() * (1 - p));
+ },
+
+ toJSON: function () {
+ return this.rgb();
+ },
+
+ clone: function () {
+ // NOTE(SB): using node-clone creates a dependency to Buffer when using browserify,
+ // making the final build way to big to embed in Chart.js. So let's do it manually,
+ // assuming that values to clone are 1 dimension arrays containing only numbers,
+ // except 'alpha' which is a number.
+ var result = new Color();
+ var source = this.values;
+ var target = result.values;
+ var value, type;
+
+ for (var prop in source) {
+ if (source.hasOwnProperty(prop)) {
+ value = source[prop];
+ type = ({}).toString.call(value);
+ if (type === '[object Array]') {
+ target[prop] = value.slice(0);
+ } else if (type === '[object Number]') {
+ target[prop] = value;
+ } else {
+ console.error('unexpected color value:', value);
+ }
+ }
+ }
+
+ return result;
+ }
+};
+
+Color.prototype.spaces = {
+ rgb: ['red', 'green', 'blue'],
+ hsl: ['hue', 'saturation', 'lightness'],
+ hsv: ['hue', 'saturation', 'value'],
+ hwb: ['hue', 'whiteness', 'blackness'],
+ cmyk: ['cyan', 'magenta', 'yellow', 'black']
+};
+
+Color.prototype.maxes = {
+ rgb: [255, 255, 255],
+ hsl: [360, 100, 100],
+ hsv: [360, 100, 100],
+ hwb: [360, 100, 100],
+ cmyk: [100, 100, 100, 100]
+};
+
+Color.prototype.getValues = function (space) {
+ var values = this.values;
+ var vals = {};
+
+ for (var i = 0; i < space.length; i++) {
+ vals[space.charAt(i)] = values[space][i];
+ }
+
+ if (values.alpha !== 1) {
+ vals.a = values.alpha;
+ }
+
+ // {r: 255, g: 255, b: 255, a: 0.4}
+ return vals;
+};
+
+Color.prototype.setValues = function (space, vals) {
+ var values = this.values;
+ var spaces = this.spaces;
+ var maxes = this.maxes;
+ var alpha = 1;
+ var i;
+
+ this.valid = true;
+
+ if (space === 'alpha') {
+ alpha = vals;
+ } else if (vals.length) {
+ // [10, 10, 10]
+ values[space] = vals.slice(0, space.length);
+ alpha = vals[space.length];
+ } else if (vals[space.charAt(0)] !== undefined) {
+ // {r: 10, g: 10, b: 10}
+ for (i = 0; i < space.length; i++) {
+ values[space][i] = vals[space.charAt(i)];
+ }
+
+ alpha = vals.a;
+ } else if (vals[spaces[space][0]] !== undefined) {
+ // {red: 10, green: 10, blue: 10}
+ var chans = spaces[space];
+
+ for (i = 0; i < space.length; i++) {
+ values[space][i] = vals[chans[i]];
+ }
+
+ alpha = vals.alpha;
+ }
+
+ values.alpha = Math.max(0, Math.min(1, (alpha === undefined ? values.alpha : alpha)));
+
+ if (space === 'alpha') {
+ return false;
+ }
+
+ var capped;
+
+ // cap values of the space prior converting all values
+ for (i = 0; i < space.length; i++) {
+ capped = Math.max(0, Math.min(maxes[space][i], values[space][i]));
+ values[space][i] = Math.round(capped);
+ }
+
+ // convert to all the other color spaces
+ for (var sname in spaces) {
+ if (sname !== space) {
+ values[sname] = convert[space][sname](values[space]);
+ }
+ }
+
+ return true;
+};
+
+Color.prototype.setSpace = function (space, args) {
+ var vals = args[0];
+
+ if (vals === undefined) {
+ // color.rgb()
+ return this.getValues(space);
+ }
+
+ // color.rgb(10, 10, 10)
+ if (typeof vals === 'number') {
+ vals = Array.prototype.slice.call(args);
+ }
+
+ this.setValues(space, vals);
+ return this;
+};
+
+Color.prototype.setChannel = function (space, index, val) {
+ var svalues = this.values[space];
+ if (val === undefined) {
+ // color.red()
+ return svalues[index];
+ } else if (val === svalues[index]) {
+ // color.red(color.red())
+ return this;
+ }
+
+ // color.red(100)
+ svalues[index] = val;
+ this.setValues(space, svalues);
+
+ return this;
+};
+
+if (typeof window !== 'undefined') {
+ window.Color = Color;
+}
+
+module.exports = Color;
+
+},{"2":2,"5":5}],4:[function(require,module,exports){
+/* MIT license */
+
+module.exports = {
+ rgb2hsl: rgb2hsl,
+ rgb2hsv: rgb2hsv,
+ rgb2hwb: rgb2hwb,
+ rgb2cmyk: rgb2cmyk,
+ rgb2keyword: rgb2keyword,
+ rgb2xyz: rgb2xyz,
+ rgb2lab: rgb2lab,
+ rgb2lch: rgb2lch,
+
+ hsl2rgb: hsl2rgb,
+ hsl2hsv: hsl2hsv,
+ hsl2hwb: hsl2hwb,
+ hsl2cmyk: hsl2cmyk,
+ hsl2keyword: hsl2keyword,
+
+ hsv2rgb: hsv2rgb,
+ hsv2hsl: hsv2hsl,
+ hsv2hwb: hsv2hwb,
+ hsv2cmyk: hsv2cmyk,
+ hsv2keyword: hsv2keyword,
+
+ hwb2rgb: hwb2rgb,
+ hwb2hsl: hwb2hsl,
+ hwb2hsv: hwb2hsv,
+ hwb2cmyk: hwb2cmyk,
+ hwb2keyword: hwb2keyword,
+
+ cmyk2rgb: cmyk2rgb,
+ cmyk2hsl: cmyk2hsl,
+ cmyk2hsv: cmyk2hsv,
+ cmyk2hwb: cmyk2hwb,
+ cmyk2keyword: cmyk2keyword,
+
+ keyword2rgb: keyword2rgb,
+ keyword2hsl: keyword2hsl,
+ keyword2hsv: keyword2hsv,
+ keyword2hwb: keyword2hwb,
+ keyword2cmyk: keyword2cmyk,
+ keyword2lab: keyword2lab,
+ keyword2xyz: keyword2xyz,
+
+ xyz2rgb: xyz2rgb,
+ xyz2lab: xyz2lab,
+ xyz2lch: xyz2lch,
+
+ lab2xyz: lab2xyz,
+ lab2rgb: lab2rgb,
+ lab2lch: lab2lch,
+
+ lch2lab: lch2lab,
+ lch2xyz: lch2xyz,
+ lch2rgb: lch2rgb
+}
+
+
+function rgb2hsl(rgb) {
+ var r = rgb[0]/255,
+ g = rgb[1]/255,
+ b = rgb[2]/255,
+ min = Math.min(r, g, b),
+ max = Math.max(r, g, b),
+ delta = max - min,
+ h, s, l;
+
+ if (max == min)
+ h = 0;
+ else if (r == max)
+ h = (g - b) / delta;
+ else if (g == max)
+ h = 2 + (b - r) / delta;
+ else if (b == max)
+ h = 4 + (r - g)/ delta;
+
+ h = Math.min(h * 60, 360);
+
+ if (h < 0)
+ h += 360;
+
+ l = (min + max) / 2;
+
+ if (max == min)
+ s = 0;
+ else if (l <= 0.5)
+ s = delta / (max + min);
+ else
+ s = delta / (2 - max - min);
+
+ return [h, s * 100, l * 100];
+}
+
+function rgb2hsv(rgb) {
+ var r = rgb[0],
+ g = rgb[1],
+ b = rgb[2],
+ min = Math.min(r, g, b),
+ max = Math.max(r, g, b),
+ delta = max - min,
+ h, s, v;
+
+ if (max == 0)
+ s = 0;
+ else
+ s = (delta/max * 1000)/10;
+
+ if (max == min)
+ h = 0;
+ else if (r == max)
+ h = (g - b) / delta;
+ else if (g == max)
+ h = 2 + (b - r) / delta;
+ else if (b == max)
+ h = 4 + (r - g) / delta;
+
+ h = Math.min(h * 60, 360);
+
+ if (h < 0)
+ h += 360;
+
+ v = ((max / 255) * 1000) / 10;
+
+ return [h, s, v];
+}
+
+function rgb2hwb(rgb) {
+ var r = rgb[0],
+ g = rgb[1],
+ b = rgb[2],
+ h = rgb2hsl(rgb)[0],
+ w = 1/255 * Math.min(r, Math.min(g, b)),
+ b = 1 - 1/255 * Math.max(r, Math.max(g, b));
+
+ return [h, w * 100, b * 100];
+}
+
+function rgb2cmyk(rgb) {
+ var r = rgb[0] / 255,
+ g = rgb[1] / 255,
+ b = rgb[2] / 255,
+ c, m, y, k;
+
+ k = Math.min(1 - r, 1 - g, 1 - b);
+ c = (1 - r - k) / (1 - k) || 0;
+ m = (1 - g - k) / (1 - k) || 0;
+ y = (1 - b - k) / (1 - k) || 0;
+ return [c * 100, m * 100, y * 100, k * 100];
+}
+
+function rgb2keyword(rgb) {
+ return reverseKeywords[JSON.stringify(rgb)];
+}
+
+function rgb2xyz(rgb) {
+ var r = rgb[0] / 255,
+ g = rgb[1] / 255,
+ b = rgb[2] / 255;
+
+ // assume sRGB
+ r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
+ g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
+ b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
+
+ var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
+ var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
+ var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
+
+ return [x * 100, y *100, z * 100];
+}
+
+function rgb2lab(rgb) {
+ var xyz = rgb2xyz(rgb),
+ x = xyz[0],
+ y = xyz[1],
+ z = xyz[2],
+ l, a, b;
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
+
+ l = (116 * y) - 16;
+ a = 500 * (x - y);
+ b = 200 * (y - z);
+
+ return [l, a, b];
+}
+
+function rgb2lch(args) {
+ return lab2lch(rgb2lab(args));
+}
+
+function hsl2rgb(hsl) {
+ var h = hsl[0] / 360,
+ s = hsl[1] / 100,
+ l = hsl[2] / 100,
+ t1, t2, t3, rgb, val;
+
+ if (s == 0) {
+ val = l * 255;
+ return [val, val, val];
+ }
+
+ if (l < 0.5)
+ t2 = l * (1 + s);
+ else
+ t2 = l + s - l * s;
+ t1 = 2 * l - t2;
+
+ rgb = [0, 0, 0];
+ for (var i = 0; i < 3; i++) {
+ t3 = h + 1 / 3 * - (i - 1);
+ t3 < 0 && t3++;
+ t3 > 1 && t3--;
+
+ if (6 * t3 < 1)
+ val = t1 + (t2 - t1) * 6 * t3;
+ else if (2 * t3 < 1)
+ val = t2;
+ else if (3 * t3 < 2)
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
+ else
+ val = t1;
+
+ rgb[i] = val * 255;
+ }
+
+ return rgb;
+}
+
+function hsl2hsv(hsl) {
+ var h = hsl[0],
+ s = hsl[1] / 100,
+ l = hsl[2] / 100,
+ sv, v;
+
+ if(l === 0) {
+ // no need to do calc on black
+ // also avoids divide by 0 error
+ return [0, 0, 0];
+ }
+
+ l *= 2;
+ s *= (l <= 1) ? l : 2 - l;
+ v = (l + s) / 2;
+ sv = (2 * s) / (l + s);
+ return [h, sv * 100, v * 100];
+}
+
+function hsl2hwb(args) {
+ return rgb2hwb(hsl2rgb(args));
+}
+
+function hsl2cmyk(args) {
+ return rgb2cmyk(hsl2rgb(args));
+}
+
+function hsl2keyword(args) {
+ return rgb2keyword(hsl2rgb(args));
+}
+
+
+function hsv2rgb(hsv) {
+ var h = hsv[0] / 60,
+ s = hsv[1] / 100,
+ v = hsv[2] / 100,
+ hi = Math.floor(h) % 6;
+
+ var f = h - Math.floor(h),
+ p = 255 * v * (1 - s),
+ q = 255 * v * (1 - (s * f)),
+ t = 255 * v * (1 - (s * (1 - f))),
+ v = 255 * v;
+
+ switch(hi) {
+ case 0:
+ return [v, t, p];
+ case 1:
+ return [q, v, p];
+ case 2:
+ return [p, v, t];
+ case 3:
+ return [p, q, v];
+ case 4:
+ return [t, p, v];
+ case 5:
+ return [v, p, q];
+ }
+}
+
+function hsv2hsl(hsv) {
+ var h = hsv[0],
+ s = hsv[1] / 100,
+ v = hsv[2] / 100,
+ sl, l;
+
+ l = (2 - s) * v;
+ sl = s * v;
+ sl /= (l <= 1) ? l : 2 - l;
+ sl = sl || 0;
+ l /= 2;
+ return [h, sl * 100, l * 100];
+}
+
+function hsv2hwb(args) {
+ return rgb2hwb(hsv2rgb(args))
+}
+
+function hsv2cmyk(args) {
+ return rgb2cmyk(hsv2rgb(args));
+}
+
+function hsv2keyword(args) {
+ return rgb2keyword(hsv2rgb(args));
+}
+
+// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
+function hwb2rgb(hwb) {
+ var h = hwb[0] / 360,
+ wh = hwb[1] / 100,
+ bl = hwb[2] / 100,
+ ratio = wh + bl,
+ i, v, f, n;
+
+ // wh + bl cant be > 1
+ if (ratio > 1) {
+ wh /= ratio;
+ bl /= ratio;
+ }
+
+ i = Math.floor(6 * h);
+ v = 1 - bl;
+ f = 6 * h - i;
+ if ((i & 0x01) != 0) {
+ f = 1 - f;
+ }
+ n = wh + f * (v - wh); // linear interpolation
+
+ switch (i) {
+ default:
+ case 6:
+ case 0: r = v; g = n; b = wh; break;
+ case 1: r = n; g = v; b = wh; break;
+ case 2: r = wh; g = v; b = n; break;
+ case 3: r = wh; g = n; b = v; break;
+ case 4: r = n; g = wh; b = v; break;
+ case 5: r = v; g = wh; b = n; break;
+ }
+
+ return [r * 255, g * 255, b * 255];
+}
+
+function hwb2hsl(args) {
+ return rgb2hsl(hwb2rgb(args));
+}
+
+function hwb2hsv(args) {
+ return rgb2hsv(hwb2rgb(args));
+}
+
+function hwb2cmyk(args) {
+ return rgb2cmyk(hwb2rgb(args));
+}
+
+function hwb2keyword(args) {
+ return rgb2keyword(hwb2rgb(args));
+}
+
+function cmyk2rgb(cmyk) {
+ var c = cmyk[0] / 100,
+ m = cmyk[1] / 100,
+ y = cmyk[2] / 100,
+ k = cmyk[3] / 100,
+ r, g, b;
+
+ r = 1 - Math.min(1, c * (1 - k) + k);
+ g = 1 - Math.min(1, m * (1 - k) + k);
+ b = 1 - Math.min(1, y * (1 - k) + k);
+ return [r * 255, g * 255, b * 255];
+}
+
+function cmyk2hsl(args) {
+ return rgb2hsl(cmyk2rgb(args));
+}
+
+function cmyk2hsv(args) {
+ return rgb2hsv(cmyk2rgb(args));
+}
+
+function cmyk2hwb(args) {
+ return rgb2hwb(cmyk2rgb(args));
+}
+
+function cmyk2keyword(args) {
+ return rgb2keyword(cmyk2rgb(args));
+}
+
+
+function xyz2rgb(xyz) {
+ var x = xyz[0] / 100,
+ y = xyz[1] / 100,
+ z = xyz[2] / 100,
+ r, g, b;
+
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
+
+ // assume sRGB
+ r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
+ : r = (r * 12.92);
+
+ g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
+ : g = (g * 12.92);
+
+ b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
+ : b = (b * 12.92);
+
+ r = Math.min(Math.max(0, r), 1);
+ g = Math.min(Math.max(0, g), 1);
+ b = Math.min(Math.max(0, b), 1);
+
+ return [r * 255, g * 255, b * 255];
+}
+
+function xyz2lab(xyz) {
+ var x = xyz[0],
+ y = xyz[1],
+ z = xyz[2],
+ l, a, b;
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
+
+ l = (116 * y) - 16;
+ a = 500 * (x - y);
+ b = 200 * (y - z);
+
+ return [l, a, b];
+}
+
+function xyz2lch(args) {
+ return lab2lch(xyz2lab(args));
+}
+
+function lab2xyz(lab) {
+ var l = lab[0],
+ a = lab[1],
+ b = lab[2],
+ x, y, z, y2;
+
+ if (l <= 8) {
+ y = (l * 100) / 903.3;
+ y2 = (7.787 * (y / 100)) + (16 / 116);
+ } else {
+ y = 100 * Math.pow((l + 16) / 116, 3);
+ y2 = Math.pow(y / 100, 1/3);
+ }
+
+ x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3);
+
+ z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3);
+
+ return [x, y, z];
+}
+
+function lab2lch(lab) {
+ var l = lab[0],
+ a = lab[1],
+ b = lab[2],
+ hr, h, c;
+
+ hr = Math.atan2(b, a);
+ h = hr * 360 / 2 / Math.PI;
+ if (h < 0) {
+ h += 360;
+ }
+ c = Math.sqrt(a * a + b * b);
+ return [l, c, h];
+}
+
+function lab2rgb(args) {
+ return xyz2rgb(lab2xyz(args));
+}
+
+function lch2lab(lch) {
+ var l = lch[0],
+ c = lch[1],
+ h = lch[2],
+ a, b, hr;
+
+ hr = h / 360 * 2 * Math.PI;
+ a = c * Math.cos(hr);
+ b = c * Math.sin(hr);
+ return [l, a, b];
+}
+
+function lch2xyz(args) {
+ return lab2xyz(lch2lab(args));
+}
+
+function lch2rgb(args) {
+ return lab2rgb(lch2lab(args));
+}
+
+function keyword2rgb(keyword) {
+ return cssKeywords[keyword];
+}
+
+function keyword2hsl(args) {
+ return rgb2hsl(keyword2rgb(args));
+}
+
+function keyword2hsv(args) {
+ return rgb2hsv(keyword2rgb(args));
+}
+
+function keyword2hwb(args) {
+ return rgb2hwb(keyword2rgb(args));
+}
+
+function keyword2cmyk(args) {
+ return rgb2cmyk(keyword2rgb(args));
+}
+
+function keyword2lab(args) {
+ return rgb2lab(keyword2rgb(args));
+}
+
+function keyword2xyz(args) {
+ return rgb2xyz(keyword2rgb(args));
+}
+
+var cssKeywords = {
+ aliceblue: [240,248,255],
+ antiquewhite: [250,235,215],
+ aqua: [0,255,255],
+ aquamarine: [127,255,212],
+ azure: [240,255,255],
+ beige: [245,245,220],
+ bisque: [255,228,196],
+ black: [0,0,0],
+ blanchedalmond: [255,235,205],
+ blue: [0,0,255],
+ blueviolet: [138,43,226],
+ brown: [165,42,42],
+ burlywood: [222,184,135],
+ cadetblue: [95,158,160],
+ chartreuse: [127,255,0],
+ chocolate: [210,105,30],
+ coral: [255,127,80],
+ cornflowerblue: [100,149,237],
+ cornsilk: [255,248,220],
+ crimson: [220,20,60],
+ cyan: [0,255,255],
+ darkblue: [0,0,139],
+ darkcyan: [0,139,139],
+ darkgoldenrod: [184,134,11],
+ darkgray: [169,169,169],
+ darkgreen: [0,100,0],
+ darkgrey: [169,169,169],
+ darkkhaki: [189,183,107],
+ darkmagenta: [139,0,139],
+ darkolivegreen: [85,107,47],
+ darkorange: [255,140,0],
+ darkorchid: [153,50,204],
+ darkred: [139,0,0],
+ darksalmon: [233,150,122],
+ darkseagreen: [143,188,143],
+ darkslateblue: [72,61,139],
+ darkslategray: [47,79,79],
+ darkslategrey: [47,79,79],
+ darkturquoise: [0,206,209],
+ darkviolet: [148,0,211],
+ deeppink: [255,20,147],
+ deepskyblue: [0,191,255],
+ dimgray: [105,105,105],
+ dimgrey: [105,105,105],
+ dodgerblue: [30,144,255],
+ firebrick: [178,34,34],
+ floralwhite: [255,250,240],
+ forestgreen: [34,139,34],
+ fuchsia: [255,0,255],
+ gainsboro: [220,220,220],
+ ghostwhite: [248,248,255],
+ gold: [255,215,0],
+ goldenrod: [218,165,32],
+ gray: [128,128,128],
+ green: [0,128,0],
+ greenyellow: [173,255,47],
+ grey: [128,128,128],
+ honeydew: [240,255,240],
+ hotpink: [255,105,180],
+ indianred: [205,92,92],
+ indigo: [75,0,130],
+ ivory: [255,255,240],
+ khaki: [240,230,140],
+ lavender: [230,230,250],
+ lavenderblush: [255,240,245],
+ lawngreen: [124,252,0],
+ lemonchiffon: [255,250,205],
+ lightblue: [173,216,230],
+ lightcoral: [240,128,128],
+ lightcyan: [224,255,255],
+ lightgoldenrodyellow: [250,250,210],
+ lightgray: [211,211,211],
+ lightgreen: [144,238,144],
+ lightgrey: [211,211,211],
+ lightpink: [255,182,193],
+ lightsalmon: [255,160,122],
+ lightseagreen: [32,178,170],
+ lightskyblue: [135,206,250],
+ lightslategray: [119,136,153],
+ lightslategrey: [119,136,153],
+ lightsteelblue: [176,196,222],
+ lightyellow: [255,255,224],
+ lime: [0,255,0],
+ limegreen: [50,205,50],
+ linen: [250,240,230],
+ magenta: [255,0,255],
+ maroon: [128,0,0],
+ mediumaquamarine: [102,205,170],
+ mediumblue: [0,0,205],
+ mediumorchid: [186,85,211],
+ mediumpurple: [147,112,219],
+ mediumseagreen: [60,179,113],
+ mediumslateblue: [123,104,238],
+ mediumspringgreen: [0,250,154],
+ mediumturquoise: [72,209,204],
+ mediumvioletred: [199,21,133],
+ midnightblue: [25,25,112],
+ mintcream: [245,255,250],
+ mistyrose: [255,228,225],
+ moccasin: [255,228,181],
+ navajowhite: [255,222,173],
+ navy: [0,0,128],
+ oldlace: [253,245,230],
+ olive: [128,128,0],
+ olivedrab: [107,142,35],
+ orange: [255,165,0],
+ orangered: [255,69,0],
+ orchid: [218,112,214],
+ palegoldenrod: [238,232,170],
+ palegreen: [152,251,152],
+ paleturquoise: [175,238,238],
+ palevioletred: [219,112,147],
+ papayawhip: [255,239,213],
+ peachpuff: [255,218,185],
+ peru: [205,133,63],
+ pink: [255,192,203],
+ plum: [221,160,221],
+ powderblue: [176,224,230],
+ purple: [128,0,128],
+ rebeccapurple: [102, 51, 153],
+ red: [255,0,0],
+ rosybrown: [188,143,143],
+ royalblue: [65,105,225],
+ saddlebrown: [139,69,19],
+ salmon: [250,128,114],
+ sandybrown: [244,164,96],
+ seagreen: [46,139,87],
+ seashell: [255,245,238],
+ sienna: [160,82,45],
+ silver: [192,192,192],
+ skyblue: [135,206,235],
+ slateblue: [106,90,205],
+ slategray: [112,128,144],
+ slategrey: [112,128,144],
+ snow: [255,250,250],
+ springgreen: [0,255,127],
+ steelblue: [70,130,180],
+ tan: [210,180,140],
+ teal: [0,128,128],
+ thistle: [216,191,216],
+ tomato: [255,99,71],
+ turquoise: [64,224,208],
+ violet: [238,130,238],
+ wheat: [245,222,179],
+ white: [255,255,255],
+ whitesmoke: [245,245,245],
+ yellow: [255,255,0],
+ yellowgreen: [154,205,50]
+};
+
+var reverseKeywords = {};
+for (var key in cssKeywords) {
+ reverseKeywords[JSON.stringify(cssKeywords[key])] = key;
+}
+
+},{}],5:[function(require,module,exports){
+var conversions = require(4);
+
+var convert = function() {
+ return new Converter();
+}
+
+for (var func in conversions) {
+ // export Raw versions
+ convert[func + "Raw"] = (function(func) {
+ // accept array or plain args
+ return function(arg) {
+ if (typeof arg == "number")
+ arg = Array.prototype.slice.call(arguments);
+ return conversions[func](arg);
+ }
+ })(func);
+
+ var pair = /(\w+)2(\w+)/.exec(func),
+ from = pair[1],
+ to = pair[2];
+
+ // export rgb2hsl and ["rgb"]["hsl"]
+ convert[from] = convert[from] || {};
+
+ convert[from][to] = convert[func] = (function(func) {
+ return function(arg) {
+ if (typeof arg == "number")
+ arg = Array.prototype.slice.call(arguments);
+
+ var val = conversions[func](arg);
+ if (typeof val == "string" || val === undefined)
+ return val; // keyword
+
+ for (var i = 0; i < val.length; i++)
+ val[i] = Math.round(val[i]);
+ return val;
+ }
+ })(func);
+}
+
+
+/* Converter does lazy conversion and caching */
+var Converter = function() {
+ this.convs = {};
+};
+
+/* Either get the values for a space or
+ set the values for a space, depending on args */
+Converter.prototype.routeSpace = function(space, args) {
+ var values = args[0];
+ if (values === undefined) {
+ // color.rgb()
+ return this.getValues(space);
+ }
+ // color.rgb(10, 10, 10)
+ if (typeof values == "number") {
+ values = Array.prototype.slice.call(args);
+ }
+
+ return this.setValues(space, values);
+};
+
+/* Set the values for a space, invalidating cache */
+Converter.prototype.setValues = function(space, values) {
+ this.space = space;
+ this.convs = {};
+ this.convs[space] = values;
+ return this;
+};
+
+/* Get the values for a space. If there's already
+ a conversion for the space, fetch it, otherwise
+ compute it */
+Converter.prototype.getValues = function(space) {
+ var vals = this.convs[space];
+ if (!vals) {
+ var fspace = this.space,
+ from = this.convs[fspace];
+ vals = convert[fspace][space](from);
+
+ this.convs[space] = vals;
+ }
+ return vals;
+};
+
+["rgb", "hsl", "hsv", "cmyk", "keyword"].forEach(function(space) {
+ Converter.prototype[space] = function(vals) {
+ return this.routeSpace(space, arguments);
+ }
+});
+
+module.exports = convert;
+},{"4":4}],6:[function(require,module,exports){
+'use strict'
+
+module.exports = {
+ "aliceblue": [240, 248, 255],
+ "antiquewhite": [250, 235, 215],
+ "aqua": [0, 255, 255],
+ "aquamarine": [127, 255, 212],
+ "azure": [240, 255, 255],
+ "beige": [245, 245, 220],
+ "bisque": [255, 228, 196],
+ "black": [0, 0, 0],
+ "blanchedalmond": [255, 235, 205],
+ "blue": [0, 0, 255],
+ "blueviolet": [138, 43, 226],
+ "brown": [165, 42, 42],
+ "burlywood": [222, 184, 135],
+ "cadetblue": [95, 158, 160],
+ "chartreuse": [127, 255, 0],
+ "chocolate": [210, 105, 30],
+ "coral": [255, 127, 80],
+ "cornflowerblue": [100, 149, 237],
+ "cornsilk": [255, 248, 220],
+ "crimson": [220, 20, 60],
+ "cyan": [0, 255, 255],
+ "darkblue": [0, 0, 139],
+ "darkcyan": [0, 139, 139],
+ "darkgoldenrod": [184, 134, 11],
+ "darkgray": [169, 169, 169],
+ "darkgreen": [0, 100, 0],
+ "darkgrey": [169, 169, 169],
+ "darkkhaki": [189, 183, 107],
+ "darkmagenta": [139, 0, 139],
+ "darkolivegreen": [85, 107, 47],
+ "darkorange": [255, 140, 0],
+ "darkorchid": [153, 50, 204],
+ "darkred": [139, 0, 0],
+ "darksalmon": [233, 150, 122],
+ "darkseagreen": [143, 188, 143],
+ "darkslateblue": [72, 61, 139],
+ "darkslategray": [47, 79, 79],
+ "darkslategrey": [47, 79, 79],
+ "darkturquoise": [0, 206, 209],
+ "darkviolet": [148, 0, 211],
+ "deeppink": [255, 20, 147],
+ "deepskyblue": [0, 191, 255],
+ "dimgray": [105, 105, 105],
+ "dimgrey": [105, 105, 105],
+ "dodgerblue": [30, 144, 255],
+ "firebrick": [178, 34, 34],
+ "floralwhite": [255, 250, 240],
+ "forestgreen": [34, 139, 34],
+ "fuchsia": [255, 0, 255],
+ "gainsboro": [220, 220, 220],
+ "ghostwhite": [248, 248, 255],
+ "gold": [255, 215, 0],
+ "goldenrod": [218, 165, 32],
+ "gray": [128, 128, 128],
+ "green": [0, 128, 0],
+ "greenyellow": [173, 255, 47],
+ "grey": [128, 128, 128],
+ "honeydew": [240, 255, 240],
+ "hotpink": [255, 105, 180],
+ "indianred": [205, 92, 92],
+ "indigo": [75, 0, 130],
+ "ivory": [255, 255, 240],
+ "khaki": [240, 230, 140],
+ "lavender": [230, 230, 250],
+ "lavenderblush": [255, 240, 245],
+ "lawngreen": [124, 252, 0],
+ "lemonchiffon": [255, 250, 205],
+ "lightblue": [173, 216, 230],
+ "lightcoral": [240, 128, 128],
+ "lightcyan": [224, 255, 255],
+ "lightgoldenrodyellow": [250, 250, 210],
+ "lightgray": [211, 211, 211],
+ "lightgreen": [144, 238, 144],
+ "lightgrey": [211, 211, 211],
+ "lightpink": [255, 182, 193],
+ "lightsalmon": [255, 160, 122],
+ "lightseagreen": [32, 178, 170],
+ "lightskyblue": [135, 206, 250],
+ "lightslategray": [119, 136, 153],
+ "lightslategrey": [119, 136, 153],
+ "lightsteelblue": [176, 196, 222],
+ "lightyellow": [255, 255, 224],
+ "lime": [0, 255, 0],
+ "limegreen": [50, 205, 50],
+ "linen": [250, 240, 230],
+ "magenta": [255, 0, 255],
+ "maroon": [128, 0, 0],
+ "mediumaquamarine": [102, 205, 170],
+ "mediumblue": [0, 0, 205],
+ "mediumorchid": [186, 85, 211],
+ "mediumpurple": [147, 112, 219],
+ "mediumseagreen": [60, 179, 113],
+ "mediumslateblue": [123, 104, 238],
+ "mediumspringgreen": [0, 250, 154],
+ "mediumturquoise": [72, 209, 204],
+ "mediumvioletred": [199, 21, 133],
+ "midnightblue": [25, 25, 112],
+ "mintcream": [245, 255, 250],
+ "mistyrose": [255, 228, 225],
+ "moccasin": [255, 228, 181],
+ "navajowhite": [255, 222, 173],
+ "navy": [0, 0, 128],
+ "oldlace": [253, 245, 230],
+ "olive": [128, 128, 0],
+ "olivedrab": [107, 142, 35],
+ "orange": [255, 165, 0],
+ "orangered": [255, 69, 0],
+ "orchid": [218, 112, 214],
+ "palegoldenrod": [238, 232, 170],
+ "palegreen": [152, 251, 152],
+ "paleturquoise": [175, 238, 238],
+ "palevioletred": [219, 112, 147],
+ "papayawhip": [255, 239, 213],
+ "peachpuff": [255, 218, 185],
+ "peru": [205, 133, 63],
+ "pink": [255, 192, 203],
+ "plum": [221, 160, 221],
+ "powderblue": [176, 224, 230],
+ "purple": [128, 0, 128],
+ "rebeccapurple": [102, 51, 153],
+ "red": [255, 0, 0],
+ "rosybrown": [188, 143, 143],
+ "royalblue": [65, 105, 225],
+ "saddlebrown": [139, 69, 19],
+ "salmon": [250, 128, 114],
+ "sandybrown": [244, 164, 96],
+ "seagreen": [46, 139, 87],
+ "seashell": [255, 245, 238],
+ "sienna": [160, 82, 45],
+ "silver": [192, 192, 192],
+ "skyblue": [135, 206, 235],
+ "slateblue": [106, 90, 205],
+ "slategray": [112, 128, 144],
+ "slategrey": [112, 128, 144],
+ "snow": [255, 250, 250],
+ "springgreen": [0, 255, 127],
+ "steelblue": [70, 130, 180],
+ "tan": [210, 180, 140],
+ "teal": [0, 128, 128],
+ "thistle": [216, 191, 216],
+ "tomato": [255, 99, 71],
+ "turquoise": [64, 224, 208],
+ "violet": [238, 130, 238],
+ "wheat": [245, 222, 179],
+ "white": [255, 255, 255],
+ "whitesmoke": [245, 245, 245],
+ "yellow": [255, 255, 0],
+ "yellowgreen": [154, 205, 50]
+};
+
+},{}],7:[function(require,module,exports){
+/**
+ * @namespace Chart
+ */
+var Chart = require(29)();
+
+Chart.helpers = require(45);
+
+// @todo dispatch these helpers into appropriated helpers/helpers.* file and write unit tests!
+require(27)(Chart);
+
+Chart.defaults = require(25);
+Chart.Element = require(26);
+Chart.elements = require(40);
+Chart.Interaction = require(28);
+Chart.platform = require(48);
+
+require(31)(Chart);
+require(22)(Chart);
+require(23)(Chart);
+require(24)(Chart);
+require(30)(Chart);
+require(33)(Chart);
+require(32)(Chart);
+require(35)(Chart);
+
+require(54)(Chart);
+require(52)(Chart);
+require(53)(Chart);
+require(55)(Chart);
+require(56)(Chart);
+require(57)(Chart);
+
+// Controllers must be loaded after elements
+// See Chart.core.datasetController.dataElementType
+require(15)(Chart);
+require(16)(Chart);
+require(17)(Chart);
+require(18)(Chart);
+require(19)(Chart);
+require(20)(Chart);
+require(21)(Chart);
+
+require(8)(Chart);
+require(9)(Chart);
+require(10)(Chart);
+require(11)(Chart);
+require(12)(Chart);
+require(13)(Chart);
+require(14)(Chart);
+
+// Loading built-it plugins
+var plugins = [];
+
+plugins.push(
+ require(49)(Chart),
+ require(50)(Chart),
+ require(51)(Chart)
+);
+
+Chart.plugins.register(plugins);
+
+Chart.platform.initialize();
+
+module.exports = Chart;
+if (typeof window !== 'undefined') {
+ window.Chart = Chart;
+}
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.canvas instead.
+ * @namespace Chart.canvasHelpers
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+Chart.canvasHelpers = Chart.helpers.canvas;
+
+},{"10":10,"11":11,"12":12,"13":13,"14":14,"15":15,"16":16,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"26":26,"27":27,"28":28,"29":29,"30":30,"31":31,"32":32,"33":33,"35":35,"40":40,"45":45,"48":48,"49":49,"50":50,"51":51,"52":52,"53":53,"54":54,"55":55,"56":56,"57":57,"8":8,"9":9}],8:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Bar = function(context, config) {
+ config.type = 'bar';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],9:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Bubble = function(context, config) {
+ config.type = 'bubble';
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],10:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Doughnut = function(context, config) {
+ config.type = 'doughnut';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],11:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Line = function(context, config) {
+ config.type = 'line';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],12:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.PolarArea = function(context, config) {
+ config.type = 'polarArea';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],13:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ Chart.Radar = function(context, config) {
+ config.type = 'radar';
+
+ return new Chart(context, config);
+ };
+
+};
+
+},{}],14:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+ Chart.Scatter = function(context, config) {
+ config.type = 'scatter';
+ return new Chart(context, config);
+ };
+};
+
+},{}],15:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('bar', {
+ hover: {
+ mode: 'label'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'category',
+
+ // Specific to Bar Controller
+ categoryPercentage: 0.8,
+ barPercentage: 0.9,
+
+ // offset settings
+ offset: true,
+
+ // grid line settings
+ gridLines: {
+ offsetGridLines: true
+ }
+ }],
+
+ yAxes: [{
+ type: 'linear'
+ }]
+ }
+});
+
+defaults._set('horizontalBar', {
+ hover: {
+ mode: 'index',
+ axis: 'y'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'linear',
+ position: 'bottom'
+ }],
+
+ yAxes: [{
+ position: 'left',
+ type: 'category',
+
+ // Specific to Horizontal Bar Controller
+ categoryPercentage: 0.8,
+ barPercentage: 0.9,
+
+ // offset settings
+ offset: true,
+
+ // grid line settings
+ gridLines: {
+ offsetGridLines: true
+ }
+ }]
+ },
+
+ elements: {
+ rectangle: {
+ borderSkipped: 'left'
+ }
+ },
+
+ tooltips: {
+ callbacks: {
+ title: function(item, data) {
+ // Pick first xLabel for now
+ var title = '';
+
+ if (item.length > 0) {
+ if (item[0].yLabel) {
+ title = item[0].yLabel;
+ } else if (data.labels.length > 0 && item[0].index < data.labels.length) {
+ title = data.labels[item[0].index];
+ }
+ }
+
+ return title;
+ },
+
+ label: function(item, data) {
+ var datasetLabel = data.datasets[item.datasetIndex].label || '';
+ return datasetLabel + ': ' + item.xLabel;
+ }
+ },
+ mode: 'index',
+ axis: 'y'
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.bar = Chart.DatasetController.extend({
+
+ dataElementType: elements.Rectangle,
+
+ initialize: function() {
+ var me = this;
+ var meta;
+
+ Chart.DatasetController.prototype.initialize.apply(me, arguments);
+
+ meta = me.getMeta();
+ meta.stack = me.getDataset().stack;
+ meta.bar = true;
+ },
+
+ update: function(reset) {
+ var me = this;
+ var rects = me.getMeta().data;
+ var i, ilen;
+
+ me._ruler = me.getRuler();
+
+ for (i = 0, ilen = rects.length; i < ilen; ++i) {
+ me.updateElement(rects[i], i, reset);
+ }
+ },
+
+ updateElement: function(rectangle, index, reset) {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var dataset = me.getDataset();
+ var custom = rectangle.custom || {};
+ var rectangleOptions = chart.options.elements.rectangle;
+
+ rectangle._xScale = me.getScaleForId(meta.xAxisID);
+ rectangle._yScale = me.getScaleForId(meta.yAxisID);
+ rectangle._datasetIndex = me.index;
+ rectangle._index = index;
+
+ rectangle._model = {
+ datasetLabel: dataset.label,
+ label: chart.data.labels[index],
+ borderSkipped: custom.borderSkipped ? custom.borderSkipped : rectangleOptions.borderSkipped,
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.backgroundColor, index, rectangleOptions.backgroundColor),
+ borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.borderColor, index, rectangleOptions.borderColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.borderWidth, index, rectangleOptions.borderWidth)
+ };
+
+ me.updateElementGeometry(rectangle, index, reset);
+
+ rectangle.pivot();
+ },
+
+ /**
+ * @private
+ */
+ updateElementGeometry: function(rectangle, index, reset) {
+ var me = this;
+ var model = rectangle._model;
+ var vscale = me.getValueScale();
+ var base = vscale.getBasePixel();
+ var horizontal = vscale.isHorizontal();
+ var ruler = me._ruler || me.getRuler();
+ var vpixels = me.calculateBarValuePixels(me.index, index);
+ var ipixels = me.calculateBarIndexPixels(me.index, index, ruler);
+
+ model.horizontal = horizontal;
+ model.base = reset ? base : vpixels.base;
+ model.x = horizontal ? reset ? base : vpixels.head : ipixels.center;
+ model.y = horizontal ? ipixels.center : reset ? base : vpixels.head;
+ model.height = horizontal ? ipixels.size : undefined;
+ model.width = horizontal ? undefined : ipixels.size;
+ },
+
+ /**
+ * @private
+ */
+ getValueScaleId: function() {
+ return this.getMeta().yAxisID;
+ },
+
+ /**
+ * @private
+ */
+ getIndexScaleId: function() {
+ return this.getMeta().xAxisID;
+ },
+
+ /**
+ * @private
+ */
+ getValueScale: function() {
+ return this.getScaleForId(this.getValueScaleId());
+ },
+
+ /**
+ * @private
+ */
+ getIndexScale: function() {
+ return this.getScaleForId(this.getIndexScaleId());
+ },
+
+ /**
+ * Returns the effective number of stacks based on groups and bar visibility.
+ * @private
+ */
+ getStackCount: function(last) {
+ var me = this;
+ var chart = me.chart;
+ var scale = me.getIndexScale();
+ var stacked = scale.options.stacked;
+ var ilen = last === undefined ? chart.data.datasets.length : last + 1;
+ var stacks = [];
+ var i, meta;
+
+ for (i = 0; i < ilen; ++i) {
+ meta = chart.getDatasetMeta(i);
+ if (meta.bar && chart.isDatasetVisible(i) &&
+ (stacked === false ||
+ (stacked === true && stacks.indexOf(meta.stack) === -1) ||
+ (stacked === undefined && (meta.stack === undefined || stacks.indexOf(meta.stack) === -1)))) {
+ stacks.push(meta.stack);
+ }
+ }
+
+ return stacks.length;
+ },
+
+ /**
+ * Returns the stack index for the given dataset based on groups and bar visibility.
+ * @private
+ */
+ getStackIndex: function(datasetIndex) {
+ return this.getStackCount(datasetIndex) - 1;
+ },
+
+ /**
+ * @private
+ */
+ getRuler: function() {
+ var me = this;
+ var scale = me.getIndexScale();
+ var stackCount = me.getStackCount();
+ var datasetIndex = me.index;
+ var pixels = [];
+ var isHorizontal = scale.isHorizontal();
+ var start = isHorizontal ? scale.left : scale.top;
+ var end = start + (isHorizontal ? scale.width : scale.height);
+ var i, ilen;
+
+ for (i = 0, ilen = me.getMeta().data.length; i < ilen; ++i) {
+ pixels.push(scale.getPixelForValue(null, i, datasetIndex));
+ }
+
+ return {
+ pixels: pixels,
+ start: start,
+ end: end,
+ stackCount: stackCount,
+ scale: scale
+ };
+ },
+
+ /**
+ * Note: pixel values are not clamped to the scale area.
+ * @private
+ */
+ calculateBarValuePixels: function(datasetIndex, index) {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var scale = me.getValueScale();
+ var datasets = chart.data.datasets;
+ var value = scale.getRightValue(datasets[datasetIndex].data[index]);
+ var stacked = scale.options.stacked;
+ var stack = meta.stack;
+ var start = 0;
+ var i, imeta, ivalue, base, head, size;
+
+ if (stacked || (stacked === undefined && stack !== undefined)) {
+ for (i = 0; i < datasetIndex; ++i) {
+ imeta = chart.getDatasetMeta(i);
+
+ if (imeta.bar &&
+ imeta.stack === stack &&
+ imeta.controller.getValueScaleId() === scale.id &&
+ chart.isDatasetVisible(i)) {
+
+ ivalue = scale.getRightValue(datasets[i].data[index]);
+ if ((value < 0 && ivalue < 0) || (value >= 0 && ivalue > 0)) {
+ start += ivalue;
+ }
+ }
+ }
+ }
+
+ base = scale.getPixelForValue(start);
+ head = scale.getPixelForValue(start + value);
+ size = (head - base) / 2;
+
+ return {
+ size: size,
+ base: base,
+ head: head,
+ center: head + size / 2
+ };
+ },
+
+ /**
+ * @private
+ */
+ calculateBarIndexPixels: function(datasetIndex, index, ruler) {
+ var me = this;
+ var options = ruler.scale.options;
+ var stackIndex = me.getStackIndex(datasetIndex);
+ var pixels = ruler.pixels;
+ var base = pixels[index];
+ var length = pixels.length;
+ var start = ruler.start;
+ var end = ruler.end;
+ var leftSampleSize, rightSampleSize, leftCategorySize, rightCategorySize, fullBarSize, size;
+
+ if (length === 1) {
+ leftSampleSize = base > start ? base - start : end - base;
+ rightSampleSize = base < end ? end - base : base - start;
+ } else {
+ if (index > 0) {
+ leftSampleSize = (base - pixels[index - 1]) / 2;
+ if (index === length - 1) {
+ rightSampleSize = leftSampleSize;
+ }
+ }
+ if (index < length - 1) {
+ rightSampleSize = (pixels[index + 1] - base) / 2;
+ if (index === 0) {
+ leftSampleSize = rightSampleSize;
+ }
+ }
+ }
+
+ leftCategorySize = leftSampleSize * options.categoryPercentage;
+ rightCategorySize = rightSampleSize * options.categoryPercentage;
+ fullBarSize = (leftCategorySize + rightCategorySize) / ruler.stackCount;
+ size = fullBarSize * options.barPercentage;
+
+ size = Math.min(
+ helpers.valueOrDefault(options.barThickness, size),
+ helpers.valueOrDefault(options.maxBarThickness, Infinity));
+
+ base -= leftCategorySize;
+ base += fullBarSize * stackIndex;
+ base += (fullBarSize - size) / 2;
+
+ return {
+ size: size,
+ base: base,
+ head: base + size,
+ center: base + size / 2
+ };
+ },
+
+ draw: function() {
+ var me = this;
+ var chart = me.chart;
+ var scale = me.getValueScale();
+ var rects = me.getMeta().data;
+ var dataset = me.getDataset();
+ var ilen = rects.length;
+ var i = 0;
+
+ helpers.canvas.clipArea(chart.ctx, chart.chartArea);
+
+ for (; i < ilen; ++i) {
+ if (!isNaN(scale.getRightValue(dataset.data[i]))) {
+ rects[i].draw();
+ }
+ }
+
+ helpers.canvas.unclipArea(chart.ctx);
+ },
+
+ setHoverStyle: function(rectangle) {
+ var dataset = this.chart.data.datasets[rectangle._datasetIndex];
+ var index = rectangle._index;
+ var custom = rectangle.custom || {};
+ var model = rectangle._model;
+
+ model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.valueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.valueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.valueAtIndexOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
+ },
+
+ removeHoverStyle: function(rectangle) {
+ var dataset = this.chart.data.datasets[rectangle._datasetIndex];
+ var index = rectangle._index;
+ var custom = rectangle.custom || {};
+ var model = rectangle._model;
+ var rectangleElementOptions = this.chart.options.elements.rectangle;
+
+ model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.backgroundColor, index, rectangleElementOptions.backgroundColor);
+ model.borderColor = custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.borderColor, index, rectangleElementOptions.borderColor);
+ model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.borderWidth, index, rectangleElementOptions.borderWidth);
+ }
+ });
+
+ Chart.controllers.horizontalBar = Chart.controllers.bar.extend({
+ /**
+ * @private
+ */
+ getValueScaleId: function() {
+ return this.getMeta().xAxisID;
+ },
+
+ /**
+ * @private
+ */
+ getIndexScaleId: function() {
+ return this.getMeta().yAxisID;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],16:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('bubble', {
+ hover: {
+ mode: 'single'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'linear', // bubble should probably use a linear scale by default
+ position: 'bottom',
+ id: 'x-axis-0' // need an ID so datasets can reference the scale
+ }],
+ yAxes: [{
+ type: 'linear',
+ position: 'left',
+ id: 'y-axis-0'
+ }]
+ },
+
+ tooltips: {
+ callbacks: {
+ title: function() {
+ // Title doesn't make sense for scatter since we format the data as a point
+ return '';
+ },
+ label: function(item, data) {
+ var datasetLabel = data.datasets[item.datasetIndex].label || '';
+ var dataPoint = data.datasets[item.datasetIndex].data[item.index];
+ return datasetLabel + ': (' + item.xLabel + ', ' + item.yLabel + ', ' + dataPoint.r + ')';
+ }
+ }
+ }
+});
+
+
+module.exports = function(Chart) {
+
+ Chart.controllers.bubble = Chart.DatasetController.extend({
+ /**
+ * @protected
+ */
+ dataElementType: elements.Point,
+
+ /**
+ * @protected
+ */
+ update: function(reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var points = meta.data;
+
+ // Update Points
+ helpers.each(points, function(point, index) {
+ me.updateElement(point, index, reset);
+ });
+ },
+
+ /**
+ * @protected
+ */
+ updateElement: function(point, index, reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var custom = point.custom || {};
+ var xScale = me.getScaleForId(meta.xAxisID);
+ var yScale = me.getScaleForId(meta.yAxisID);
+ var options = me._resolveElementOptions(point, index);
+ var data = me.getDataset().data[index];
+ var dsIndex = me.index;
+
+ var x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex);
+ var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex);
+
+ point._xScale = xScale;
+ point._yScale = yScale;
+ point._options = options;
+ point._datasetIndex = dsIndex;
+ point._index = index;
+ point._model = {
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderWidth: options.borderWidth,
+ hitRadius: options.hitRadius,
+ pointStyle: options.pointStyle,
+ radius: reset ? 0 : options.radius,
+ skip: custom.skip || isNaN(x) || isNaN(y),
+ x: x,
+ y: y,
+ };
+
+ point.pivot();
+ },
+
+ /**
+ * @protected
+ */
+ setHoverStyle: function(point) {
+ var model = point._model;
+ var options = point._options;
+
+ model.backgroundColor = helpers.valueOrDefault(options.hoverBackgroundColor, helpers.getHoverColor(options.backgroundColor));
+ model.borderColor = helpers.valueOrDefault(options.hoverBorderColor, helpers.getHoverColor(options.borderColor));
+ model.borderWidth = helpers.valueOrDefault(options.hoverBorderWidth, options.borderWidth);
+ model.radius = options.radius + options.hoverRadius;
+ },
+
+ /**
+ * @protected
+ */
+ removeHoverStyle: function(point) {
+ var model = point._model;
+ var options = point._options;
+
+ model.backgroundColor = options.backgroundColor;
+ model.borderColor = options.borderColor;
+ model.borderWidth = options.borderWidth;
+ model.radius = options.radius;
+ },
+
+ /**
+ * @private
+ */
+ _resolveElementOptions: function(point, index) {
+ var me = this;
+ var chart = me.chart;
+ var datasets = chart.data.datasets;
+ var dataset = datasets[me.index];
+ var custom = point.custom || {};
+ var options = chart.options.elements.point;
+ var resolve = helpers.options.resolve;
+ var data = dataset.data[index];
+ var values = {};
+ var i, ilen, key;
+
+ // Scriptable options
+ var context = {
+ chart: chart,
+ dataIndex: index,
+ dataset: dataset,
+ datasetIndex: me.index
+ };
+
+ var keys = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderWidth',
+ 'hoverBackgroundColor',
+ 'hoverBorderColor',
+ 'hoverBorderWidth',
+ 'hoverRadius',
+ 'hitRadius',
+ 'pointStyle'
+ ];
+
+ for (i = 0, ilen = keys.length; i < ilen; ++i) {
+ key = keys[i];
+ values[key] = resolve([
+ custom[key],
+ dataset[key],
+ options[key]
+ ], context, index);
+ }
+
+ // Custom radius resolution
+ values.radius = resolve([
+ custom.radius,
+ data ? data.r : undefined,
+ dataset.radius,
+ options.radius
+ ], context, index);
+
+ return values;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],17:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('doughnut', {
+ animation: {
+ // Boolean - Whether we animate the rotation of the Doughnut
+ animateRotate: true,
+ // Boolean - Whether we animate scaling the Doughnut from the centre
+ animateScale: false
+ },
+ hover: {
+ mode: 'single'
+ },
+ legendCallback: function(chart) {
+ var text = [];
+ text.push('<ul class="' + chart.id + '-legend">');
+
+ var data = chart.data;
+ var datasets = data.datasets;
+ var labels = data.labels;
+
+ if (datasets.length) {
+ for (var i = 0; i < datasets[0].data.length; ++i) {
+ text.push('<li><span style="background-color:' + datasets[0].backgroundColor[i] + '"></span>');
+ if (labels[i]) {
+ text.push(labels[i]);
+ }
+ text.push('</li>');
+ }
+ }
+
+ text.push('</ul>');
+ return text.join('');
+ },
+ legend: {
+ labels: {
+ generateLabels: function(chart) {
+ var data = chart.data;
+ if (data.labels.length && data.datasets.length) {
+ return data.labels.map(function(label, i) {
+ var meta = chart.getDatasetMeta(0);
+ var ds = data.datasets[0];
+ var arc = meta.data[i];
+ var custom = arc && arc.custom || {};
+ var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+ var arcOpts = chart.options.elements.arc;
+ var fill = custom.backgroundColor ? custom.backgroundColor : valueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor);
+ var stroke = custom.borderColor ? custom.borderColor : valueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor);
+ var bw = custom.borderWidth ? custom.borderWidth : valueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth);
+
+ return {
+ text: label,
+ fillStyle: fill,
+ strokeStyle: stroke,
+ lineWidth: bw,
+ hidden: isNaN(ds.data[i]) || meta.data[i].hidden,
+
+ // Extra data used for toggling the correct item
+ index: i
+ };
+ });
+ }
+ return [];
+ }
+ },
+
+ onClick: function(e, legendItem) {
+ var index = legendItem.index;
+ var chart = this.chart;
+ var i, ilen, meta;
+
+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
+ meta = chart.getDatasetMeta(i);
+ // toggle visibility of index if exists
+ if (meta.data[index]) {
+ meta.data[index].hidden = !meta.data[index].hidden;
+ }
+ }
+
+ chart.update();
+ }
+ },
+
+ // The percentage of the chart that we cut out of the middle.
+ cutoutPercentage: 50,
+
+ // The rotation of the chart, where the first data arc begins.
+ rotation: Math.PI * -0.5,
+
+ // The total circumference of the chart.
+ circumference: Math.PI * 2.0,
+
+ // Need to override these to give a nice default
+ tooltips: {
+ callbacks: {
+ title: function() {
+ return '';
+ },
+ label: function(tooltipItem, data) {
+ var dataLabel = data.labels[tooltipItem.index];
+ var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
+
+ if (helpers.isArray(dataLabel)) {
+ // show value on first line of multiline label
+ // need to clone because we are changing the value
+ dataLabel = dataLabel.slice();
+ dataLabel[0] += value;
+ } else {
+ dataLabel += value;
+ }
+
+ return dataLabel;
+ }
+ }
+ }
+});
+
+defaults._set('pie', helpers.clone(defaults.doughnut));
+defaults._set('pie', {
+ cutoutPercentage: 0
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.doughnut = Chart.controllers.pie = Chart.DatasetController.extend({
+
+ dataElementType: elements.Arc,
+
+ linkScales: helpers.noop,
+
+ // Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly
+ getRingIndex: function(datasetIndex) {
+ var ringIndex = 0;
+
+ for (var j = 0; j < datasetIndex; ++j) {
+ if (this.chart.isDatasetVisible(j)) {
+ ++ringIndex;
+ }
+ }
+
+ return ringIndex;
+ },
+
+ update: function(reset) {
+ var me = this;
+ var chart = me.chart;
+ var chartArea = chart.chartArea;
+ var opts = chart.options;
+ var arcOpts = opts.elements.arc;
+ var availableWidth = chartArea.right - chartArea.left - arcOpts.borderWidth;
+ var availableHeight = chartArea.bottom - chartArea.top - arcOpts.borderWidth;
+ var minSize = Math.min(availableWidth, availableHeight);
+ var offset = {x: 0, y: 0};
+ var meta = me.getMeta();
+ var cutoutPercentage = opts.cutoutPercentage;
+ var circumference = opts.circumference;
+
+ // If the chart's circumference isn't a full circle, calculate minSize as a ratio of the width/height of the arc
+ if (circumference < Math.PI * 2.0) {
+ var startAngle = opts.rotation % (Math.PI * 2.0);
+ startAngle += Math.PI * 2.0 * (startAngle >= Math.PI ? -1 : startAngle < -Math.PI ? 1 : 0);
+ var endAngle = startAngle + circumference;
+ var start = {x: Math.cos(startAngle), y: Math.sin(startAngle)};
+ var end = {x: Math.cos(endAngle), y: Math.sin(endAngle)};
+ var contains0 = (startAngle <= 0 && endAngle >= 0) || (startAngle <= Math.PI * 2.0 && Math.PI * 2.0 <= endAngle);
+ var contains90 = (startAngle <= Math.PI * 0.5 && Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 2.5 && Math.PI * 2.5 <= endAngle);
+ var contains180 = (startAngle <= -Math.PI && -Math.PI <= endAngle) || (startAngle <= Math.PI && Math.PI <= endAngle);
+ var contains270 = (startAngle <= -Math.PI * 0.5 && -Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 1.5 && Math.PI * 1.5 <= endAngle);
+ var cutout = cutoutPercentage / 100.0;
+ var min = {x: contains180 ? -1 : Math.min(start.x * (start.x < 0 ? 1 : cutout), end.x * (end.x < 0 ? 1 : cutout)), y: contains270 ? -1 : Math.min(start.y * (start.y < 0 ? 1 : cutout), end.y * (end.y < 0 ? 1 : cutout))};
+ var max = {x: contains0 ? 1 : Math.max(start.x * (start.x > 0 ? 1 : cutout), end.x * (end.x > 0 ? 1 : cutout)), y: contains90 ? 1 : Math.max(start.y * (start.y > 0 ? 1 : cutout), end.y * (end.y > 0 ? 1 : cutout))};
+ var size = {width: (max.x - min.x) * 0.5, height: (max.y - min.y) * 0.5};
+ minSize = Math.min(availableWidth / size.width, availableHeight / size.height);
+ offset = {x: (max.x + min.x) * -0.5, y: (max.y + min.y) * -0.5};
+ }
+
+ chart.borderWidth = me.getMaxBorderWidth(meta.data);
+ chart.outerRadius = Math.max((minSize - chart.borderWidth) / 2, 0);
+ chart.innerRadius = Math.max(cutoutPercentage ? (chart.outerRadius / 100) * (cutoutPercentage) : 0, 0);
+ chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
+ chart.offsetX = offset.x * chart.outerRadius;
+ chart.offsetY = offset.y * chart.outerRadius;
+
+ meta.total = me.calculateTotal();
+
+ me.outerRadius = chart.outerRadius - (chart.radiusLength * me.getRingIndex(me.index));
+ me.innerRadius = Math.max(me.outerRadius - chart.radiusLength, 0);
+
+ helpers.each(meta.data, function(arc, index) {
+ me.updateElement(arc, index, reset);
+ });
+ },
+
+ updateElement: function(arc, index, reset) {
+ var me = this;
+ var chart = me.chart;
+ var chartArea = chart.chartArea;
+ var opts = chart.options;
+ var animationOpts = opts.animation;
+ var centerX = (chartArea.left + chartArea.right) / 2;
+ var centerY = (chartArea.top + chartArea.bottom) / 2;
+ var startAngle = opts.rotation; // non reset case handled later
+ var endAngle = opts.rotation; // non reset case handled later
+ var dataset = me.getDataset();
+ var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumference / (2.0 * Math.PI));
+ var innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius;
+ var outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius;
+ var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+
+ helpers.extend(arc, {
+ // Utility
+ _datasetIndex: me.index,
+ _index: index,
+
+ // Desired view properties
+ _model: {
+ x: centerX + chart.offsetX,
+ y: centerY + chart.offsetY,
+ startAngle: startAngle,
+ endAngle: endAngle,
+ circumference: circumference,
+ outerRadius: outerRadius,
+ innerRadius: innerRadius,
+ label: valueAtIndexOrDefault(dataset.label, index, chart.data.labels[index])
+ }
+ });
+
+ var model = arc._model;
+ // Resets the visual styles
+ this.removeHoverStyle(arc);
+
+ // Set correct angles if not resetting
+ if (!reset || !animationOpts.animateRotate) {
+ if (index === 0) {
+ model.startAngle = opts.rotation;
+ } else {
+ model.startAngle = me.getMeta().data[index - 1]._model.endAngle;
+ }
+
+ model.endAngle = model.startAngle + model.circumference;
+ }
+
+ arc.pivot();
+ },
+
+ removeHoverStyle: function(arc) {
+ Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc);
+ },
+
+ calculateTotal: function() {
+ var dataset = this.getDataset();
+ var meta = this.getMeta();
+ var total = 0;
+ var value;
+
+ helpers.each(meta.data, function(element, index) {
+ value = dataset.data[index];
+ if (!isNaN(value) && !element.hidden) {
+ total += Math.abs(value);
+ }
+ });
+
+ /* if (total === 0) {
+ total = NaN;
+ }*/
+
+ return total;
+ },
+
+ calculateCircumference: function(value) {
+ var total = this.getMeta().total;
+ if (total > 0 && !isNaN(value)) {
+ return (Math.PI * 2.0) * (value / total);
+ }
+ return 0;
+ },
+
+ // gets the max border or hover width to properly scale pie charts
+ getMaxBorderWidth: function(arcs) {
+ var max = 0;
+ var index = this.index;
+ var length = arcs.length;
+ var borderWidth;
+ var hoverWidth;
+
+ for (var i = 0; i < length; i++) {
+ borderWidth = arcs[i]._model ? arcs[i]._model.borderWidth : 0;
+ hoverWidth = arcs[i]._chart ? arcs[i]._chart.config.data.datasets[index].hoverBorderWidth : 0;
+
+ max = borderWidth > max ? borderWidth : max;
+ max = hoverWidth > max ? hoverWidth : max;
+ }
+ return max;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],18:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('line', {
+ showLines: true,
+ spanGaps: false,
+
+ hover: {
+ mode: 'label'
+ },
+
+ scales: {
+ xAxes: [{
+ type: 'category',
+ id: 'x-axis-0'
+ }],
+ yAxes: [{
+ type: 'linear',
+ id: 'y-axis-0'
+ }]
+ }
+});
+
+module.exports = function(Chart) {
+
+ function lineEnabled(dataset, options) {
+ return helpers.valueOrDefault(dataset.showLine, options.showLines);
+ }
+
+ Chart.controllers.line = Chart.DatasetController.extend({
+
+ datasetElementType: elements.Line,
+
+ dataElementType: elements.Point,
+
+ update: function(reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var line = meta.dataset;
+ var points = meta.data || [];
+ var options = me.chart.options;
+ var lineElementOptions = options.elements.line;
+ var scale = me.getScaleForId(meta.yAxisID);
+ var i, ilen, custom;
+ var dataset = me.getDataset();
+ var showLine = lineEnabled(dataset, options);
+
+ // Update Line
+ if (showLine) {
+ custom = line.custom || {};
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
+ dataset.lineTension = dataset.tension;
+ }
+
+ // Utility
+ line._scale = scale;
+ line._datasetIndex = me.index;
+ // Data
+ line._children = points;
+ // Model
+ line._model = {
+ // Appearance
+ // The default behavior of lines is to break at null values, according
+ // to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
+ // This option gives lines the ability to span gaps
+ spanGaps: dataset.spanGaps ? dataset.spanGaps : options.spanGaps,
+ tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
+ borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor),
+ borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle),
+ borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash),
+ borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset),
+ borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle),
+ fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill),
+ steppedLine: custom.steppedLine ? custom.steppedLine : helpers.valueOrDefault(dataset.steppedLine, lineElementOptions.stepped),
+ cubicInterpolationMode: custom.cubicInterpolationMode ? custom.cubicInterpolationMode : helpers.valueOrDefault(dataset.cubicInterpolationMode, lineElementOptions.cubicInterpolationMode),
+ };
+
+ line.pivot();
+ }
+
+ // Update Points
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ me.updateElement(points[i], i, reset);
+ }
+
+ if (showLine && line._model.tension !== 0) {
+ me.updateBezierControlPoints();
+ }
+
+ // Now pivot the point for animation
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ points[i].pivot();
+ }
+ },
+
+ getPointBackgroundColor: function(point, index) {
+ var backgroundColor = this.chart.options.elements.point.backgroundColor;
+ var dataset = this.getDataset();
+ var custom = point.custom || {};
+
+ if (custom.backgroundColor) {
+ backgroundColor = custom.backgroundColor;
+ } else if (dataset.pointBackgroundColor) {
+ backgroundColor = helpers.valueAtIndexOrDefault(dataset.pointBackgroundColor, index, backgroundColor);
+ } else if (dataset.backgroundColor) {
+ backgroundColor = dataset.backgroundColor;
+ }
+
+ return backgroundColor;
+ },
+
+ getPointBorderColor: function(point, index) {
+ var borderColor = this.chart.options.elements.point.borderColor;
+ var dataset = this.getDataset();
+ var custom = point.custom || {};
+
+ if (custom.borderColor) {
+ borderColor = custom.borderColor;
+ } else if (dataset.pointBorderColor) {
+ borderColor = helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, borderColor);
+ } else if (dataset.borderColor) {
+ borderColor = dataset.borderColor;
+ }
+
+ return borderColor;
+ },
+
+ getPointBorderWidth: function(point, index) {
+ var borderWidth = this.chart.options.elements.point.borderWidth;
+ var dataset = this.getDataset();
+ var custom = point.custom || {};
+
+ if (!isNaN(custom.borderWidth)) {
+ borderWidth = custom.borderWidth;
+ } else if (!isNaN(dataset.pointBorderWidth) || helpers.isArray(dataset.pointBorderWidth)) {
+ borderWidth = helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, borderWidth);
+ } else if (!isNaN(dataset.borderWidth)) {
+ borderWidth = dataset.borderWidth;
+ }
+
+ return borderWidth;
+ },
+
+ updateElement: function(point, index, reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var custom = point.custom || {};
+ var dataset = me.getDataset();
+ var datasetIndex = me.index;
+ var value = dataset.data[index];
+ var yScale = me.getScaleForId(meta.yAxisID);
+ var xScale = me.getScaleForId(meta.xAxisID);
+ var pointOptions = me.chart.options.elements.point;
+ var x, y;
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
+ dataset.pointRadius = dataset.radius;
+ }
+ if ((dataset.hitRadius !== undefined) && (dataset.pointHitRadius === undefined)) {
+ dataset.pointHitRadius = dataset.hitRadius;
+ }
+
+ x = xScale.getPixelForValue(typeof value === 'object' ? value : NaN, index, datasetIndex);
+ y = reset ? yScale.getBasePixel() : me.calculatePointY(value, index, datasetIndex);
+
+ // Utility
+ point._xScale = xScale;
+ point._yScale = yScale;
+ point._datasetIndex = datasetIndex;
+ point._index = index;
+
+ // Desired view properties
+ point._model = {
+ x: x,
+ y: y,
+ skip: custom.skip || isNaN(x) || isNaN(y),
+ // Appearance
+ radius: custom.radius || helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointOptions.radius),
+ pointStyle: custom.pointStyle || helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointOptions.pointStyle),
+ backgroundColor: me.getPointBackgroundColor(point, index),
+ borderColor: me.getPointBorderColor(point, index),
+ borderWidth: me.getPointBorderWidth(point, index),
+ tension: meta.dataset._model ? meta.dataset._model.tension : 0,
+ steppedLine: meta.dataset._model ? meta.dataset._model.steppedLine : false,
+ // Tooltip
+ hitRadius: custom.hitRadius || helpers.valueAtIndexOrDefault(dataset.pointHitRadius, index, pointOptions.hitRadius)
+ };
+ },
+
+ calculatePointY: function(value, index, datasetIndex) {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var yScale = me.getScaleForId(meta.yAxisID);
+ var sumPos = 0;
+ var sumNeg = 0;
+ var i, ds, dsMeta;
+
+ if (yScale.options.stacked) {
+ for (i = 0; i < datasetIndex; i++) {
+ ds = chart.data.datasets[i];
+ dsMeta = chart.getDatasetMeta(i);
+ if (dsMeta.type === 'line' && dsMeta.yAxisID === yScale.id && chart.isDatasetVisible(i)) {
+ var stackedRightValue = Number(yScale.getRightValue(ds.data[index]));
+ if (stackedRightValue < 0) {
+ sumNeg += stackedRightValue || 0;
+ } else {
+ sumPos += stackedRightValue || 0;
+ }
+ }
+ }
+
+ var rightValue = Number(yScale.getRightValue(value));
+ if (rightValue < 0) {
+ return yScale.getPixelForValue(sumNeg + rightValue);
+ }
+ return yScale.getPixelForValue(sumPos + rightValue);
+ }
+
+ return yScale.getPixelForValue(value);
+ },
+
+ updateBezierControlPoints: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var area = me.chart.chartArea;
+ var points = (meta.data || []);
+ var i, ilen, point, model, controlPoints;
+
+ // Only consider points that are drawn in case the spanGaps option is used
+ if (meta.dataset._model.spanGaps) {
+ points = points.filter(function(pt) {
+ return !pt._model.skip;
+ });
+ }
+
+ function capControlPoint(pt, min, max) {
+ return Math.max(Math.min(pt, max), min);
+ }
+
+ if (meta.dataset._model.cubicInterpolationMode === 'monotone') {
+ helpers.splineCurveMonotone(points);
+ } else {
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ point = points[i];
+ model = point._model;
+ controlPoints = helpers.splineCurve(
+ helpers.previousItem(points, i)._model,
+ model,
+ helpers.nextItem(points, i)._model,
+ meta.dataset._model.tension
+ );
+ model.controlPointPreviousX = controlPoints.previous.x;
+ model.controlPointPreviousY = controlPoints.previous.y;
+ model.controlPointNextX = controlPoints.next.x;
+ model.controlPointNextY = controlPoints.next.y;
+ }
+ }
+
+ if (me.chart.options.elements.line.capBezierPoints) {
+ for (i = 0, ilen = points.length; i < ilen; ++i) {
+ model = points[i]._model;
+ model.controlPointPreviousX = capControlPoint(model.controlPointPreviousX, area.left, area.right);
+ model.controlPointPreviousY = capControlPoint(model.controlPointPreviousY, area.top, area.bottom);
+ model.controlPointNextX = capControlPoint(model.controlPointNextX, area.left, area.right);
+ model.controlPointNextY = capControlPoint(model.controlPointNextY, area.top, area.bottom);
+ }
+ }
+ },
+
+ draw: function() {
+ var me = this;
+ var chart = me.chart;
+ var meta = me.getMeta();
+ var points = meta.data || [];
+ var area = chart.chartArea;
+ var ilen = points.length;
+ var i = 0;
+
+ helpers.canvas.clipArea(chart.ctx, area);
+
+ if (lineEnabled(me.getDataset(), chart.options)) {
+ meta.dataset.draw();
+ }
+
+ helpers.canvas.unclipArea(chart.ctx);
+
+ // Draw the points
+ for (; i < ilen; ++i) {
+ points[i].draw(area);
+ }
+ },
+
+ setHoverStyle: function(point) {
+ // Point
+ var dataset = this.chart.data.datasets[point._datasetIndex];
+ var index = point._index;
+ var custom = point.custom || {};
+ var model = point._model;
+
+ model.radius = custom.hoverRadius || helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
+ model.backgroundColor = custom.hoverBackgroundColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
+ },
+
+ removeHoverStyle: function(point) {
+ var me = this;
+ var dataset = me.chart.data.datasets[point._datasetIndex];
+ var index = point._index;
+ var custom = point.custom || {};
+ var model = point._model;
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
+ dataset.pointRadius = dataset.radius;
+ }
+
+ model.radius = custom.radius || helpers.valueAtIndexOrDefault(dataset.pointRadius, index, me.chart.options.elements.point.radius);
+ model.backgroundColor = me.getPointBackgroundColor(point, index);
+ model.borderColor = me.getPointBorderColor(point, index);
+ model.borderWidth = me.getPointBorderWidth(point, index);
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],19:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('polarArea', {
+ scale: {
+ type: 'radialLinear',
+ angleLines: {
+ display: false
+ },
+ gridLines: {
+ circular: true
+ },
+ pointLabels: {
+ display: false
+ },
+ ticks: {
+ beginAtZero: true
+ }
+ },
+
+ // Boolean - Whether to animate the rotation of the chart
+ animation: {
+ animateRotate: true,
+ animateScale: true
+ },
+
+ startAngle: -0.5 * Math.PI,
+ legendCallback: function(chart) {
+ var text = [];
+ text.push('<ul class="' + chart.id + '-legend">');
+
+ var data = chart.data;
+ var datasets = data.datasets;
+ var labels = data.labels;
+
+ if (datasets.length) {
+ for (var i = 0; i < datasets[0].data.length; ++i) {
+ text.push('<li><span style="background-color:' + datasets[0].backgroundColor[i] + '"></span>');
+ if (labels[i]) {
+ text.push(labels[i]);
+ }
+ text.push('</li>');
+ }
+ }
+
+ text.push('</ul>');
+ return text.join('');
+ },
+ legend: {
+ labels: {
+ generateLabels: function(chart) {
+ var data = chart.data;
+ if (data.labels.length && data.datasets.length) {
+ return data.labels.map(function(label, i) {
+ var meta = chart.getDatasetMeta(0);
+ var ds = data.datasets[0];
+ var arc = meta.data[i];
+ var custom = arc.custom || {};
+ var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+ var arcOpts = chart.options.elements.arc;
+ var fill = custom.backgroundColor ? custom.backgroundColor : valueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor);
+ var stroke = custom.borderColor ? custom.borderColor : valueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor);
+ var bw = custom.borderWidth ? custom.borderWidth : valueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth);
+
+ return {
+ text: label,
+ fillStyle: fill,
+ strokeStyle: stroke,
+ lineWidth: bw,
+ hidden: isNaN(ds.data[i]) || meta.data[i].hidden,
+
+ // Extra data used for toggling the correct item
+ index: i
+ };
+ });
+ }
+ return [];
+ }
+ },
+
+ onClick: function(e, legendItem) {
+ var index = legendItem.index;
+ var chart = this.chart;
+ var i, ilen, meta;
+
+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
+ meta = chart.getDatasetMeta(i);
+ meta.data[index].hidden = !meta.data[index].hidden;
+ }
+
+ chart.update();
+ }
+ },
+
+ // Need to override these to give a nice default
+ tooltips: {
+ callbacks: {
+ title: function() {
+ return '';
+ },
+ label: function(item, data) {
+ return data.labels[item.index] + ': ' + item.yLabel;
+ }
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.polarArea = Chart.DatasetController.extend({
+
+ dataElementType: elements.Arc,
+
+ linkScales: helpers.noop,
+
+ update: function(reset) {
+ var me = this;
+ var chart = me.chart;
+ var chartArea = chart.chartArea;
+ var meta = me.getMeta();
+ var opts = chart.options;
+ var arcOpts = opts.elements.arc;
+ var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);
+ chart.outerRadius = Math.max((minSize - arcOpts.borderWidth / 2) / 2, 0);
+ chart.innerRadius = Math.max(opts.cutoutPercentage ? (chart.outerRadius / 100) * (opts.cutoutPercentage) : 1, 0);
+ chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
+
+ me.outerRadius = chart.outerRadius - (chart.radiusLength * me.index);
+ me.innerRadius = me.outerRadius - chart.radiusLength;
+
+ meta.count = me.countVisibleElements();
+
+ helpers.each(meta.data, function(arc, index) {
+ me.updateElement(arc, index, reset);
+ });
+ },
+
+ updateElement: function(arc, index, reset) {
+ var me = this;
+ var chart = me.chart;
+ var dataset = me.getDataset();
+ var opts = chart.options;
+ var animationOpts = opts.animation;
+ var scale = chart.scale;
+ var labels = chart.data.labels;
+
+ var circumference = me.calculateCircumference(dataset.data[index]);
+ var centerX = scale.xCenter;
+ var centerY = scale.yCenter;
+
+ // If there is NaN data before us, we need to calculate the starting angle correctly.
+ // We could be way more efficient here, but its unlikely that the polar area chart will have a lot of data
+ var visibleCount = 0;
+ var meta = me.getMeta();
+ for (var i = 0; i < index; ++i) {
+ if (!isNaN(dataset.data[i]) && !meta.data[i].hidden) {
+ ++visibleCount;
+ }
+ }
+
+ // var negHalfPI = -0.5 * Math.PI;
+ var datasetStartAngle = opts.startAngle;
+ var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
+ var startAngle = datasetStartAngle + (circumference * visibleCount);
+ var endAngle = startAngle + (arc.hidden ? 0 : circumference);
+
+ var resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
+
+ helpers.extend(arc, {
+ // Utility
+ _datasetIndex: me.index,
+ _index: index,
+ _scale: scale,
+
+ // Desired view properties
+ _model: {
+ x: centerX,
+ y: centerY,
+ innerRadius: 0,
+ outerRadius: reset ? resetRadius : distance,
+ startAngle: reset && animationOpts.animateRotate ? datasetStartAngle : startAngle,
+ endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : endAngle,
+ label: helpers.valueAtIndexOrDefault(labels, index, labels[index])
+ }
+ });
+
+ // Apply border and fill style
+ me.removeHoverStyle(arc);
+
+ arc.pivot();
+ },
+
+ removeHoverStyle: function(arc) {
+ Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc);
+ },
+
+ countVisibleElements: function() {
+ var dataset = this.getDataset();
+ var meta = this.getMeta();
+ var count = 0;
+
+ helpers.each(meta.data, function(element, index) {
+ if (!isNaN(dataset.data[index]) && !element.hidden) {
+ count++;
+ }
+ });
+
+ return count;
+ },
+
+ calculateCircumference: function(value) {
+ var count = this.getMeta().count;
+ if (count > 0 && !isNaN(value)) {
+ return (2 * Math.PI) / count;
+ }
+ return 0;
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],20:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('radar', {
+ scale: {
+ type: 'radialLinear'
+ },
+ elements: {
+ line: {
+ tension: 0 // no bezier in radar
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.controllers.radar = Chart.DatasetController.extend({
+
+ datasetElementType: elements.Line,
+
+ dataElementType: elements.Point,
+
+ linkScales: helpers.noop,
+
+ update: function(reset) {
+ var me = this;
+ var meta = me.getMeta();
+ var line = meta.dataset;
+ var points = meta.data;
+ var custom = line.custom || {};
+ var dataset = me.getDataset();
+ var lineElementOptions = me.chart.options.elements.line;
+ var scale = me.chart.scale;
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
+ dataset.lineTension = dataset.tension;
+ }
+
+ helpers.extend(meta.dataset, {
+ // Utility
+ _datasetIndex: me.index,
+ _scale: scale,
+ // Data
+ _children: points,
+ _loop: true,
+ // Model
+ _model: {
+ // Appearance
+ tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
+ borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor),
+ fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill),
+ borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle),
+ borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash),
+ borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset),
+ borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle),
+ }
+ });
+
+ meta.dataset.pivot();
+
+ // Update Points
+ helpers.each(points, function(point, index) {
+ me.updateElement(point, index, reset);
+ }, me);
+
+ // Update bezier control points
+ me.updateBezierControlPoints();
+ },
+ updateElement: function(point, index, reset) {
+ var me = this;
+ var custom = point.custom || {};
+ var dataset = me.getDataset();
+ var scale = me.chart.scale;
+ var pointElementOptions = me.chart.options.elements.point;
+ var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]);
+
+ // Compatibility: If the properties are defined with only the old name, use those values
+ if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
+ dataset.pointRadius = dataset.radius;
+ }
+ if ((dataset.hitRadius !== undefined) && (dataset.pointHitRadius === undefined)) {
+ dataset.pointHitRadius = dataset.hitRadius;
+ }
+
+ helpers.extend(point, {
+ // Utility
+ _datasetIndex: me.index,
+ _index: index,
+ _scale: scale,
+
+ // Desired view properties
+ _model: {
+ x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales
+ y: reset ? scale.yCenter : pointPosition.y,
+
+ // Appearance
+ tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, me.chart.options.elements.line.tension),
+ radius: custom.radius ? custom.radius : helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointElementOptions.radius),
+ backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.pointBackgroundColor, index, pointElementOptions.backgroundColor),
+ borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor),
+ borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth),
+ pointStyle: custom.pointStyle ? custom.pointStyle : helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointElementOptions.pointStyle),
+
+ // Tooltip
+ hitRadius: custom.hitRadius ? custom.hitRadius : helpers.valueAtIndexOrDefault(dataset.pointHitRadius, index, pointElementOptions.hitRadius)
+ }
+ });
+
+ point._model.skip = custom.skip ? custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
+ },
+ updateBezierControlPoints: function() {
+ var chartArea = this.chart.chartArea;
+ var meta = this.getMeta();
+
+ helpers.each(meta.data, function(point, index) {
+ var model = point._model;
+ var controlPoints = helpers.splineCurve(
+ helpers.previousItem(meta.data, index, true)._model,
+ model,
+ helpers.nextItem(meta.data, index, true)._model,
+ model.tension
+ );
+
+ // Prevent the bezier going outside of the bounds of the graph
+ model.controlPointPreviousX = Math.max(Math.min(controlPoints.previous.x, chartArea.right), chartArea.left);
+ model.controlPointPreviousY = Math.max(Math.min(controlPoints.previous.y, chartArea.bottom), chartArea.top);
+
+ model.controlPointNextX = Math.max(Math.min(controlPoints.next.x, chartArea.right), chartArea.left);
+ model.controlPointNextY = Math.max(Math.min(controlPoints.next.y, chartArea.bottom), chartArea.top);
+
+ // Now pivot the point for animation
+ point.pivot();
+ });
+ },
+
+ setHoverStyle: function(point) {
+ // Point
+ var dataset = this.chart.data.datasets[point._datasetIndex];
+ var custom = point.custom || {};
+ var index = point._index;
+ var model = point._model;
+
+ model.radius = custom.hoverRadius ? custom.hoverRadius : helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
+ model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
+ },
+
+ removeHoverStyle: function(point) {
+ var dataset = this.chart.data.datasets[point._datasetIndex];
+ var custom = point.custom || {};
+ var index = point._index;
+ var model = point._model;
+ var pointElementOptions = this.chart.options.elements.point;
+
+ model.radius = custom.radius ? custom.radius : helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointElementOptions.radius);
+ model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.pointBackgroundColor, index, pointElementOptions.backgroundColor);
+ model.borderColor = custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor);
+ model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth);
+ }
+ });
+};
+
+},{"25":25,"40":40,"45":45}],21:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+
+defaults._set('scatter', {
+ hover: {
+ mode: 'single'
+ },
+
+ scales: {
+ xAxes: [{
+ id: 'x-axis-1', // need an ID so datasets can reference the scale
+ type: 'linear', // scatter should not use a category axis
+ position: 'bottom'
+ }],
+ yAxes: [{
+ id: 'y-axis-1',
+ type: 'linear',
+ position: 'left'
+ }]
+ },
+
+ showLines: false,
+
+ tooltips: {
+ callbacks: {
+ title: function() {
+ return ''; // doesn't make sense for scatter since data are formatted as a point
+ },
+ label: function(item) {
+ return '(' + item.xLabel + ', ' + item.yLabel + ')';
+ }
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ // Scatter charts use line controllers
+ Chart.controllers.scatter = Chart.controllers.line;
+
+};
+
+},{"25":25}],22:[function(require,module,exports){
+/* global window: false */
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ animation: {
+ duration: 1000,
+ easing: 'easeOutQuart',
+ onProgress: helpers.noop,
+ onComplete: helpers.noop
+ }
+});
+
+module.exports = function(Chart) {
+
+ Chart.Animation = Element.extend({
+ chart: null, // the animation associated chart instance
+ currentStep: 0, // the current animation step
+ numSteps: 60, // default number of steps
+ easing: '', // the easing to use for this animation
+ render: null, // render function used by the animation service
+
+ onAnimationProgress: null, // user specified callback to fire on each step of the animation
+ onAnimationComplete: null, // user specified callback to fire when the animation finishes
+ });
+
+ Chart.animationService = {
+ frameDuration: 17,
+ animations: [],
+ dropFrames: 0,
+ request: null,
+
+ /**
+ * @param {Chart} chart - The chart to animate.
+ * @param {Chart.Animation} animation - The animation that we will animate.
+ * @param {Number} duration - The animation duration in ms.
+ * @param {Boolean} lazy - if true, the chart is not marked as animating to enable more responsive interactions
+ */
+ addAnimation: function(chart, animation, duration, lazy) {
+ var animations = this.animations;
+ var i, ilen;
+
+ animation.chart = chart;
+
+ if (!lazy) {
+ chart.animating = true;
+ }
+
+ for (i = 0, ilen = animations.length; i < ilen; ++i) {
+ if (animations[i].chart === chart) {
+ animations[i] = animation;
+ return;
+ }
+ }
+
+ animations.push(animation);
+
+ // If there are no animations queued, manually kickstart a digest, for lack of a better word
+ if (animations.length === 1) {
+ this.requestAnimationFrame();
+ }
+ },
+
+ cancelAnimation: function(chart) {
+ var index = helpers.findIndex(this.animations, function(animation) {
+ return animation.chart === chart;
+ });
+
+ if (index !== -1) {
+ this.animations.splice(index, 1);
+ chart.animating = false;
+ }
+ },
+
+ requestAnimationFrame: function() {
+ var me = this;
+ if (me.request === null) {
+ // Skip animation frame requests until the active one is executed.
+ // This can happen when processing mouse events, e.g. 'mousemove'
+ // and 'mouseout' events will trigger multiple renders.
+ me.request = helpers.requestAnimFrame.call(window, function() {
+ me.request = null;
+ me.startDigest();
+ });
+ }
+ },
+
+ /**
+ * @private
+ */
+ startDigest: function() {
+ var me = this;
+ var startTime = Date.now();
+ var framesToDrop = 0;
+
+ if (me.dropFrames > 1) {
+ framesToDrop = Math.floor(me.dropFrames);
+ me.dropFrames = me.dropFrames % 1;
+ }
+
+ me.advance(1 + framesToDrop);
+
+ var endTime = Date.now();
+
+ me.dropFrames += (endTime - startTime) / me.frameDuration;
+
+ // Do we have more stuff to animate?
+ if (me.animations.length > 0) {
+ me.requestAnimationFrame();
+ }
+ },
+
+ /**
+ * @private
+ */
+ advance: function(count) {
+ var animations = this.animations;
+ var animation, chart;
+ var i = 0;
+
+ while (i < animations.length) {
+ animation = animations[i];
+ chart = animation.chart;
+
+ animation.currentStep = (animation.currentStep || 0) + count;
+ animation.currentStep = Math.min(animation.currentStep, animation.numSteps);
+
+ helpers.callback(animation.render, [chart, animation], chart);
+ helpers.callback(animation.onAnimationProgress, [animation], chart);
+
+ if (animation.currentStep >= animation.numSteps) {
+ helpers.callback(animation.onAnimationComplete, [animation], chart);
+ chart.animating = false;
+ animations.splice(i, 1);
+ } else {
+ ++i;
+ }
+ }
+ }
+ };
+
+ /**
+ * Provided for backward compatibility, use Chart.Animation instead
+ * @prop Chart.Animation#animationObject
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ */
+ Object.defineProperty(Chart.Animation.prototype, 'animationObject', {
+ get: function() {
+ return this;
+ }
+ });
+
+ /**
+ * Provided for backward compatibility, use Chart.Animation#chart instead
+ * @prop Chart.Animation#chartInstance
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ */
+ Object.defineProperty(Chart.Animation.prototype, 'chartInstance', {
+ get: function() {
+ return this.chart;
+ },
+ set: function(value) {
+ this.chart = value;
+ }
+ });
+
+};
+
+},{"25":25,"26":26,"45":45}],23:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+var Interaction = require(28);
+var platform = require(48);
+
+module.exports = function(Chart) {
+ var plugins = Chart.plugins;
+
+ // Create a dictionary of chart types, to allow for extension of existing types
+ Chart.types = {};
+
+ // Store a reference to each instance - allowing us to globally resize chart instances on window resize.
+ // Destroy method on the chart will remove the instance of the chart from this reference.
+ Chart.instances = {};
+
+ // Controllers available for dataset visualization eg. bar, line, slice, etc.
+ Chart.controllers = {};
+
+ /**
+ * Initializes the given config with global and chart default values.
+ */
+ function initConfig(config) {
+ config = config || {};
+
+ // Do NOT use configMerge() for the data object because this method merges arrays
+ // and so would change references to labels and datasets, preventing data updates.
+ var data = config.data = config.data || {};
+ data.datasets = data.datasets || [];
+ data.labels = data.labels || [];
+
+ config.options = helpers.configMerge(
+ defaults.global,
+ defaults[config.type],
+ config.options || {});
+
+ return config;
+ }
+
+ /**
+ * Updates the config of the chart
+ * @param chart {Chart} chart to update the options for
+ */
+ function updateConfig(chart) {
+ var newOptions = chart.options;
+
+ // Update Scale(s) with options
+ if (newOptions.scale) {
+ chart.scale.options = newOptions.scale;
+ } else if (newOptions.scales) {
+ newOptions.scales.xAxes.concat(newOptions.scales.yAxes).forEach(function(scaleOptions) {
+ chart.scales[scaleOptions.id].options = scaleOptions;
+ });
+ }
+
+ // Tooltip
+ chart.tooltip._options = newOptions.tooltips;
+ }
+
+ function positionIsHorizontal(position) {
+ return position === 'top' || position === 'bottom';
+ }
+
+ helpers.extend(Chart.prototype, /** @lends Chart */ {
+ /**
+ * @private
+ */
+ construct: function(item, config) {
+ var me = this;
+
+ config = initConfig(config);
+
+ var context = platform.acquireContext(item, config);
+ var canvas = context && context.canvas;
+ var height = canvas && canvas.height;
+ var width = canvas && canvas.width;
+
+ me.id = helpers.uid();
+ me.ctx = context;
+ me.canvas = canvas;
+ me.config = config;
+ me.width = width;
+ me.height = height;
+ me.aspectRatio = height ? width / height : null;
+ me.options = config.options;
+ me._bufferedRender = false;
+
+ /**
+ * Provided for backward compatibility, Chart and Chart.Controller have been merged,
+ * the "instance" still need to be defined since it might be called from plugins.
+ * @prop Chart#chart
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+ me.chart = me;
+ me.controller = me; // chart.chart.controller #inception
+
+ // Add the chart instance to the global namespace
+ Chart.instances[me.id] = me;
+
+ // Define alias to the config data: `chart.data === chart.config.data`
+ Object.defineProperty(me, 'data', {
+ get: function() {
+ return me.config.data;
+ },
+ set: function(value) {
+ me.config.data = value;
+ }
+ });
+
+ if (!context || !canvas) {
+ // The given item is not a compatible context2d element, let's return before finalizing
+ // the chart initialization but after setting basic chart / controller properties that
+ // can help to figure out that the chart is not valid (e.g chart.canvas !== null);
+ // https://github.com/chartjs/Chart.js/issues/2807
+ console.error("Failed to create chart: can't acquire context from the given item");
+ return;
+ }
+
+ me.initialize();
+ me.update();
+ },
+
+ /**
+ * @private
+ */
+ initialize: function() {
+ var me = this;
+
+ // Before init plugin notification
+ plugins.notify(me, 'beforeInit');
+
+ helpers.retinaScale(me, me.options.devicePixelRatio);
+
+ me.bindEvents();
+
+ if (me.options.responsive) {
+ // Initial resize before chart draws (must be silent to preserve initial animations).
+ me.resize(true);
+ }
+
+ // Make sure scales have IDs and are built before we build any controllers.
+ me.ensureScalesHaveIDs();
+ me.buildScales();
+ me.initToolTip();
+
+ // After init plugin notification
+ plugins.notify(me, 'afterInit');
+
+ return me;
+ },
+
+ clear: function() {
+ helpers.canvas.clear(this);
+ return this;
+ },
+
+ stop: function() {
+ // Stops any current animation loop occurring
+ Chart.animationService.cancelAnimation(this);
+ return this;
+ },
+
+ resize: function(silent) {
+ var me = this;
+ var options = me.options;
+ var canvas = me.canvas;
+ var aspectRatio = (options.maintainAspectRatio && me.aspectRatio) || null;
+
+ // the canvas render width and height will be casted to integers so make sure that
+ // the canvas display style uses the same integer values to avoid blurring effect.
+
+ // Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased
+ var newWidth = Math.max(0, Math.floor(helpers.getMaximumWidth(canvas)));
+ var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)));
+
+ if (me.width === newWidth && me.height === newHeight) {
+ return;
+ }
+
+ canvas.width = me.width = newWidth;
+ canvas.height = me.height = newHeight;
+ canvas.style.width = newWidth + 'px';
+ canvas.style.height = newHeight + 'px';
+
+ helpers.retinaScale(me, options.devicePixelRatio);
+
+ if (!silent) {
+ // Notify any plugins about the resize
+ var newSize = {width: newWidth, height: newHeight};
+ plugins.notify(me, 'resize', [newSize]);
+
+ // Notify of resize
+ if (me.options.onResize) {
+ me.options.onResize(me, newSize);
+ }
+
+ me.stop();
+ me.update(me.options.responsiveAnimationDuration);
+ }
+ },
+
+ ensureScalesHaveIDs: function() {
+ var options = this.options;
+ var scalesOptions = options.scales || {};
+ var scaleOptions = options.scale;
+
+ helpers.each(scalesOptions.xAxes, function(xAxisOptions, index) {
+ xAxisOptions.id = xAxisOptions.id || ('x-axis-' + index);
+ });
+
+ helpers.each(scalesOptions.yAxes, function(yAxisOptions, index) {
+ yAxisOptions.id = yAxisOptions.id || ('y-axis-' + index);
+ });
+
+ if (scaleOptions) {
+ scaleOptions.id = scaleOptions.id || 'scale';
+ }
+ },
+
+ /**
+ * Builds a map of scale ID to scale object for future lookup.
+ */
+ buildScales: function() {
+ var me = this;
+ var options = me.options;
+ var scales = me.scales = {};
+ var items = [];
+
+ if (options.scales) {
+ items = items.concat(
+ (options.scales.xAxes || []).map(function(xAxisOptions) {
+ return {options: xAxisOptions, dtype: 'category', dposition: 'bottom'};
+ }),
+ (options.scales.yAxes || []).map(function(yAxisOptions) {
+ return {options: yAxisOptions, dtype: 'linear', dposition: 'left'};
+ })
+ );
+ }
+
+ if (options.scale) {
+ items.push({
+ options: options.scale,
+ dtype: 'radialLinear',
+ isDefault: true,
+ dposition: 'chartArea'
+ });
+ }
+
+ helpers.each(items, function(item) {
+ var scaleOptions = item.options;
+ var scaleType = helpers.valueOrDefault(scaleOptions.type, item.dtype);
+ var scaleClass = Chart.scaleService.getScaleConstructor(scaleType);
+ if (!scaleClass) {
+ return;
+ }
+
+ if (positionIsHorizontal(scaleOptions.position) !== positionIsHorizontal(item.dposition)) {
+ scaleOptions.position = item.dposition;
+ }
+
+ var scale = new scaleClass({
+ id: scaleOptions.id,
+ options: scaleOptions,
+ ctx: me.ctx,
+ chart: me
+ });
+
+ scales[scale.id] = scale;
+ scale.mergeTicksOptions();
+
+ // TODO(SB): I think we should be able to remove this custom case (options.scale)
+ // and consider it as a regular scale part of the "scales"" map only! This would
+ // make the logic easier and remove some useless? custom code.
+ if (item.isDefault) {
+ me.scale = scale;
+ }
+ });
+
+ Chart.scaleService.addScalesToLayout(this);
+ },
+
+ buildOrUpdateControllers: function() {
+ var me = this;
+ var types = [];
+ var newControllers = [];
+
+ helpers.each(me.data.datasets, function(dataset, datasetIndex) {
+ var meta = me.getDatasetMeta(datasetIndex);
+ var type = dataset.type || me.config.type;
+
+ if (meta.type && meta.type !== type) {
+ me.destroyDatasetMeta(datasetIndex);
+ meta = me.getDatasetMeta(datasetIndex);
+ }
+ meta.type = type;
+
+ types.push(meta.type);
+
+ if (meta.controller) {
+ meta.controller.updateIndex(datasetIndex);
+ } else {
+ var ControllerClass = Chart.controllers[meta.type];
+ if (ControllerClass === undefined) {
+ throw new Error('"' + meta.type + '" is not a chart type.');
+ }
+
+ meta.controller = new ControllerClass(me, datasetIndex);
+ newControllers.push(meta.controller);
+ }
+ }, me);
+
+ return newControllers;
+ },
+
+ /**
+ * Reset the elements of all datasets
+ * @private
+ */
+ resetElements: function() {
+ var me = this;
+ helpers.each(me.data.datasets, function(dataset, datasetIndex) {
+ me.getDatasetMeta(datasetIndex).controller.reset();
+ }, me);
+ },
+
+ /**
+ * Resets the chart back to it's state before the initial animation
+ */
+ reset: function() {
+ this.resetElements();
+ this.tooltip.initialize();
+ },
+
+ update: function(config) {
+ var me = this;
+
+ if (!config || typeof config !== 'object') {
+ // backwards compatibility
+ config = {
+ duration: config,
+ lazy: arguments[1]
+ };
+ }
+
+ updateConfig(me);
+
+ if (plugins.notify(me, 'beforeUpdate') === false) {
+ return;
+ }
+
+ // In case the entire data object changed
+ me.tooltip._data = me.data;
+
+ // Make sure dataset controllers are updated and new controllers are reset
+ var newControllers = me.buildOrUpdateControllers();
+
+ // Make sure all dataset controllers have correct meta data counts
+ helpers.each(me.data.datasets, function(dataset, datasetIndex) {
+ me.getDatasetMeta(datasetIndex).controller.buildOrUpdateElements();
+ }, me);
+
+ me.updateLayout();
+
+ // Can only reset the new controllers after the scales have been updated
+ helpers.each(newControllers, function(controller) {
+ controller.reset();
+ });
+
+ me.updateDatasets();
+
+ // Need to reset tooltip in case it is displayed with elements that are removed
+ // after update.
+ me.tooltip.initialize();
+
+ // Last active contains items that were previously in the tooltip.
+ // When we reset the tooltip, we need to clear it
+ me.lastActive = [];
+
+ // Do this before render so that any plugins that need final scale updates can use it
+ plugins.notify(me, 'afterUpdate');
+
+ if (me._bufferedRender) {
+ me._bufferedRequest = {
+ duration: config.duration,
+ easing: config.easing,
+ lazy: config.lazy
+ };
+ } else {
+ me.render(config);
+ }
+ },
+
+ /**
+ * Updates the chart layout unless a plugin returns `false` to the `beforeLayout`
+ * hook, in which case, plugins will not be called on `afterLayout`.
+ * @private
+ */
+ updateLayout: function() {
+ var me = this;
+
+ if (plugins.notify(me, 'beforeLayout') === false) {
+ return;
+ }
+
+ Chart.layoutService.update(this, this.width, this.height);
+
+ /**
+ * Provided for backward compatibility, use `afterLayout` instead.
+ * @method IPlugin#afterScaleUpdate
+ * @deprecated since version 2.5.0
+ * @todo remove at version 3
+ * @private
+ */
+ plugins.notify(me, 'afterScaleUpdate');
+ plugins.notify(me, 'afterLayout');
+ },
+
+ /**
+ * Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate`
+ * hook, in which case, plugins will not be called on `afterDatasetsUpdate`.
+ * @private
+ */
+ updateDatasets: function() {
+ var me = this;
+
+ if (plugins.notify(me, 'beforeDatasetsUpdate') === false) {
+ return;
+ }
+
+ for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
+ me.updateDataset(i);
+ }
+
+ plugins.notify(me, 'afterDatasetsUpdate');
+ },
+
+ /**
+ * Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate`
+ * hook, in which case, plugins will not be called on `afterDatasetUpdate`.
+ * @private
+ */
+ updateDataset: function(index) {
+ var me = this;
+ var meta = me.getDatasetMeta(index);
+ var args = {
+ meta: meta,
+ index: index
+ };
+
+ if (plugins.notify(me, 'beforeDatasetUpdate', [args]) === false) {
+ return;
+ }
+
+ meta.controller.update();
+
+ plugins.notify(me, 'afterDatasetUpdate', [args]);
+ },
+
+ render: function(config) {
+ var me = this;
+
+ if (!config || typeof config !== 'object') {
+ // backwards compatibility
+ config = {
+ duration: config,
+ lazy: arguments[1]
+ };
+ }
+
+ var duration = config.duration;
+ var lazy = config.lazy;
+
+ if (plugins.notify(me, 'beforeRender') === false) {
+ return;
+ }
+
+ var animationOptions = me.options.animation;
+ var onComplete = function(animation) {
+ plugins.notify(me, 'afterRender');
+ helpers.callback(animationOptions && animationOptions.onComplete, [animation], me);
+ };
+
+ if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
+ var animation = new Chart.Animation({
+ numSteps: (duration || animationOptions.duration) / 16.66, // 60 fps
+ easing: config.easing || animationOptions.easing,
+
+ render: function(chart, animationObject) {
+ var easingFunction = helpers.easing.effects[animationObject.easing];
+ var currentStep = animationObject.currentStep;
+ var stepDecimal = currentStep / animationObject.numSteps;
+
+ chart.draw(easingFunction(stepDecimal), stepDecimal, currentStep);
+ },
+
+ onAnimationProgress: animationOptions.onProgress,
+ onAnimationComplete: onComplete
+ });
+
+ Chart.animationService.addAnimation(me, animation, duration, lazy);
+ } else {
+ me.draw();
+
+ // See https://github.com/chartjs/Chart.js/issues/3781
+ onComplete(new Chart.Animation({numSteps: 0, chart: me}));
+ }
+
+ return me;
+ },
+
+ draw: function(easingValue) {
+ var me = this;
+
+ me.clear();
+
+ if (helpers.isNullOrUndef(easingValue)) {
+ easingValue = 1;
+ }
+
+ me.transition(easingValue);
+
+ if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) {
+ return;
+ }
+
+ // Draw all the scales
+ helpers.each(me.boxes, function(box) {
+ box.draw(me.chartArea);
+ }, me);
+
+ if (me.scale) {
+ me.scale.draw();
+ }
+
+ me.drawDatasets(easingValue);
+ me._drawTooltip(easingValue);
+
+ plugins.notify(me, 'afterDraw', [easingValue]);
+ },
+
+ /**
+ * @private
+ */
+ transition: function(easingValue) {
+ var me = this;
+
+ for (var i = 0, ilen = (me.data.datasets || []).length; i < ilen; ++i) {
+ if (me.isDatasetVisible(i)) {
+ me.getDatasetMeta(i).controller.transition(easingValue);
+ }
+ }
+
+ me.tooltip.transition(easingValue);
+ },
+
+ /**
+ * Draws all datasets unless a plugin returns `false` to the `beforeDatasetsDraw`
+ * hook, in which case, plugins will not be called on `afterDatasetsDraw`.
+ * @private
+ */
+ drawDatasets: function(easingValue) {
+ var me = this;
+
+ if (plugins.notify(me, 'beforeDatasetsDraw', [easingValue]) === false) {
+ return;
+ }
+
+ // Draw datasets reversed to support proper line stacking
+ for (var i = (me.data.datasets || []).length - 1; i >= 0; --i) {
+ if (me.isDatasetVisible(i)) {
+ me.drawDataset(i, easingValue);
+ }
+ }
+
+ plugins.notify(me, 'afterDatasetsDraw', [easingValue]);
+ },
+
+ /**
+ * Draws dataset at index unless a plugin returns `false` to the `beforeDatasetDraw`
+ * hook, in which case, plugins will not be called on `afterDatasetDraw`.
+ * @private
+ */
+ drawDataset: function(index, easingValue) {
+ var me = this;
+ var meta = me.getDatasetMeta(index);
+ var args = {
+ meta: meta,
+ index: index,
+ easingValue: easingValue
+ };
+
+ if (plugins.notify(me, 'beforeDatasetDraw', [args]) === false) {
+ return;
+ }
+
+ meta.controller.draw(easingValue);
+
+ plugins.notify(me, 'afterDatasetDraw', [args]);
+ },
+
+ /**
+ * Draws tooltip unless a plugin returns `false` to the `beforeTooltipDraw`
+ * hook, in which case, plugins will not be called on `afterTooltipDraw`.
+ * @private
+ */
+ _drawTooltip: function(easingValue) {
+ var me = this;
+ var tooltip = me.tooltip;
+ var args = {
+ tooltip: tooltip,
+ easingValue: easingValue
+ };
+
+ if (plugins.notify(me, 'beforeTooltipDraw', [args]) === false) {
+ return;
+ }
+
+ tooltip.draw();
+
+ plugins.notify(me, 'afterTooltipDraw', [args]);
+ },
+
+ // Get the single element that was clicked on
+ // @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
+ getElementAtEvent: function(e) {
+ return Interaction.modes.single(this, e);
+ },
+
+ getElementsAtEvent: function(e) {
+ return Interaction.modes.label(this, e, {intersect: true});
+ },
+
+ getElementsAtXAxis: function(e) {
+ return Interaction.modes['x-axis'](this, e, {intersect: true});
+ },
+
+ getElementsAtEventForMode: function(e, mode, options) {
+ var method = Interaction.modes[mode];
+ if (typeof method === 'function') {
+ return method(this, e, options);
+ }
+
+ return [];
+ },
+
+ getDatasetAtEvent: function(e) {
+ return Interaction.modes.dataset(this, e, {intersect: true});
+ },
+
+ getDatasetMeta: function(datasetIndex) {
+ var me = this;
+ var dataset = me.data.datasets[datasetIndex];
+ if (!dataset._meta) {
+ dataset._meta = {};
+ }
+
+ var meta = dataset._meta[me.id];
+ if (!meta) {
+ meta = dataset._meta[me.id] = {
+ type: null,
+ data: [],
+ dataset: null,
+ controller: null,
+ hidden: null, // See isDatasetVisible() comment
+ xAxisID: null,
+ yAxisID: null
+ };
+ }
+
+ return meta;
+ },
+
+ getVisibleDatasetCount: function() {
+ var count = 0;
+ for (var i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {
+ if (this.isDatasetVisible(i)) {
+ count++;
+ }
+ }
+ return count;
+ },
+
+ isDatasetVisible: function(datasetIndex) {
+ var meta = this.getDatasetMeta(datasetIndex);
+
+ // meta.hidden is a per chart dataset hidden flag override with 3 states: if true or false,
+ // the dataset.hidden value is ignored, else if null, the dataset hidden state is returned.
+ return typeof meta.hidden === 'boolean' ? !meta.hidden : !this.data.datasets[datasetIndex].hidden;
+ },
+
+ generateLegend: function() {
+ return this.options.legendCallback(this);
+ },
+
+ /**
+ * @private
+ */
+ destroyDatasetMeta: function(datasetIndex) {
+ var id = this.id;
+ var dataset = this.data.datasets[datasetIndex];
+ var meta = dataset._meta && dataset._meta[id];
+
+ if (meta) {
+ meta.controller.destroy();
+ delete dataset._meta[id];
+ }
+ },
+
+ destroy: function() {
+ var me = this;
+ var canvas = me.canvas;
+ var i, ilen;
+
+ me.stop();
+
+ // dataset controllers need to cleanup associated data
+ for (i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
+ me.destroyDatasetMeta(i);
+ }
+
+ if (canvas) {
+ me.unbindEvents();
+ helpers.canvas.clear(me);
+ platform.releaseContext(me.ctx);
+ me.canvas = null;
+ me.ctx = null;
+ }
+
+ plugins.notify(me, 'destroy');
+
+ delete Chart.instances[me.id];
+ },
+
+ toBase64Image: function() {
+ return this.canvas.toDataURL.apply(this.canvas, arguments);
+ },
+
+ initToolTip: function() {
+ var me = this;
+ me.tooltip = new Chart.Tooltip({
+ _chart: me,
+ _chartInstance: me, // deprecated, backward compatibility
+ _data: me.data,
+ _options: me.options.tooltips
+ }, me);
+ },
+
+ /**
+ * @private
+ */
+ bindEvents: function() {
+ var me = this;
+ var listeners = me._listeners = {};
+ var listener = function() {
+ me.eventHandler.apply(me, arguments);
+ };
+
+ helpers.each(me.options.events, function(type) {
+ platform.addEventListener(me, type, listener);
+ listeners[type] = listener;
+ });
+
+ // Elements used to detect size change should not be injected for non responsive charts.
+ // See https://github.com/chartjs/Chart.js/issues/2210
+ if (me.options.responsive) {
+ listener = function() {
+ me.resize();
+ };
+
+ platform.addEventListener(me, 'resize', listener);
+ listeners.resize = listener;
+ }
+ },
+
+ /**
+ * @private
+ */
+ unbindEvents: function() {
+ var me = this;
+ var listeners = me._listeners;
+ if (!listeners) {
+ return;
+ }
+
+ delete me._listeners;
+ helpers.each(listeners, function(listener, type) {
+ platform.removeEventListener(me, type, listener);
+ });
+ },
+
+ updateHoverStyle: function(elements, mode, enabled) {
+ var method = enabled ? 'setHoverStyle' : 'removeHoverStyle';
+ var element, i, ilen;
+
+ for (i = 0, ilen = elements.length; i < ilen; ++i) {
+ element = elements[i];
+ if (element) {
+ this.getDatasetMeta(element._datasetIndex).controller[method](element);
+ }
+ }
+ },
+
+ /**
+ * @private
+ */
+ eventHandler: function(e) {
+ var me = this;
+ var tooltip = me.tooltip;
+
+ if (plugins.notify(me, 'beforeEvent', [e]) === false) {
+ return;
+ }
+
+ // Buffer any update calls so that renders do not occur
+ me._bufferedRender = true;
+ me._bufferedRequest = null;
+
+ var changed = me.handleEvent(e);
+ changed |= tooltip && tooltip.handleEvent(e);
+
+ plugins.notify(me, 'afterEvent', [e]);
+
+ var bufferedRequest = me._bufferedRequest;
+ if (bufferedRequest) {
+ // If we have an update that was triggered, we need to do a normal render
+ me.render(bufferedRequest);
+ } else if (changed && !me.animating) {
+ // If entering, leaving, or changing elements, animate the change via pivot
+ me.stop();
+
+ // We only need to render at this point. Updating will cause scales to be
+ // recomputed generating flicker & using more memory than necessary.
+ me.render(me.options.hover.animationDuration, true);
+ }
+
+ me._bufferedRender = false;
+ me._bufferedRequest = null;
+
+ return me;
+ },
+
+ /**
+ * Handle an event
+ * @private
+ * @param {IEvent} event the event to handle
+ * @return {Boolean} true if the chart needs to re-render
+ */
+ handleEvent: function(e) {
+ var me = this;
+ var options = me.options || {};
+ var hoverOptions = options.hover;
+ var changed = false;
+
+ me.lastActive = me.lastActive || [];
+
+ // Find Active Elements for hover and tooltips
+ if (e.type === 'mouseout') {
+ me.active = [];
+ } else {
+ me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions);
+ }
+
+ // Invoke onHover hook
+ // Need to call with native event here to not break backwards compatibility
+ helpers.callback(options.onHover || options.hover.onHover, [e.native, me.active], me);
+
+ if (e.type === 'mouseup' || e.type === 'click') {
+ if (options.onClick) {
+ // Use e.native here for backwards compatibility
+ options.onClick.call(me, e.native, me.active);
+ }
+ }
+
+ // Remove styling for last active (even if it may still be active)
+ if (me.lastActive.length) {
+ me.updateHoverStyle(me.lastActive, hoverOptions.mode, false);
+ }
+
+ // Built in hover styling
+ if (me.active.length && hoverOptions.mode) {
+ me.updateHoverStyle(me.active, hoverOptions.mode, true);
+ }
+
+ changed = !helpers.arrayEquals(me.active, me.lastActive);
+
+ // Remember Last Actives
+ me.lastActive = me.active;
+
+ return changed;
+ }
+ });
+
+ /**
+ * Provided for backward compatibility, use Chart instead.
+ * @class Chart.Controller
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+ Chart.Controller = Chart;
+};
+
+},{"25":25,"28":28,"45":45,"48":48}],24:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];
+
+ /**
+ * Hooks the array methods that add or remove values ('push', pop', 'shift', 'splice',
+ * 'unshift') and notify the listener AFTER the array has been altered. Listeners are
+ * called on the 'onData*' callbacks (e.g. onDataPush, etc.) with same arguments.
+ */
+ function listenArrayEvents(array, listener) {
+ if (array._chartjs) {
+ array._chartjs.listeners.push(listener);
+ return;
+ }
+
+ Object.defineProperty(array, '_chartjs', {
+ configurable: true,
+ enumerable: false,
+ value: {
+ listeners: [listener]
+ }
+ });
+
+ arrayEvents.forEach(function(key) {
+ var method = 'onData' + key.charAt(0).toUpperCase() + key.slice(1);
+ var base = array[key];
+
+ Object.defineProperty(array, key, {
+ configurable: true,
+ enumerable: false,
+ value: function() {
+ var args = Array.prototype.slice.call(arguments);
+ var res = base.apply(this, args);
+
+ helpers.each(array._chartjs.listeners, function(object) {
+ if (typeof object[method] === 'function') {
+ object[method].apply(object, args);
+ }
+ });
+
+ return res;
+ }
+ });
+ });
+ }
+
+ /**
+ * Removes the given array event listener and cleanup extra attached properties (such as
+ * the _chartjs stub and overridden methods) if array doesn't have any more listeners.
+ */
+ function unlistenArrayEvents(array, listener) {
+ var stub = array._chartjs;
+ if (!stub) {
+ return;
+ }
+
+ var listeners = stub.listeners;
+ var index = listeners.indexOf(listener);
+ if (index !== -1) {
+ listeners.splice(index, 1);
+ }
+
+ if (listeners.length > 0) {
+ return;
+ }
+
+ arrayEvents.forEach(function(key) {
+ delete array[key];
+ });
+
+ delete array._chartjs;
+ }
+
+ // Base class for all dataset controllers (line, bar, etc)
+ Chart.DatasetController = function(chart, datasetIndex) {
+ this.initialize(chart, datasetIndex);
+ };
+
+ helpers.extend(Chart.DatasetController.prototype, {
+
+ /**
+ * Element type used to generate a meta dataset (e.g. Chart.element.Line).
+ * @type {Chart.core.element}
+ */
+ datasetElementType: null,
+
+ /**
+ * Element type used to generate a meta data (e.g. Chart.element.Point).
+ * @type {Chart.core.element}
+ */
+ dataElementType: null,
+
+ initialize: function(chart, datasetIndex) {
+ var me = this;
+ me.chart = chart;
+ me.index = datasetIndex;
+ me.linkScales();
+ me.addElements();
+ },
+
+ updateIndex: function(datasetIndex) {
+ this.index = datasetIndex;
+ },
+
+ linkScales: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var dataset = me.getDataset();
+
+ if (meta.xAxisID === null) {
+ meta.xAxisID = dataset.xAxisID || me.chart.options.scales.xAxes[0].id;
+ }
+ if (meta.yAxisID === null) {
+ meta.yAxisID = dataset.yAxisID || me.chart.options.scales.yAxes[0].id;
+ }
+ },
+
+ getDataset: function() {
+ return this.chart.data.datasets[this.index];
+ },
+
+ getMeta: function() {
+ return this.chart.getDatasetMeta(this.index);
+ },
+
+ getScaleForId: function(scaleID) {
+ return this.chart.scales[scaleID];
+ },
+
+ reset: function() {
+ this.update(true);
+ },
+
+ /**
+ * @private
+ */
+ destroy: function() {
+ if (this._data) {
+ unlistenArrayEvents(this._data, this);
+ }
+ },
+
+ createMetaDataset: function() {
+ var me = this;
+ var type = me.datasetElementType;
+ return type && new type({
+ _chart: me.chart,
+ _datasetIndex: me.index
+ });
+ },
+
+ createMetaData: function(index) {
+ var me = this;
+ var type = me.dataElementType;
+ return type && new type({
+ _chart: me.chart,
+ _datasetIndex: me.index,
+ _index: index
+ });
+ },
+
+ addElements: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var data = me.getDataset().data || [];
+ var metaData = meta.data;
+ var i, ilen;
+
+ for (i = 0, ilen = data.length; i < ilen; ++i) {
+ metaData[i] = metaData[i] || me.createMetaData(i);
+ }
+
+ meta.dataset = meta.dataset || me.createMetaDataset();
+ },
+
+ addElementAndReset: function(index) {
+ var element = this.createMetaData(index);
+ this.getMeta().data.splice(index, 0, element);
+ this.updateElement(element, index, true);
+ },
+
+ buildOrUpdateElements: function() {
+ var me = this;
+ var dataset = me.getDataset();
+ var data = dataset.data || (dataset.data = []);
+
+ // In order to correctly handle data addition/deletion animation (an thus simulate
+ // real-time charts), we need to monitor these data modifications and synchronize
+ // the internal meta data accordingly.
+ if (me._data !== data) {
+ if (me._data) {
+ // This case happens when the user replaced the data array instance.
+ unlistenArrayEvents(me._data, me);
+ }
+
+ listenArrayEvents(data, me);
+ me._data = data;
+ }
+
+ // Re-sync meta data in case the user replaced the data array or if we missed
+ // any updates and so make sure that we handle number of datapoints changing.
+ me.resyncElements();
+ },
+
+ update: helpers.noop,
+
+ transition: function(easingValue) {
+ var meta = this.getMeta();
+ var elements = meta.data || [];
+ var ilen = elements.length;
+ var i = 0;
+
+ for (; i < ilen; ++i) {
+ elements[i].transition(easingValue);
+ }
+
+ if (meta.dataset) {
+ meta.dataset.transition(easingValue);
+ }
+ },
+
+ draw: function() {
+ var meta = this.getMeta();
+ var elements = meta.data || [];
+ var ilen = elements.length;
+ var i = 0;
+
+ if (meta.dataset) {
+ meta.dataset.draw();
+ }
+
+ for (; i < ilen; ++i) {
+ elements[i].draw();
+ }
+ },
+
+ removeHoverStyle: function(element, elementOpts) {
+ var dataset = this.chart.data.datasets[element._datasetIndex];
+ var index = element._index;
+ var custom = element.custom || {};
+ var valueOrDefault = helpers.valueAtIndexOrDefault;
+ var model = element._model;
+
+ model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueOrDefault(dataset.backgroundColor, index, elementOpts.backgroundColor);
+ model.borderColor = custom.borderColor ? custom.borderColor : valueOrDefault(dataset.borderColor, index, elementOpts.borderColor);
+ model.borderWidth = custom.borderWidth ? custom.borderWidth : valueOrDefault(dataset.borderWidth, index, elementOpts.borderWidth);
+ },
+
+ setHoverStyle: function(element) {
+ var dataset = this.chart.data.datasets[element._datasetIndex];
+ var index = element._index;
+ var custom = element.custom || {};
+ var valueOrDefault = helpers.valueAtIndexOrDefault;
+ var getHoverColor = helpers.getHoverColor;
+ var model = element._model;
+
+ model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : valueOrDefault(dataset.hoverBackgroundColor, index, getHoverColor(model.backgroundColor));
+ model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : valueOrDefault(dataset.hoverBorderColor, index, getHoverColor(model.borderColor));
+ model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : valueOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
+ },
+
+ /**
+ * @private
+ */
+ resyncElements: function() {
+ var me = this;
+ var meta = me.getMeta();
+ var data = me.getDataset().data;
+ var numMeta = meta.data.length;
+ var numData = data.length;
+
+ if (numData < numMeta) {
+ meta.data.splice(numData, numMeta - numData);
+ } else if (numData > numMeta) {
+ me.insertElements(numMeta, numData - numMeta);
+ }
+ },
+
+ /**
+ * @private
+ */
+ insertElements: function(start, count) {
+ for (var i = 0; i < count; ++i) {
+ this.addElementAndReset(start + i);
+ }
+ },
+
+ /**
+ * @private
+ */
+ onDataPush: function() {
+ this.insertElements(this.getDataset().data.length - 1, arguments.length);
+ },
+
+ /**
+ * @private
+ */
+ onDataPop: function() {
+ this.getMeta().data.pop();
+ },
+
+ /**
+ * @private
+ */
+ onDataShift: function() {
+ this.getMeta().data.shift();
+ },
+
+ /**
+ * @private
+ */
+ onDataSplice: function(start, count) {
+ this.getMeta().data.splice(start, count);
+ this.insertElements(start, arguments.length - 2);
+ },
+
+ /**
+ * @private
+ */
+ onDataUnshift: function() {
+ this.insertElements(0, arguments.length);
+ }
+ });
+
+ Chart.DatasetController.extend = helpers.inherits;
+};
+
+},{"45":45}],25:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+module.exports = {
+ /**
+ * @private
+ */
+ _set: function(scope, values) {
+ return helpers.merge(this[scope] || (this[scope] = {}), values);
+ }
+};
+
+},{"45":45}],26:[function(require,module,exports){
+'use strict';
+
+var color = require(3);
+var helpers = require(45);
+
+function interpolate(start, view, model, ease) {
+ var keys = Object.keys(model);
+ var i, ilen, key, actual, origin, target, type, c0, c1;
+
+ for (i = 0, ilen = keys.length; i < ilen; ++i) {
+ key = keys[i];
+
+ target = model[key];
+
+ // if a value is added to the model after pivot() has been called, the view
+ // doesn't contain it, so let's initialize the view to the target value.
+ if (!view.hasOwnProperty(key)) {
+ view[key] = target;
+ }
+
+ actual = view[key];
+
+ if (actual === target || key[0] === '_') {
+ continue;
+ }
+
+ if (!start.hasOwnProperty(key)) {
+ start[key] = actual;
+ }
+
+ origin = start[key];
+
+ type = typeof target;
+
+ if (type === typeof origin) {
+ if (type === 'string') {
+ c0 = color(origin);
+ if (c0.valid) {
+ c1 = color(target);
+ if (c1.valid) {
+ view[key] = c1.mix(c0, ease).rgbString();
+ continue;
+ }
+ }
+ } else if (type === 'number' && isFinite(origin) && isFinite(target)) {
+ view[key] = origin + (target - origin) * ease;
+ continue;
+ }
+ }
+
+ view[key] = target;
+ }
+}
+
+var Element = function(configuration) {
+ helpers.extend(this, configuration);
+ this.initialize.apply(this, arguments);
+};
+
+helpers.extend(Element.prototype, {
+
+ initialize: function() {
+ this.hidden = false;
+ },
+
+ pivot: function() {
+ var me = this;
+ if (!me._view) {
+ me._view = helpers.clone(me._model);
+ }
+ me._start = {};
+ return me;
+ },
+
+ transition: function(ease) {
+ var me = this;
+ var model = me._model;
+ var start = me._start;
+ var view = me._view;
+
+ // No animation -> No Transition
+ if (!model || ease === 1) {
+ me._view = model;
+ me._start = null;
+ return me;
+ }
+
+ if (!view) {
+ view = me._view = {};
+ }
+
+ if (!start) {
+ start = me._start = {};
+ }
+
+ interpolate(start, view, model, ease);
+
+ return me;
+ },
+
+ tooltipPosition: function() {
+ return {
+ x: this._model.x,
+ y: this._model.y
+ };
+ },
+
+ hasValue: function() {
+ return helpers.isNumber(this._model.x) && helpers.isNumber(this._model.y);
+ }
+});
+
+Element.extend = helpers.inherits;
+
+module.exports = Element;
+
+},{"3":3,"45":45}],27:[function(require,module,exports){
+/* global window: false */
+/* global document: false */
+'use strict';
+
+var color = require(3);
+var defaults = require(25);
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ // -- Basic js utility methods
+
+ helpers.configMerge = function(/* objects ... */) {
+ return helpers.merge(helpers.clone(arguments[0]), [].slice.call(arguments, 1), {
+ merger: function(key, target, source, options) {
+ var tval = target[key] || {};
+ var sval = source[key];
+
+ if (key === 'scales') {
+ // scale config merging is complex. Add our own function here for that
+ target[key] = helpers.scaleMerge(tval, sval);
+ } else if (key === 'scale') {
+ // used in polar area & radar charts since there is only one scale
+ target[key] = helpers.merge(tval, [Chart.scaleService.getScaleDefaults(sval.type), sval]);
+ } else {
+ helpers._merger(key, target, source, options);
+ }
+ }
+ });
+ };
+
+ helpers.scaleMerge = function(/* objects ... */) {
+ return helpers.merge(helpers.clone(arguments[0]), [].slice.call(arguments, 1), {
+ merger: function(key, target, source, options) {
+ if (key === 'xAxes' || key === 'yAxes') {
+ var slen = source[key].length;
+ var i, type, scale;
+
+ if (!target[key]) {
+ target[key] = [];
+ }
+
+ for (i = 0; i < slen; ++i) {
+ scale = source[key][i];
+ type = helpers.valueOrDefault(scale.type, key === 'xAxes' ? 'category' : 'linear');
+
+ if (i >= target[key].length) {
+ target[key].push({});
+ }
+
+ if (!target[key][i].type || (scale.type && scale.type !== target[key][i].type)) {
+ // new/untyped scale or type changed: let's apply the new defaults
+ // then merge source scale to correctly overwrite the defaults.
+ helpers.merge(target[key][i], [Chart.scaleService.getScaleDefaults(type), scale]);
+ } else {
+ // scales type are the same
+ helpers.merge(target[key][i], scale);
+ }
+ }
+ } else {
+ helpers._merger(key, target, source, options);
+ }
+ }
+ });
+ };
+
+ helpers.where = function(collection, filterCallback) {
+ if (helpers.isArray(collection) && Array.prototype.filter) {
+ return collection.filter(filterCallback);
+ }
+ var filtered = [];
+
+ helpers.each(collection, function(item) {
+ if (filterCallback(item)) {
+ filtered.push(item);
+ }
+ });
+
+ return filtered;
+ };
+ helpers.findIndex = Array.prototype.findIndex ?
+ function(array, callback, scope) {
+ return array.findIndex(callback, scope);
+ } :
+ function(array, callback, scope) {
+ scope = scope === undefined ? array : scope;
+ for (var i = 0, ilen = array.length; i < ilen; ++i) {
+ if (callback.call(scope, array[i], i, array)) {
+ return i;
+ }
+ }
+ return -1;
+ };
+ helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) {
+ // Default to start of the array
+ if (helpers.isNullOrUndef(startIndex)) {
+ startIndex = -1;
+ }
+ for (var i = startIndex + 1; i < arrayToSearch.length; i++) {
+ var currentItem = arrayToSearch[i];
+ if (filterCallback(currentItem)) {
+ return currentItem;
+ }
+ }
+ };
+ helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) {
+ // Default to end of the array
+ if (helpers.isNullOrUndef(startIndex)) {
+ startIndex = arrayToSearch.length;
+ }
+ for (var i = startIndex - 1; i >= 0; i--) {
+ var currentItem = arrayToSearch[i];
+ if (filterCallback(currentItem)) {
+ return currentItem;
+ }
+ }
+ };
+
+ // -- Math methods
+ helpers.isNumber = function(n) {
+ return !isNaN(parseFloat(n)) && isFinite(n);
+ };
+ helpers.almostEquals = function(x, y, epsilon) {
+ return Math.abs(x - y) < epsilon;
+ };
+ helpers.almostWhole = function(x, epsilon) {
+ var rounded = Math.round(x);
+ return (((rounded - epsilon) < x) && ((rounded + epsilon) > x));
+ };
+ helpers.max = function(array) {
+ return array.reduce(function(max, value) {
+ if (!isNaN(value)) {
+ return Math.max(max, value);
+ }
+ return max;
+ }, Number.NEGATIVE_INFINITY);
+ };
+ helpers.min = function(array) {
+ return array.reduce(function(min, value) {
+ if (!isNaN(value)) {
+ return Math.min(min, value);
+ }
+ return min;
+ }, Number.POSITIVE_INFINITY);
+ };
+ helpers.sign = Math.sign ?
+ function(x) {
+ return Math.sign(x);
+ } :
+ function(x) {
+ x = +x; // convert to a number
+ if (x === 0 || isNaN(x)) {
+ return x;
+ }
+ return x > 0 ? 1 : -1;
+ };
+ helpers.log10 = Math.log10 ?
+ function(x) {
+ return Math.log10(x);
+ } :
+ function(x) {
+ return Math.log(x) / Math.LN10;
+ };
+ helpers.toRadians = function(degrees) {
+ return degrees * (Math.PI / 180);
+ };
+ helpers.toDegrees = function(radians) {
+ return radians * (180 / Math.PI);
+ };
+ // Gets the angle from vertical upright to the point about a centre.
+ helpers.getAngleFromPoint = function(centrePoint, anglePoint) {
+ var distanceFromXCenter = anglePoint.x - centrePoint.x;
+ var distanceFromYCenter = anglePoint.y - centrePoint.y;
+ var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);
+
+ var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter);
+
+ if (angle < (-0.5 * Math.PI)) {
+ angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2]
+ }
+
+ return {
+ angle: angle,
+ distance: radialDistanceFromCenter
+ };
+ };
+ helpers.distanceBetweenPoints = function(pt1, pt2) {
+ return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));
+ };
+ helpers.aliasPixel = function(pixelWidth) {
+ return (pixelWidth % 2 === 0) ? 0 : 0.5;
+ };
+ helpers.splineCurve = function(firstPoint, middlePoint, afterPoint, t) {
+ // Props to Rob Spencer at scaled innovation for his post on splining between points
+ // http://scaledinnovation.com/analytics/splines/aboutSplines.html
+
+ // This function must also respect "skipped" points
+
+ var previous = firstPoint.skip ? middlePoint : firstPoint;
+ var current = middlePoint;
+ var next = afterPoint.skip ? middlePoint : afterPoint;
+
+ var d01 = Math.sqrt(Math.pow(current.x - previous.x, 2) + Math.pow(current.y - previous.y, 2));
+ var d12 = Math.sqrt(Math.pow(next.x - current.x, 2) + Math.pow(next.y - current.y, 2));
+
+ var s01 = d01 / (d01 + d12);
+ var s12 = d12 / (d01 + d12);
+
+ // If all points are the same, s01 & s02 will be inf
+ s01 = isNaN(s01) ? 0 : s01;
+ s12 = isNaN(s12) ? 0 : s12;
+
+ var fa = t * s01; // scaling factor for triangle Ta
+ var fb = t * s12;
+
+ return {
+ previous: {
+ x: current.x - fa * (next.x - previous.x),
+ y: current.y - fa * (next.y - previous.y)
+ },
+ next: {
+ x: current.x + fb * (next.x - previous.x),
+ y: current.y + fb * (next.y - previous.y)
+ }
+ };
+ };
+ helpers.EPSILON = Number.EPSILON || 1e-14;
+ helpers.splineCurveMonotone = function(points) {
+ // This function calculates Bézier control points in a similar way than |splineCurve|,
+ // but preserves monotonicity of the provided data and ensures no local extremums are added
+ // between the dataset discrete points due to the interpolation.
+ // See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
+
+ var pointsWithTangents = (points || []).map(function(point) {
+ return {
+ model: point._model,
+ deltaK: 0,
+ mK: 0
+ };
+ });
+
+ // Calculate slopes (deltaK) and initialize tangents (mK)
+ var pointsLen = pointsWithTangents.length;
+ var i, pointBefore, pointCurrent, pointAfter;
+ for (i = 0; i < pointsLen; ++i) {
+ pointCurrent = pointsWithTangents[i];
+ if (pointCurrent.model.skip) {
+ continue;
+ }
+
+ pointBefore = i > 0 ? pointsWithTangents[i - 1] : null;
+ pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;
+ if (pointAfter && !pointAfter.model.skip) {
+ var slopeDeltaX = (pointAfter.model.x - pointCurrent.model.x);
+
+ // In the case of two points that appear at the same x pixel, slopeDeltaX is 0
+ pointCurrent.deltaK = slopeDeltaX !== 0 ? (pointAfter.model.y - pointCurrent.model.y) / slopeDeltaX : 0;
+ }
+
+ if (!pointBefore || pointBefore.model.skip) {
+ pointCurrent.mK = pointCurrent.deltaK;
+ } else if (!pointAfter || pointAfter.model.skip) {
+ pointCurrent.mK = pointBefore.deltaK;
+ } else if (this.sign(pointBefore.deltaK) !== this.sign(pointCurrent.deltaK)) {
+ pointCurrent.mK = 0;
+ } else {
+ pointCurrent.mK = (pointBefore.deltaK + pointCurrent.deltaK) / 2;
+ }
+ }
+
+ // Adjust tangents to ensure monotonic properties
+ var alphaK, betaK, tauK, squaredMagnitude;
+ for (i = 0; i < pointsLen - 1; ++i) {
+ pointCurrent = pointsWithTangents[i];
+ pointAfter = pointsWithTangents[i + 1];
+ if (pointCurrent.model.skip || pointAfter.model.skip) {
+ continue;
+ }
+
+ if (helpers.almostEquals(pointCurrent.deltaK, 0, this.EPSILON)) {
+ pointCurrent.mK = pointAfter.mK = 0;
+ continue;
+ }
+
+ alphaK = pointCurrent.mK / pointCurrent.deltaK;
+ betaK = pointAfter.mK / pointCurrent.deltaK;
+ squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2);
+ if (squaredMagnitude <= 9) {
+ continue;
+ }
+
+ tauK = 3 / Math.sqrt(squaredMagnitude);
+ pointCurrent.mK = alphaK * tauK * pointCurrent.deltaK;
+ pointAfter.mK = betaK * tauK * pointCurrent.deltaK;
+ }
+
+ // Compute control points
+ var deltaX;
+ for (i = 0; i < pointsLen; ++i) {
+ pointCurrent = pointsWithTangents[i];
+ if (pointCurrent.model.skip) {
+ continue;
+ }
+
+ pointBefore = i > 0 ? pointsWithTangents[i - 1] : null;
+ pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;
+ if (pointBefore && !pointBefore.model.skip) {
+ deltaX = (pointCurrent.model.x - pointBefore.model.x) / 3;
+ pointCurrent.model.controlPointPreviousX = pointCurrent.model.x - deltaX;
+ pointCurrent.model.controlPointPreviousY = pointCurrent.model.y - deltaX * pointCurrent.mK;
+ }
+ if (pointAfter && !pointAfter.model.skip) {
+ deltaX = (pointAfter.model.x - pointCurrent.model.x) / 3;
+ pointCurrent.model.controlPointNextX = pointCurrent.model.x + deltaX;
+ pointCurrent.model.controlPointNextY = pointCurrent.model.y + deltaX * pointCurrent.mK;
+ }
+ }
+ };
+ helpers.nextItem = function(collection, index, loop) {
+ if (loop) {
+ return index >= collection.length - 1 ? collection[0] : collection[index + 1];
+ }
+ return index >= collection.length - 1 ? collection[collection.length - 1] : collection[index + 1];
+ };
+ helpers.previousItem = function(collection, index, loop) {
+ if (loop) {
+ return index <= 0 ? collection[collection.length - 1] : collection[index - 1];
+ }
+ return index <= 0 ? collection[0] : collection[index - 1];
+ };
+ // Implementation of the nice number algorithm used in determining where axis labels will go
+ helpers.niceNum = function(range, round) {
+ var exponent = Math.floor(helpers.log10(range));
+ var fraction = range / Math.pow(10, exponent);
+ var niceFraction;
+
+ if (round) {
+ if (fraction < 1.5) {
+ niceFraction = 1;
+ } else if (fraction < 3) {
+ niceFraction = 2;
+ } else if (fraction < 7) {
+ niceFraction = 5;
+ } else {
+ niceFraction = 10;
+ }
+ } else if (fraction <= 1.0) {
+ niceFraction = 1;
+ } else if (fraction <= 2) {
+ niceFraction = 2;
+ } else if (fraction <= 5) {
+ niceFraction = 5;
+ } else {
+ niceFraction = 10;
+ }
+
+ return niceFraction * Math.pow(10, exponent);
+ };
+ // Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
+ helpers.requestAnimFrame = (function() {
+ if (typeof window === 'undefined') {
+ return function(callback) {
+ callback();
+ };
+ }
+ return window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function(callback) {
+ return window.setTimeout(callback, 1000 / 60);
+ };
+ }());
+ // -- DOM methods
+ helpers.getRelativePosition = function(evt, chart) {
+ var mouseX, mouseY;
+ var e = evt.originalEvent || evt;
+ var canvas = evt.currentTarget || evt.srcElement;
+ var boundingRect = canvas.getBoundingClientRect();
+
+ var touches = e.touches;
+ if (touches && touches.length > 0) {
+ mouseX = touches[0].clientX;
+ mouseY = touches[0].clientY;
+
+ } else {
+ mouseX = e.clientX;
+ mouseY = e.clientY;
+ }
+
+ // Scale mouse coordinates into canvas coordinates
+ // by following the pattern laid out by 'jerryj' in the comments of
+ // http://www.html5canvastutorials.com/advanced/html5-canvas-mouse-coordinates/
+ var paddingLeft = parseFloat(helpers.getStyle(canvas, 'padding-left'));
+ var paddingTop = parseFloat(helpers.getStyle(canvas, 'padding-top'));
+ var paddingRight = parseFloat(helpers.getStyle(canvas, 'padding-right'));
+ var paddingBottom = parseFloat(helpers.getStyle(canvas, 'padding-bottom'));
+ var width = boundingRect.right - boundingRect.left - paddingLeft - paddingRight;
+ var height = boundingRect.bottom - boundingRect.top - paddingTop - paddingBottom;
+
+ // We divide by the current device pixel ratio, because the canvas is scaled up by that amount in each direction. However
+ // the backend model is in unscaled coordinates. Since we are going to deal with our model coordinates, we go back here
+ mouseX = Math.round((mouseX - boundingRect.left - paddingLeft) / (width) * canvas.width / chart.currentDevicePixelRatio);
+ mouseY = Math.round((mouseY - boundingRect.top - paddingTop) / (height) * canvas.height / chart.currentDevicePixelRatio);
+
+ return {
+ x: mouseX,
+ y: mouseY
+ };
+
+ };
+
+ // Private helper function to convert max-width/max-height values that may be percentages into a number
+ function parseMaxStyle(styleValue, node, parentProperty) {
+ var valueInPixels;
+ if (typeof styleValue === 'string') {
+ valueInPixels = parseInt(styleValue, 10);
+
+ if (styleValue.indexOf('%') !== -1) {
+ // percentage * size in dimension
+ valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];
+ }
+ } else {
+ valueInPixels = styleValue;
+ }
+
+ return valueInPixels;
+ }
+
+ /**
+ * Returns if the given value contains an effective constraint.
+ * @private
+ */
+ function isConstrainedValue(value) {
+ return value !== undefined && value !== null && value !== 'none';
+ }
+
+ // Private helper to get a constraint dimension
+ // @param domNode : the node to check the constraint on
+ // @param maxStyle : the style that defines the maximum for the direction we are using (maxWidth / maxHeight)
+ // @param percentageProperty : property of parent to use when calculating width as a percentage
+ // @see http://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser
+ function getConstraintDimension(domNode, maxStyle, percentageProperty) {
+ var view = document.defaultView;
+ var parentNode = domNode.parentNode;
+ var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
+ var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
+ var hasCNode = isConstrainedValue(constrainedNode);
+ var hasCContainer = isConstrainedValue(constrainedContainer);
+ var infinity = Number.POSITIVE_INFINITY;
+
+ if (hasCNode || hasCContainer) {
+ return Math.min(
+ hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity,
+ hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity);
+ }
+
+ return 'none';
+ }
+ // returns Number or undefined if no constraint
+ helpers.getConstraintWidth = function(domNode) {
+ return getConstraintDimension(domNode, 'max-width', 'clientWidth');
+ };
+ // returns Number or undefined if no constraint
+ helpers.getConstraintHeight = function(domNode) {
+ return getConstraintDimension(domNode, 'max-height', 'clientHeight');
+ };
+ helpers.getMaximumWidth = function(domNode) {
+ var container = domNode.parentNode;
+ if (!container) {
+ return domNode.clientWidth;
+ }
+
+ var paddingLeft = parseInt(helpers.getStyle(container, 'padding-left'), 10);
+ var paddingRight = parseInt(helpers.getStyle(container, 'padding-right'), 10);
+ var w = container.clientWidth - paddingLeft - paddingRight;
+ var cw = helpers.getConstraintWidth(domNode);
+ return isNaN(cw) ? w : Math.min(w, cw);
+ };
+ helpers.getMaximumHeight = function(domNode) {
+ var container = domNode.parentNode;
+ if (!container) {
+ return domNode.clientHeight;
+ }
+
+ var paddingTop = parseInt(helpers.getStyle(container, 'padding-top'), 10);
+ var paddingBottom = parseInt(helpers.getStyle(container, 'padding-bottom'), 10);
+ var h = container.clientHeight - paddingTop - paddingBottom;
+ var ch = helpers.getConstraintHeight(domNode);
+ return isNaN(ch) ? h : Math.min(h, ch);
+ };
+ helpers.getStyle = function(el, property) {
+ return el.currentStyle ?
+ el.currentStyle[property] :
+ document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
+ };
+ helpers.retinaScale = function(chart, forceRatio) {
+ var pixelRatio = chart.currentDevicePixelRatio = forceRatio || window.devicePixelRatio || 1;
+ if (pixelRatio === 1) {
+ return;
+ }
+
+ var canvas = chart.canvas;
+ var height = chart.height;
+ var width = chart.width;
+
+ canvas.height = height * pixelRatio;
+ canvas.width = width * pixelRatio;
+ chart.ctx.scale(pixelRatio, pixelRatio);
+
+ // If no style has been set on the canvas, the render size is used as display size,
+ // making the chart visually bigger, so let's enforce it to the "correct" values.
+ // See https://github.com/chartjs/Chart.js/issues/3575
+ canvas.style.height = height + 'px';
+ canvas.style.width = width + 'px';
+ };
+ // -- Canvas methods
+ helpers.fontString = function(pixelSize, fontStyle, fontFamily) {
+ return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
+ };
+ helpers.longestText = function(ctx, font, arrayOfThings, cache) {
+ cache = cache || {};
+ var data = cache.data = cache.data || {};
+ var gc = cache.garbageCollect = cache.garbageCollect || [];
+
+ if (cache.font !== font) {
+ data = cache.data = {};
+ gc = cache.garbageCollect = [];
+ cache.font = font;
+ }
+
+ ctx.font = font;
+ var longest = 0;
+ helpers.each(arrayOfThings, function(thing) {
+ // Undefined strings and arrays should not be measured
+ if (thing !== undefined && thing !== null && helpers.isArray(thing) !== true) {
+ longest = helpers.measureText(ctx, data, gc, longest, thing);
+ } else if (helpers.isArray(thing)) {
+ // if it is an array lets measure each element
+ // to do maybe simplify this function a bit so we can do this more recursively?
+ helpers.each(thing, function(nestedThing) {
+ // Undefined strings and arrays should not be measured
+ if (nestedThing !== undefined && nestedThing !== null && !helpers.isArray(nestedThing)) {
+ longest = helpers.measureText(ctx, data, gc, longest, nestedThing);
+ }
+ });
+ }
+ });
+
+ var gcLen = gc.length / 2;
+ if (gcLen > arrayOfThings.length) {
+ for (var i = 0; i < gcLen; i++) {
+ delete data[gc[i]];
+ }
+ gc.splice(0, gcLen);
+ }
+ return longest;
+ };
+ helpers.measureText = function(ctx, data, gc, longest, string) {
+ var textWidth = data[string];
+ if (!textWidth) {
+ textWidth = data[string] = ctx.measureText(string).width;
+ gc.push(string);
+ }
+ if (textWidth > longest) {
+ longest = textWidth;
+ }
+ return longest;
+ };
+ helpers.numberOfLabelLines = function(arrayOfThings) {
+ var numberOfLines = 1;
+ helpers.each(arrayOfThings, function(thing) {
+ if (helpers.isArray(thing)) {
+ if (thing.length > numberOfLines) {
+ numberOfLines = thing.length;
+ }
+ }
+ });
+ return numberOfLines;
+ };
+
+ helpers.color = !color ?
+ function(value) {
+ console.error('Color.js not found!');
+ return value;
+ } :
+ function(value) {
+ /* global CanvasGradient */
+ if (value instanceof CanvasGradient) {
+ value = defaults.global.defaultColor;
+ }
+
+ return color(value);
+ };
+
+ helpers.getHoverColor = function(colorValue) {
+ /* global CanvasPattern */
+ return (colorValue instanceof CanvasPattern) ?
+ colorValue :
+ helpers.color(colorValue).saturate(0.5).darken(0.1).rgbString();
+ };
+};
+
+},{"25":25,"3":3,"45":45}],28:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+/**
+ * Helper function to get relative position for an event
+ * @param {Event|IEvent} event - The event to get the position for
+ * @param {Chart} chart - The chart
+ * @returns {Point} the event position
+ */
+function getRelativePosition(e, chart) {
+ if (e.native) {
+ return {
+ x: e.x,
+ y: e.y
+ };
+ }
+
+ return helpers.getRelativePosition(e, chart);
+}
+
+/**
+ * Helper function to traverse all of the visible elements in the chart
+ * @param chart {chart} the chart
+ * @param handler {Function} the callback to execute for each visible item
+ */
+function parseVisibleItems(chart, handler) {
+ var datasets = chart.data.datasets;
+ var meta, i, j, ilen, jlen;
+
+ for (i = 0, ilen = datasets.length; i < ilen; ++i) {
+ if (!chart.isDatasetVisible(i)) {
+ continue;
+ }
+
+ meta = chart.getDatasetMeta(i);
+ for (j = 0, jlen = meta.data.length; j < jlen; ++j) {
+ var element = meta.data[j];
+ if (!element._view.skip) {
+ handler(element);
+ }
+ }
+ }
+}
+
+/**
+ * Helper function to get the items that intersect the event position
+ * @param items {ChartElement[]} elements to filter
+ * @param position {Point} the point to be nearest to
+ * @return {ChartElement[]} the nearest items
+ */
+function getIntersectItems(chart, position) {
+ var elements = [];
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inRange(position.x, position.y)) {
+ elements.push(element);
+ }
+ });
+
+ return elements;
+}
+
+/**
+ * Helper function to get the items nearest to the event position considering all visible items in teh chart
+ * @param chart {Chart} the chart to look at elements from
+ * @param position {Point} the point to be nearest to
+ * @param intersect {Boolean} if true, only consider items that intersect the position
+ * @param distanceMetric {Function} function to provide the distance between points
+ * @return {ChartElement[]} the nearest items
+ */
+function getNearestItems(chart, position, intersect, distanceMetric) {
+ var minDistance = Number.POSITIVE_INFINITY;
+ var nearestItems = [];
+
+ parseVisibleItems(chart, function(element) {
+ if (intersect && !element.inRange(position.x, position.y)) {
+ return;
+ }
+
+ var center = element.getCenterPoint();
+ var distance = distanceMetric(position, center);
+
+ if (distance < minDistance) {
+ nearestItems = [element];
+ minDistance = distance;
+ } else if (distance === minDistance) {
+ // Can have multiple items at the same distance in which case we sort by size
+ nearestItems.push(element);
+ }
+ });
+
+ return nearestItems;
+}
+
+/**
+ * Get a distance metric function for two points based on the
+ * axis mode setting
+ * @param {String} axis the axis mode. x|y|xy
+ */
+function getDistanceMetricForAxis(axis) {
+ var useX = axis.indexOf('x') !== -1;
+ var useY = axis.indexOf('y') !== -1;
+
+ return function(pt1, pt2) {
+ var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;
+ var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;
+ return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
+ };
+}
+
+function indexMode(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ // Default axis for index mode is 'x' to match old behaviour
+ options.axis = options.axis || 'x';
+ var distanceMetric = getDistanceMetricForAxis(options.axis);
+ var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric);
+ var elements = [];
+
+ if (!items.length) {
+ return [];
+ }
+
+ chart.data.datasets.forEach(function(dataset, datasetIndex) {
+ if (chart.isDatasetVisible(datasetIndex)) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ var element = meta.data[items[0]._index];
+
+ // don't count items that are skipped (null data)
+ if (element && !element._view.skip) {
+ elements.push(element);
+ }
+ }
+ });
+
+ return elements;
+}
+
+/**
+ * @interface IInteractionOptions
+ */
+/**
+ * If true, only consider items that intersect the point
+ * @name IInterfaceOptions#boolean
+ * @type Boolean
+ */
+
+/**
+ * Contains interaction related functions
+ * @namespace Chart.Interaction
+ */
+module.exports = {
+ // Helper function for different modes
+ modes: {
+ single: function(chart, e) {
+ var position = getRelativePosition(e, chart);
+ var elements = [];
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inRange(position.x, position.y)) {
+ elements.push(element);
+ return elements;
+ }
+ });
+
+ return elements.slice(0, 1);
+ },
+
+ /**
+ * @function Chart.Interaction.modes.label
+ * @deprecated since version 2.4.0
+ * @todo remove at version 3
+ * @private
+ */
+ label: indexMode,
+
+ /**
+ * Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something
+ * If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
+ * @function Chart.Interaction.modes.index
+ * @since v2.4.0
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use during interaction
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ index: indexMode,
+
+ /**
+ * Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something
+ * If the options.intersect is false, we find the nearest item and return the items in that dataset
+ * @function Chart.Interaction.modes.dataset
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use during interaction
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ dataset: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ options.axis = options.axis || 'xy';
+ var distanceMetric = getDistanceMetricForAxis(options.axis);
+ var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric);
+
+ if (items.length > 0) {
+ items = chart.getDatasetMeta(items[0]._datasetIndex).data;
+ }
+
+ return items;
+ },
+
+ /**
+ * @function Chart.Interaction.modes.x-axis
+ * @deprecated since version 2.4.0. Use index mode and intersect == true
+ * @todo remove at version 3
+ * @private
+ */
+ 'x-axis': function(chart, e) {
+ return indexMode(chart, e, {intersect: false});
+ },
+
+ /**
+ * Point mode returns all elements that hit test based on the event position
+ * of the event
+ * @function Chart.Interaction.modes.intersect
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ point: function(chart, e) {
+ var position = getRelativePosition(e, chart);
+ return getIntersectItems(chart, position);
+ },
+
+ /**
+ * nearest mode returns the element closest to the point
+ * @function Chart.Interaction.modes.intersect
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ nearest: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ options.axis = options.axis || 'xy';
+ var distanceMetric = getDistanceMetricForAxis(options.axis);
+ var nearestItems = getNearestItems(chart, position, options.intersect, distanceMetric);
+
+ // We have multiple items at the same distance from the event. Now sort by smallest
+ if (nearestItems.length > 1) {
+ nearestItems.sort(function(a, b) {
+ var sizeA = a.getArea();
+ var sizeB = b.getArea();
+ var ret = sizeA - sizeB;
+
+ if (ret === 0) {
+ // if equal sort by dataset index
+ ret = a._datasetIndex - b._datasetIndex;
+ }
+
+ return ret;
+ });
+ }
+
+ // Return only 1 item
+ return nearestItems.slice(0, 1);
+ },
+
+ /**
+ * x mode returns the elements that hit-test at the current x coordinate
+ * @function Chart.Interaction.modes.x
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ x: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ var items = [];
+ var intersectsItem = false;
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inXRange(position.x)) {
+ items.push(element);
+ }
+
+ if (element.inRange(position.x, position.y)) {
+ intersectsItem = true;
+ }
+ });
+
+ // If we want to trigger on an intersect and we don't have any items
+ // that intersect the position, return nothing
+ if (options.intersect && !intersectsItem) {
+ items = [];
+ }
+ return items;
+ },
+
+ /**
+ * y mode returns the elements that hit-test at the current y coordinate
+ * @function Chart.Interaction.modes.y
+ * @param chart {chart} the chart we are returning items from
+ * @param e {Event} the event we are find things at
+ * @param options {IInteractionOptions} options to use
+ * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
+ */
+ y: function(chart, e, options) {
+ var position = getRelativePosition(e, chart);
+ var items = [];
+ var intersectsItem = false;
+
+ parseVisibleItems(chart, function(element) {
+ if (element.inYRange(position.y)) {
+ items.push(element);
+ }
+
+ if (element.inRange(position.x, position.y)) {
+ intersectsItem = true;
+ }
+ });
+
+ // If we want to trigger on an intersect and we don't have any items
+ // that intersect the position, return nothing
+ if (options.intersect && !intersectsItem) {
+ items = [];
+ }
+ return items;
+ }
+ }
+};
+
+},{"45":45}],29:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+
+defaults._set('global', {
+ responsive: true,
+ responsiveAnimationDuration: 0,
+ maintainAspectRatio: true,
+ events: ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'],
+ hover: {
+ onHover: null,
+ mode: 'nearest',
+ intersect: true,
+ animationDuration: 400
+ },
+ onClick: null,
+ defaultColor: 'rgba(0,0,0,0.1)',
+ defaultFontColor: '#666',
+ defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+ defaultFontSize: 12,
+ defaultFontStyle: 'normal',
+ showLines: true,
+
+ // Element defaults defined in element extensions
+ elements: {},
+
+ // Layout options such as padding
+ layout: {
+ padding: {
+ top: 0,
+ right: 0,
+ bottom: 0,
+ left: 0
+ }
+ }
+});
+
+module.exports = function() {
+
+ // Occupy the global variable of Chart, and create a simple base class
+ var Chart = function(item, config) {
+ this.construct(item, config);
+ return this;
+ };
+
+ Chart.Chart = Chart;
+
+ return Chart;
+};
+
+},{"25":25}],30:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ function filterByPosition(array, position) {
+ return helpers.where(array, function(v) {
+ return v.position === position;
+ });
+ }
+
+ function sortByWeight(array, reverse) {
+ array.forEach(function(v, i) {
+ v._tmpIndex_ = i;
+ return v;
+ });
+ array.sort(function(a, b) {
+ var v0 = reverse ? b : a;
+ var v1 = reverse ? a : b;
+ return v0.weight === v1.weight ?
+ v0._tmpIndex_ - v1._tmpIndex_ :
+ v0.weight - v1.weight;
+ });
+ array.forEach(function(v) {
+ delete v._tmpIndex_;
+ });
+ }
+
+ /**
+ * @interface ILayoutItem
+ * @prop {String} position - The position of the item in the chart layout. Possible values are
+ * 'left', 'top', 'right', 'bottom', and 'chartArea'
+ * @prop {Number} weight - The weight used to sort the item. Higher weights are further away from the chart area
+ * @prop {Boolean} fullWidth - if true, and the item is horizontal, then push vertical boxes down
+ * @prop {Function} isHorizontal - returns true if the layout item is horizontal (ie. top or bottom)
+ * @prop {Function} update - Takes two parameters: width and height. Returns size of item
+ * @prop {Function} getPadding - Returns an object with padding on the edges
+ * @prop {Number} width - Width of item. Must be valid after update()
+ * @prop {Number} height - Height of item. Must be valid after update()
+ * @prop {Number} left - Left edge of the item. Set by layout system and cannot be used in update
+ * @prop {Number} top - Top edge of the item. Set by layout system and cannot be used in update
+ * @prop {Number} right - Right edge of the item. Set by layout system and cannot be used in update
+ * @prop {Number} bottom - Bottom edge of the item. Set by layout system and cannot be used in update
+ */
+
+ // The layout service is very self explanatory. It's responsible for the layout within a chart.
+ // Scales, Legends and Plugins all rely on the layout service and can easily register to be placed anywhere they need
+ // It is this service's responsibility of carrying out that layout.
+ Chart.layoutService = {
+ defaults: {},
+
+ /**
+ * Register a box to a chart.
+ * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
+ * @param {Chart} chart - the chart to use
+ * @param {ILayoutItem} item - the item to add to be layed out
+ */
+ addBox: function(chart, item) {
+ if (!chart.boxes) {
+ chart.boxes = [];
+ }
+
+ // initialize item with default values
+ item.fullWidth = item.fullWidth || false;
+ item.position = item.position || 'top';
+ item.weight = item.weight || 0;
+
+ chart.boxes.push(item);
+ },
+
+ /**
+ * Remove a layoutItem from a chart
+ * @param {Chart} chart - the chart to remove the box from
+ * @param {Object} layoutItem - the item to remove from the layout
+ */
+ removeBox: function(chart, layoutItem) {
+ var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;
+ if (index !== -1) {
+ chart.boxes.splice(index, 1);
+ }
+ },
+
+ /**
+ * Sets (or updates) options on the given `item`.
+ * @param {Chart} chart - the chart in which the item lives (or will be added to)
+ * @param {Object} item - the item to configure with the given options
+ * @param {Object} options - the new item options.
+ */
+ configure: function(chart, item, options) {
+ var props = ['fullWidth', 'position', 'weight'];
+ var ilen = props.length;
+ var i = 0;
+ var prop;
+
+ for (; i < ilen; ++i) {
+ prop = props[i];
+ if (options.hasOwnProperty(prop)) {
+ item[prop] = options[prop];
+ }
+ }
+ },
+
+ /**
+ * Fits boxes of the given chart into the given size by having each box measure itself
+ * then running a fitting algorithm
+ * @param {Chart} chart - the chart
+ * @param {Number} width - the width to fit into
+ * @param {Number} height - the height to fit into
+ */
+ update: function(chart, width, height) {
+ if (!chart) {
+ return;
+ }
+
+ var layoutOptions = chart.options.layout || {};
+ var padding = helpers.options.toPadding(layoutOptions.padding);
+ var leftPadding = padding.left;
+ var rightPadding = padding.right;
+ var topPadding = padding.top;
+ var bottomPadding = padding.bottom;
+
+ var leftBoxes = filterByPosition(chart.boxes, 'left');
+ var rightBoxes = filterByPosition(chart.boxes, 'right');
+ var topBoxes = filterByPosition(chart.boxes, 'top');
+ var bottomBoxes = filterByPosition(chart.boxes, 'bottom');
+ var chartAreaBoxes = filterByPosition(chart.boxes, 'chartArea');
+
+ // Sort boxes by weight. A higher weight is further away from the chart area
+ sortByWeight(leftBoxes, true);
+ sortByWeight(rightBoxes, false);
+ sortByWeight(topBoxes, true);
+ sortByWeight(bottomBoxes, false);
+
+ // Essentially we now have any number of boxes on each of the 4 sides.
+ // Our canvas looks like the following.
+ // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and
+ // B1 is the bottom axis
+ // There are also 4 quadrant-like locations (left to right instead of clockwise) reserved for chart overlays
+ // These locations are single-box locations only, when trying to register a chartArea location that is already taken,
+ // an error will be thrown.
+ //
+ // |----------------------------------------------------|
+ // | T1 (Full Width) |
+ // |----------------------------------------------------|
+ // | | | T2 | |
+ // | |----|-------------------------------------|----|
+ // | | | C1 | | C2 | |
+ // | | |----| |----| |
+ // | | | | |
+ // | L1 | L2 | ChartArea (C0) | R1 |
+ // | | | | |
+ // | | |----| |----| |
+ // | | | C3 | | C4 | |
+ // | |----|-------------------------------------|----|
+ // | | | B1 | |
+ // |----------------------------------------------------|
+ // | B2 (Full Width) |
+ // |----------------------------------------------------|
+ //
+ // What we do to find the best sizing, we do the following
+ // 1. Determine the minimum size of the chart area.
+ // 2. Split the remaining width equally between each vertical axis
+ // 3. Split the remaining height equally between each horizontal axis
+ // 4. Give each layout the maximum size it can be. The layout will return it's minimum size
+ // 5. Adjust the sizes of each axis based on it's minimum reported size.
+ // 6. Refit each axis
+ // 7. Position each axis in the final location
+ // 8. Tell the chart the final location of the chart area
+ // 9. Tell any axes that overlay the chart area the positions of the chart area
+
+ // Step 1
+ var chartWidth = width - leftPadding - rightPadding;
+ var chartHeight = height - topPadding - bottomPadding;
+ var chartAreaWidth = chartWidth / 2; // min 50%
+ var chartAreaHeight = chartHeight / 2; // min 50%
+
+ // Step 2
+ var verticalBoxWidth = (width - chartAreaWidth) / (leftBoxes.length + rightBoxes.length);
+
+ // Step 3
+ var horizontalBoxHeight = (height - chartAreaHeight) / (topBoxes.length + bottomBoxes.length);
+
+ // Step 4
+ var maxChartAreaWidth = chartWidth;
+ var maxChartAreaHeight = chartHeight;
+ var minBoxSizes = [];
+
+ function getMinimumBoxSize(box) {
+ var minSize;
+ var isHorizontal = box.isHorizontal();
+
+ if (isHorizontal) {
+ minSize = box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, horizontalBoxHeight);
+ maxChartAreaHeight -= minSize.height;
+ } else {
+ minSize = box.update(verticalBoxWidth, chartAreaHeight);
+ maxChartAreaWidth -= minSize.width;
+ }
+
+ minBoxSizes.push({
+ horizontal: isHorizontal,
+ minSize: minSize,
+ box: box,
+ });
+ }
+
+ helpers.each(leftBoxes.concat(rightBoxes, topBoxes, bottomBoxes), getMinimumBoxSize);
+
+ // If a horizontal box has padding, we move the left boxes over to avoid ugly charts (see issue #2478)
+ var maxHorizontalLeftPadding = 0;
+ var maxHorizontalRightPadding = 0;
+ var maxVerticalTopPadding = 0;
+ var maxVerticalBottomPadding = 0;
+
+ helpers.each(topBoxes.concat(bottomBoxes), function(horizontalBox) {
+ if (horizontalBox.getPadding) {
+ var boxPadding = horizontalBox.getPadding();
+ maxHorizontalLeftPadding = Math.max(maxHorizontalLeftPadding, boxPadding.left);
+ maxHorizontalRightPadding = Math.max(maxHorizontalRightPadding, boxPadding.right);
+ }
+ });
+
+ helpers.each(leftBoxes.concat(rightBoxes), function(verticalBox) {
+ if (verticalBox.getPadding) {
+ var boxPadding = verticalBox.getPadding();
+ maxVerticalTopPadding = Math.max(maxVerticalTopPadding, boxPadding.top);
+ maxVerticalBottomPadding = Math.max(maxVerticalBottomPadding, boxPadding.bottom);
+ }
+ });
+
+ // At this point, maxChartAreaHeight and maxChartAreaWidth are the size the chart area could
+ // be if the axes are drawn at their minimum sizes.
+ // Steps 5 & 6
+ var totalLeftBoxesWidth = leftPadding;
+ var totalRightBoxesWidth = rightPadding;
+ var totalTopBoxesHeight = topPadding;
+ var totalBottomBoxesHeight = bottomPadding;
+
+ // Function to fit a box
+ function fitBox(box) {
+ var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minBox) {
+ return minBox.box === box;
+ });
+
+ if (minBoxSize) {
+ if (box.isHorizontal()) {
+ var scaleMargin = {
+ left: Math.max(totalLeftBoxesWidth, maxHorizontalLeftPadding),
+ right: Math.max(totalRightBoxesWidth, maxHorizontalRightPadding),
+ top: 0,
+ bottom: 0
+ };
+
+ // Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends
+ // on the margin. Sometimes they need to increase in size slightly
+ box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, chartHeight / 2, scaleMargin);
+ } else {
+ box.update(minBoxSize.minSize.width, maxChartAreaHeight);
+ }
+ }
+ }
+
+ // Update, and calculate the left and right margins for the horizontal boxes
+ helpers.each(leftBoxes.concat(rightBoxes), fitBox);
+
+ helpers.each(leftBoxes, function(box) {
+ totalLeftBoxesWidth += box.width;
+ });
+
+ helpers.each(rightBoxes, function(box) {
+ totalRightBoxesWidth += box.width;
+ });
+
+ // Set the Left and Right margins for the horizontal boxes
+ helpers.each(topBoxes.concat(bottomBoxes), fitBox);
+
+ // Figure out how much margin is on the top and bottom of the vertical boxes
+ helpers.each(topBoxes, function(box) {
+ totalTopBoxesHeight += box.height;
+ });
+
+ helpers.each(bottomBoxes, function(box) {
+ totalBottomBoxesHeight += box.height;
+ });
+
+ function finalFitVerticalBox(box) {
+ var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minSize) {
+ return minSize.box === box;
+ });
+
+ var scaleMargin = {
+ left: 0,
+ right: 0,
+ top: totalTopBoxesHeight,
+ bottom: totalBottomBoxesHeight
+ };
+
+ if (minBoxSize) {
+ box.update(minBoxSize.minSize.width, maxChartAreaHeight, scaleMargin);
+ }
+ }
+
+ // Let the left layout know the final margin
+ helpers.each(leftBoxes.concat(rightBoxes), finalFitVerticalBox);
+
+ // Recalculate because the size of each layout might have changed slightly due to the margins (label rotation for instance)
+ totalLeftBoxesWidth = leftPadding;
+ totalRightBoxesWidth = rightPadding;
+ totalTopBoxesHeight = topPadding;
+ totalBottomBoxesHeight = bottomPadding;
+
+ helpers.each(leftBoxes, function(box) {
+ totalLeftBoxesWidth += box.width;
+ });
+
+ helpers.each(rightBoxes, function(box) {
+ totalRightBoxesWidth += box.width;
+ });
+
+ helpers.each(topBoxes, function(box) {
+ totalTopBoxesHeight += box.height;
+ });
+ helpers.each(bottomBoxes, function(box) {
+ totalBottomBoxesHeight += box.height;
+ });
+
+ // We may be adding some padding to account for rotated x axis labels
+ var leftPaddingAddition = Math.max(maxHorizontalLeftPadding - totalLeftBoxesWidth, 0);
+ totalLeftBoxesWidth += leftPaddingAddition;
+ totalRightBoxesWidth += Math.max(maxHorizontalRightPadding - totalRightBoxesWidth, 0);
+
+ var topPaddingAddition = Math.max(maxVerticalTopPadding - totalTopBoxesHeight, 0);
+ totalTopBoxesHeight += topPaddingAddition;
+ totalBottomBoxesHeight += Math.max(maxVerticalBottomPadding - totalBottomBoxesHeight, 0);
+
+ // Figure out if our chart area changed. This would occur if the dataset layout label rotation
+ // changed due to the application of the margins in step 6. Since we can only get bigger, this is safe to do
+ // without calling `fit` again
+ var newMaxChartAreaHeight = height - totalTopBoxesHeight - totalBottomBoxesHeight;
+ var newMaxChartAreaWidth = width - totalLeftBoxesWidth - totalRightBoxesWidth;
+
+ if (newMaxChartAreaWidth !== maxChartAreaWidth || newMaxChartAreaHeight !== maxChartAreaHeight) {
+ helpers.each(leftBoxes, function(box) {
+ box.height = newMaxChartAreaHeight;
+ });
+
+ helpers.each(rightBoxes, function(box) {
+ box.height = newMaxChartAreaHeight;
+ });
+
+ helpers.each(topBoxes, function(box) {
+ if (!box.fullWidth) {
+ box.width = newMaxChartAreaWidth;
+ }
+ });
+
+ helpers.each(bottomBoxes, function(box) {
+ if (!box.fullWidth) {
+ box.width = newMaxChartAreaWidth;
+ }
+ });
+
+ maxChartAreaHeight = newMaxChartAreaHeight;
+ maxChartAreaWidth = newMaxChartAreaWidth;
+ }
+
+ // Step 7 - Position the boxes
+ var left = leftPadding + leftPaddingAddition;
+ var top = topPadding + topPaddingAddition;
+
+ function placeBox(box) {
+ if (box.isHorizontal()) {
+ box.left = box.fullWidth ? leftPadding : totalLeftBoxesWidth;
+ box.right = box.fullWidth ? width - rightPadding : totalLeftBoxesWidth + maxChartAreaWidth;
+ box.top = top;
+ box.bottom = top + box.height;
+
+ // Move to next point
+ top = box.bottom;
+
+ } else {
+
+ box.left = left;
+ box.right = left + box.width;
+ box.top = totalTopBoxesHeight;
+ box.bottom = totalTopBoxesHeight + maxChartAreaHeight;
+
+ // Move to next point
+ left = box.right;
+ }
+ }
+
+ helpers.each(leftBoxes.concat(topBoxes), placeBox);
+
+ // Account for chart width and height
+ left += maxChartAreaWidth;
+ top += maxChartAreaHeight;
+
+ helpers.each(rightBoxes, placeBox);
+ helpers.each(bottomBoxes, placeBox);
+
+ // Step 8
+ chart.chartArea = {
+ left: totalLeftBoxesWidth,
+ top: totalTopBoxesHeight,
+ right: totalLeftBoxesWidth + maxChartAreaWidth,
+ bottom: totalTopBoxesHeight + maxChartAreaHeight
+ };
+
+ // Step 9
+ helpers.each(chartAreaBoxes, function(box) {
+ box.left = chart.chartArea.left;
+ box.top = chart.chartArea.top;
+ box.right = chart.chartArea.right;
+ box.bottom = chart.chartArea.bottom;
+
+ box.update(maxChartAreaWidth, maxChartAreaHeight);
+ });
+ }
+ };
+};
+
+},{"45":45}],31:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ plugins: {}
+});
+
+module.exports = function(Chart) {
+
+ /**
+ * The plugin service singleton
+ * @namespace Chart.plugins
+ * @since 2.1.0
+ */
+ Chart.plugins = {
+ /**
+ * Globally registered plugins.
+ * @private
+ */
+ _plugins: [],
+
+ /**
+ * This identifier is used to invalidate the descriptors cache attached to each chart
+ * when a global plugin is registered or unregistered. In this case, the cache ID is
+ * incremented and descriptors are regenerated during following API calls.
+ * @private
+ */
+ _cacheId: 0,
+
+ /**
+ * Registers the given plugin(s) if not already registered.
+ * @param {Array|Object} plugins plugin instance(s).
+ */
+ register: function(plugins) {
+ var p = this._plugins;
+ ([]).concat(plugins).forEach(function(plugin) {
+ if (p.indexOf(plugin) === -1) {
+ p.push(plugin);
+ }
+ });
+
+ this._cacheId++;
+ },
+
+ /**
+ * Unregisters the given plugin(s) only if registered.
+ * @param {Array|Object} plugins plugin instance(s).
+ */
+ unregister: function(plugins) {
+ var p = this._plugins;
+ ([]).concat(plugins).forEach(function(plugin) {
+ var idx = p.indexOf(plugin);
+ if (idx !== -1) {
+ p.splice(idx, 1);
+ }
+ });
+
+ this._cacheId++;
+ },
+
+ /**
+ * Remove all registered plugins.
+ * @since 2.1.5
+ */
+ clear: function() {
+ this._plugins = [];
+ this._cacheId++;
+ },
+
+ /**
+ * Returns the number of registered plugins?
+ * @returns {Number}
+ * @since 2.1.5
+ */
+ count: function() {
+ return this._plugins.length;
+ },
+
+ /**
+ * Returns all registered plugin instances.
+ * @returns {Array} array of plugin objects.
+ * @since 2.1.5
+ */
+ getAll: function() {
+ return this._plugins;
+ },
+
+ /**
+ * Calls enabled plugins for `chart` on the specified hook and with the given args.
+ * This method immediately returns as soon as a plugin explicitly returns false. The
+ * returned value can be used, for instance, to interrupt the current action.
+ * @param {Object} chart - The chart instance for which plugins should be called.
+ * @param {String} hook - The name of the plugin method to call (e.g. 'beforeUpdate').
+ * @param {Array} [args] - Extra arguments to apply to the hook call.
+ * @returns {Boolean} false if any of the plugins return false, else returns true.
+ */
+ notify: function(chart, hook, args) {
+ var descriptors = this.descriptors(chart);
+ var ilen = descriptors.length;
+ var i, descriptor, plugin, params, method;
+
+ for (i = 0; i < ilen; ++i) {
+ descriptor = descriptors[i];
+ plugin = descriptor.plugin;
+ method = plugin[hook];
+ if (typeof method === 'function') {
+ params = [chart].concat(args || []);
+ params.push(descriptor.options);
+ if (method.apply(plugin, params) === false) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ },
+
+ /**
+ * Returns descriptors of enabled plugins for the given chart.
+ * @returns {Array} [{ plugin, options }]
+ * @private
+ */
+ descriptors: function(chart) {
+ var cache = chart._plugins || (chart._plugins = {});
+ if (cache.id === this._cacheId) {
+ return cache.descriptors;
+ }
+
+ var plugins = [];
+ var descriptors = [];
+ var config = (chart && chart.config) || {};
+ var options = (config.options && config.options.plugins) || {};
+
+ this._plugins.concat(config.plugins || []).forEach(function(plugin) {
+ var idx = plugins.indexOf(plugin);
+ if (idx !== -1) {
+ return;
+ }
+
+ var id = plugin.id;
+ var opts = options[id];
+ if (opts === false) {
+ return;
+ }
+
+ if (opts === true) {
+ opts = helpers.clone(defaults.global.plugins[id]);
+ }
+
+ plugins.push(plugin);
+ descriptors.push({
+ plugin: plugin,
+ options: opts || {}
+ });
+ });
+
+ cache.descriptors = descriptors;
+ cache.id = this._cacheId;
+ return descriptors;
+ }
+ };
+
+ /**
+ * Plugin extension hooks.
+ * @interface IPlugin
+ * @since 2.1.0
+ */
+ /**
+ * @method IPlugin#beforeInit
+ * @desc Called before initializing `chart`.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#afterInit
+ * @desc Called after `chart` has been initialized and before the first update.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeUpdate
+ * @desc Called before updating `chart`. If any plugin returns `false`, the update
+ * is cancelled (and thus subsequent render(s)) until another `update` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart update.
+ */
+ /**
+ * @method IPlugin#afterUpdate
+ * @desc Called after `chart` has been updated and before rendering. Note that this
+ * hook will not be called if the chart update has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDatasetsUpdate
+ * @desc Called before updating the `chart` datasets. If any plugin returns `false`,
+ * the datasets update is cancelled until another `update` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} false to cancel the datasets update.
+ * @since version 2.1.5
+ */
+ /**
+ * @method IPlugin#afterDatasetsUpdate
+ * @desc Called after the `chart` datasets have been updated. Note that this hook
+ * will not be called if the datasets update has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @since version 2.1.5
+ */
+ /**
+ * @method IPlugin#beforeDatasetUpdate
+ * @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
+ * returns `false`, the datasets update is cancelled until another `update` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetUpdate
+ * @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
+ * that this hook will not be called if the datasets update has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeLayout
+ * @desc Called before laying out `chart`. If any plugin returns `false`,
+ * the layout update is cancelled until another `update` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart layout.
+ */
+ /**
+ * @method IPlugin#afterLayout
+ * @desc Called after the `chart` has been layed out. Note that this hook will not
+ * be called if the layout update has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeRender
+ * @desc Called before rendering `chart`. If any plugin returns `false`,
+ * the rendering is cancelled until another `render` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart rendering.
+ */
+ /**
+ * @method IPlugin#afterRender
+ * @desc Called after the `chart` has been fully rendered (and animation completed). Note
+ * that this hook will not be called if the rendering has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDraw
+ * @desc Called before drawing `chart` at every animation frame specified by the given
+ * easing value. If any plugin returns `false`, the frame drawing is cancelled until
+ * another `render` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart drawing.
+ */
+ /**
+ * @method IPlugin#afterDraw
+ * @desc Called after the `chart` has been drawn for the specific easing value. Note
+ * that this hook will not be called if the drawing has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDatasetsDraw
+ * @desc Called before drawing the `chart` datasets. If any plugin returns `false`,
+ * the datasets drawing is cancelled until another `render` is triggered.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetsDraw
+ * @desc Called after the `chart` datasets have been drawn. Note that this hook
+ * will not be called if the datasets drawing has been previously cancelled.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeDatasetDraw
+ * @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
+ * are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
+ * is cancelled until another `render` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetDraw
+ * @desc Called after the `chart` datasets at the given `args.index` have been drawn
+ * (datasets are drawn in the reverse order). Note that this hook will not be called
+ * if the datasets drawing has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Number} args.index - The dataset index.
+ * @param {Object} args.meta - The dataset metadata.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeTooltipDraw
+ * @desc Called before drawing the `tooltip`. If any plugin returns `false`,
+ * the tooltip drawing is cancelled until another `render` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.tooltip - The tooltip.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart tooltip drawing.
+ */
+ /**
+ * @method IPlugin#afterTooltipDraw
+ * @desc Called after drawing the `tooltip`. Note that this hook will not
+ * be called if the tooltip drawing has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.tooltip - The tooltip.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#beforeEvent
+ * @desc Called before processing the specified `event`. If any plugin returns `false`,
+ * the event will be discarded.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {IEvent} event - The event object.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#afterEvent
+ * @desc Called after the `event` has been consumed. Note that this hook
+ * will not be called if the `event` has been previously discarded.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {IEvent} event - The event object.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#resize
+ * @desc Called after the chart as been resized.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Number} size - The new canvas display size (eq. canvas.style width & height).
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#destroy
+ * @desc Called after the chart as been destroyed.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {Object} options - The plugin options.
+ */
+
+ /**
+ * Provided for backward compatibility, use Chart.plugins instead
+ * @namespace Chart.pluginService
+ * @deprecated since version 2.1.5
+ * @todo remove at version 3
+ * @private
+ */
+ Chart.pluginService = Chart.plugins;
+
+ /**
+ * Provided for backward compatibility, inheriting from Chart.PlugingBase has no
+ * effect, instead simply create/register plugins via plain JavaScript objects.
+ * @interface Chart.PluginBase
+ * @deprecated since version 2.5.0
+ * @todo remove at version 3
+ * @private
+ */
+ Chart.PluginBase = Element.extend({});
+};
+
+},{"25":25,"26":26,"45":45}],32:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+var Ticks = require(34);
+
+defaults._set('scale', {
+ display: true,
+ position: 'left',
+ offset: false,
+
+ // grid line settings
+ gridLines: {
+ display: true,
+ color: 'rgba(0, 0, 0, 0.1)',
+ lineWidth: 1,
+ drawBorder: true,
+ drawOnChartArea: true,
+ drawTicks: true,
+ tickMarkLength: 10,
+ zeroLineWidth: 1,
+ zeroLineColor: 'rgba(0,0,0,0.25)',
+ zeroLineBorderDash: [],
+ zeroLineBorderDashOffset: 0.0,
+ offsetGridLines: false,
+ borderDash: [],
+ borderDashOffset: 0.0
+ },
+
+ // scale label
+ scaleLabel: {
+ // display property
+ display: false,
+
+ // actual label
+ labelString: '',
+
+ // line height
+ lineHeight: 1.2,
+
+ // top/bottom padding
+ padding: {
+ top: 4,
+ bottom: 4
+ }
+ },
+
+ // label settings
+ ticks: {
+ beginAtZero: false,
+ minRotation: 0,
+ maxRotation: 50,
+ mirror: false,
+ padding: 0,
+ reverse: false,
+ display: true,
+ autoSkip: true,
+ autoSkipPadding: 0,
+ labelOffset: 0,
+ // We pass through arrays to be rendered as multiline labels, we convert Others to strings here.
+ callback: Ticks.formatters.values,
+ minor: {},
+ major: {}
+ }
+});
+
+function labelsFromTicks(ticks) {
+ var labels = [];
+ var i, ilen;
+
+ for (i = 0, ilen = ticks.length; i < ilen; ++i) {
+ labels.push(ticks[i].label);
+ }
+
+ return labels;
+}
+
+function getLineValue(scale, index, offsetGridLines) {
+ var lineValue = scale.getPixelForTick(index);
+
+ if (offsetGridLines) {
+ if (index === 0) {
+ lineValue -= (scale.getPixelForTick(1) - lineValue) / 2;
+ } else {
+ lineValue -= (lineValue - scale.getPixelForTick(index - 1)) / 2;
+ }
+ }
+ return lineValue;
+}
+
+module.exports = function(Chart) {
+
+ function computeTextSize(context, tick, font) {
+ return helpers.isArray(tick) ?
+ helpers.longestText(context, font, tick) :
+ context.measureText(tick).width;
+ }
+
+ function parseFontOptions(options) {
+ var valueOrDefault = helpers.valueOrDefault;
+ var globalDefaults = defaults.global;
+ var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
+ var style = valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle);
+ var family = valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily);
+
+ return {
+ size: size,
+ style: style,
+ family: family,
+ font: helpers.fontString(size, style, family)
+ };
+ }
+
+ function parseLineHeight(options) {
+ return helpers.options.toLineHeight(
+ helpers.valueOrDefault(options.lineHeight, 1.2),
+ helpers.valueOrDefault(options.fontSize, defaults.global.defaultFontSize));
+ }
+
+ Chart.Scale = Element.extend({
+ /**
+ * Get the padding needed for the scale
+ * @method getPadding
+ * @private
+ * @returns {Padding} the necessary padding
+ */
+ getPadding: function() {
+ var me = this;
+ return {
+ left: me.paddingLeft || 0,
+ top: me.paddingTop || 0,
+ right: me.paddingRight || 0,
+ bottom: me.paddingBottom || 0
+ };
+ },
+
+ /**
+ * Returns the scale tick objects ({label, major})
+ * @since 2.7
+ */
+ getTicks: function() {
+ return this._ticks;
+ },
+
+ // These methods are ordered by lifecyle. Utilities then follow.
+ // Any function defined here is inherited by all scale types.
+ // Any function can be extended by the scale type
+
+ mergeTicksOptions: function() {
+ var ticks = this.options.ticks;
+ if (ticks.minor === false) {
+ ticks.minor = {
+ display: false
+ };
+ }
+ if (ticks.major === false) {
+ ticks.major = {
+ display: false
+ };
+ }
+ for (var key in ticks) {
+ if (key !== 'major' && key !== 'minor') {
+ if (typeof ticks.minor[key] === 'undefined') {
+ ticks.minor[key] = ticks[key];
+ }
+ if (typeof ticks.major[key] === 'undefined') {
+ ticks.major[key] = ticks[key];
+ }
+ }
+ }
+ },
+ beforeUpdate: function() {
+ helpers.callback(this.options.beforeUpdate, [this]);
+ },
+ update: function(maxWidth, maxHeight, margins) {
+ var me = this;
+ var i, ilen, labels, label, ticks, tick;
+
+ // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
+ me.beforeUpdate();
+
+ // Absorb the master measurements
+ me.maxWidth = maxWidth;
+ me.maxHeight = maxHeight;
+ me.margins = helpers.extend({
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, margins);
+ me.longestTextCache = me.longestTextCache || {};
+
+ // Dimensions
+ me.beforeSetDimensions();
+ me.setDimensions();
+ me.afterSetDimensions();
+
+ // Data min/max
+ me.beforeDataLimits();
+ me.determineDataLimits();
+ me.afterDataLimits();
+
+ // Ticks - `this.ticks` is now DEPRECATED!
+ // Internal ticks are now stored as objects in the PRIVATE `this._ticks` member
+ // and must not be accessed directly from outside this class. `this.ticks` being
+ // around for long time and not marked as private, we can't change its structure
+ // without unexpected breaking changes. If you need to access the scale ticks,
+ // use scale.getTicks() instead.
+
+ me.beforeBuildTicks();
+
+ // New implementations should return an array of objects but for BACKWARD COMPAT,
+ // we still support no return (`this.ticks` internally set by calling this method).
+ ticks = me.buildTicks() || [];
+
+ me.afterBuildTicks();
+
+ me.beforeTickToLabelConversion();
+
+ // New implementations should return the formatted tick labels but for BACKWARD
+ // COMPAT, we still support no return (`this.ticks` internally changed by calling
+ // this method and supposed to contain only string values).
+ labels = me.convertTicksToLabels(ticks) || me.ticks;
+
+ me.afterTickToLabelConversion();
+
+ me.ticks = labels; // BACKWARD COMPATIBILITY
+
+ // IMPORTANT: from this point, we consider that `this.ticks` will NEVER change!
+
+ // BACKWARD COMPAT: synchronize `_ticks` with labels (so potentially `this.ticks`)
+ for (i = 0, ilen = labels.length; i < ilen; ++i) {
+ label = labels[i];
+ tick = ticks[i];
+ if (!tick) {
+ ticks.push(tick = {
+ label: label,
+ major: false
+ });
+ } else {
+ tick.label = label;
+ }
+ }
+
+ me._ticks = ticks;
+
+ // Tick Rotation
+ me.beforeCalculateTickRotation();
+ me.calculateTickRotation();
+ me.afterCalculateTickRotation();
+ // Fit
+ me.beforeFit();
+ me.fit();
+ me.afterFit();
+ //
+ me.afterUpdate();
+
+ return me.minSize;
+
+ },
+ afterUpdate: function() {
+ helpers.callback(this.options.afterUpdate, [this]);
+ },
+
+ //
+
+ beforeSetDimensions: function() {
+ helpers.callback(this.options.beforeSetDimensions, [this]);
+ },
+ setDimensions: function() {
+ var me = this;
+ // Set the unconstrained dimension before label rotation
+ if (me.isHorizontal()) {
+ // Reset position before calculating rotation
+ me.width = me.maxWidth;
+ me.left = 0;
+ me.right = me.width;
+ } else {
+ me.height = me.maxHeight;
+
+ // Reset position before calculating rotation
+ me.top = 0;
+ me.bottom = me.height;
+ }
+
+ // Reset padding
+ me.paddingLeft = 0;
+ me.paddingTop = 0;
+ me.paddingRight = 0;
+ me.paddingBottom = 0;
+ },
+ afterSetDimensions: function() {
+ helpers.callback(this.options.afterSetDimensions, [this]);
+ },
+
+ // Data limits
+ beforeDataLimits: function() {
+ helpers.callback(this.options.beforeDataLimits, [this]);
+ },
+ determineDataLimits: helpers.noop,
+ afterDataLimits: function() {
+ helpers.callback(this.options.afterDataLimits, [this]);
+ },
+
+ //
+ beforeBuildTicks: function() {
+ helpers.callback(this.options.beforeBuildTicks, [this]);
+ },
+ buildTicks: helpers.noop,
+ afterBuildTicks: function() {
+ helpers.callback(this.options.afterBuildTicks, [this]);
+ },
+
+ beforeTickToLabelConversion: function() {
+ helpers.callback(this.options.beforeTickToLabelConversion, [this]);
+ },
+ convertTicksToLabels: function() {
+ var me = this;
+ // Convert ticks to strings
+ var tickOpts = me.options.ticks;
+ me.ticks = me.ticks.map(tickOpts.userCallback || tickOpts.callback, this);
+ },
+ afterTickToLabelConversion: function() {
+ helpers.callback(this.options.afterTickToLabelConversion, [this]);
+ },
+
+ //
+
+ beforeCalculateTickRotation: function() {
+ helpers.callback(this.options.beforeCalculateTickRotation, [this]);
+ },
+ calculateTickRotation: function() {
+ var me = this;
+ var context = me.ctx;
+ var tickOpts = me.options.ticks;
+ var labels = labelsFromTicks(me._ticks);
+
+ // Get the width of each grid by calculating the difference
+ // between x offsets between 0 and 1.
+ var tickFont = parseFontOptions(tickOpts);
+ context.font = tickFont.font;
+
+ var labelRotation = tickOpts.minRotation || 0;
+
+ if (labels.length && me.options.display && me.isHorizontal()) {
+ var originalLabelWidth = helpers.longestText(context, tickFont.font, labels, me.longestTextCache);
+ var labelWidth = originalLabelWidth;
+ var cosRotation, sinRotation;
+
+ // Allow 3 pixels x2 padding either side for label readability
+ var tickWidth = me.getPixelForTick(1) - me.getPixelForTick(0) - 6;
+
+ // Max label rotation can be set or default to 90 - also act as a loop counter
+ while (labelWidth > tickWidth && labelRotation < tickOpts.maxRotation) {
+ var angleRadians = helpers.toRadians(labelRotation);
+ cosRotation = Math.cos(angleRadians);
+ sinRotation = Math.sin(angleRadians);
+
+ if (sinRotation * originalLabelWidth > me.maxHeight) {
+ // go back one step
+ labelRotation--;
+ break;
+ }
+
+ labelRotation++;
+ labelWidth = cosRotation * originalLabelWidth;
+ }
+ }
+
+ me.labelRotation = labelRotation;
+ },
+ afterCalculateTickRotation: function() {
+ helpers.callback(this.options.afterCalculateTickRotation, [this]);
+ },
+
+ //
+
+ beforeFit: function() {
+ helpers.callback(this.options.beforeFit, [this]);
+ },
+ fit: function() {
+ var me = this;
+ // Reset
+ var minSize = me.minSize = {
+ width: 0,
+ height: 0
+ };
+
+ var labels = labelsFromTicks(me._ticks);
+
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ var scaleLabelOpts = opts.scaleLabel;
+ var gridLineOpts = opts.gridLines;
+ var display = opts.display;
+ var isHorizontal = me.isHorizontal();
+
+ var tickFont = parseFontOptions(tickOpts);
+ var tickMarkLength = opts.gridLines.tickMarkLength;
+
+ // Width
+ if (isHorizontal) {
+ // subtract the margins to line up with the chartArea if we are a full width scale
+ minSize.width = me.isFullWidth() ? me.maxWidth - me.margins.left - me.margins.right : me.maxWidth;
+ } else {
+ minSize.width = display && gridLineOpts.drawTicks ? tickMarkLength : 0;
+ }
+
+ // height
+ if (isHorizontal) {
+ minSize.height = display && gridLineOpts.drawTicks ? tickMarkLength : 0;
+ } else {
+ minSize.height = me.maxHeight; // fill all the height
+ }
+
+ // Are we showing a title for the scale?
+ if (scaleLabelOpts.display && display) {
+ var scaleLabelLineHeight = parseLineHeight(scaleLabelOpts);
+ var scaleLabelPadding = helpers.options.toPadding(scaleLabelOpts.padding);
+ var deltaHeight = scaleLabelLineHeight + scaleLabelPadding.height;
+
+ if (isHorizontal) {
+ minSize.height += deltaHeight;
+ } else {
+ minSize.width += deltaHeight;
+ }
+ }
+
+ // Don't bother fitting the ticks if we are not showing them
+ if (tickOpts.display && display) {
+ var largestTextWidth = helpers.longestText(me.ctx, tickFont.font, labels, me.longestTextCache);
+ var tallestLabelHeightInLines = helpers.numberOfLabelLines(labels);
+ var lineSpace = tickFont.size * 0.5;
+ var tickPadding = me.options.ticks.padding;
+
+ if (isHorizontal) {
+ // A horizontal axis is more constrained by the height.
+ me.longestLabelWidth = largestTextWidth;
+
+ var angleRadians = helpers.toRadians(me.labelRotation);
+ var cosRotation = Math.cos(angleRadians);
+ var sinRotation = Math.sin(angleRadians);
+
+ // TODO - improve this calculation
+ var labelHeight = (sinRotation * largestTextWidth)
+ + (tickFont.size * tallestLabelHeightInLines)
+ + (lineSpace * (tallestLabelHeightInLines - 1))
+ + lineSpace; // padding
+
+ minSize.height = Math.min(me.maxHeight, minSize.height + labelHeight + tickPadding);
+
+ me.ctx.font = tickFont.font;
+ var firstLabelWidth = computeTextSize(me.ctx, labels[0], tickFont.font);
+ var lastLabelWidth = computeTextSize(me.ctx, labels[labels.length - 1], tickFont.font);
+
+ // Ensure that our ticks are always inside the canvas. When rotated, ticks are right aligned
+ // which means that the right padding is dominated by the font height
+ if (me.labelRotation !== 0) {
+ me.paddingLeft = opts.position === 'bottom' ? (cosRotation * firstLabelWidth) + 3 : (cosRotation * lineSpace) + 3; // add 3 px to move away from canvas edges
+ me.paddingRight = opts.position === 'bottom' ? (cosRotation * lineSpace) + 3 : (cosRotation * lastLabelWidth) + 3;
+ } else {
+ me.paddingLeft = firstLabelWidth / 2 + 3; // add 3 px to move away from canvas edges
+ me.paddingRight = lastLabelWidth / 2 + 3;
+ }
+ } else {
+ // A vertical axis is more constrained by the width. Labels are the
+ // dominant factor here, so get that length first and account for padding
+ if (tickOpts.mirror) {
+ largestTextWidth = 0;
+ } else {
+ // use lineSpace for consistency with horizontal axis
+ // tickPadding is not implemented for horizontal
+ largestTextWidth += tickPadding + lineSpace;
+ }
+
+ minSize.width = Math.min(me.maxWidth, minSize.width + largestTextWidth);
+
+ me.paddingTop = tickFont.size / 2;
+ me.paddingBottom = tickFont.size / 2;
+ }
+ }
+
+ me.handleMargins();
+
+ me.width = minSize.width;
+ me.height = minSize.height;
+ },
+
+ /**
+ * Handle margins and padding interactions
+ * @private
+ */
+ handleMargins: function() {
+ var me = this;
+ if (me.margins) {
+ me.paddingLeft = Math.max(me.paddingLeft - me.margins.left, 0);
+ me.paddingTop = Math.max(me.paddingTop - me.margins.top, 0);
+ me.paddingRight = Math.max(me.paddingRight - me.margins.right, 0);
+ me.paddingBottom = Math.max(me.paddingBottom - me.margins.bottom, 0);
+ }
+ },
+
+ afterFit: function() {
+ helpers.callback(this.options.afterFit, [this]);
+ },
+
+ // Shared Methods
+ isHorizontal: function() {
+ return this.options.position === 'top' || this.options.position === 'bottom';
+ },
+ isFullWidth: function() {
+ return (this.options.fullWidth);
+ },
+
+ // Get the correct value. NaN bad inputs, If the value type is object get the x or y based on whether we are horizontal or not
+ getRightValue: function(rawValue) {
+ // Null and undefined values first
+ if (helpers.isNullOrUndef(rawValue)) {
+ return NaN;
+ }
+ // isNaN(object) returns true, so make sure NaN is checking for a number; Discard Infinite values
+ if (typeof rawValue === 'number' && !isFinite(rawValue)) {
+ return NaN;
+ }
+ // If it is in fact an object, dive in one more level
+ if (rawValue) {
+ if (this.isHorizontal()) {
+ if (rawValue.x !== undefined) {
+ return this.getRightValue(rawValue.x);
+ }
+ } else if (rawValue.y !== undefined) {
+ return this.getRightValue(rawValue.y);
+ }
+ }
+
+ // Value is good, return it
+ return rawValue;
+ },
+
+ /**
+ * Used to get the value to display in the tooltip for the data at the given index
+ * @param index
+ * @param datasetIndex
+ */
+ getLabelForIndex: helpers.noop,
+
+ /**
+ * Returns the location of the given data point. Value can either be an index or a numerical value
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ * @param value
+ * @param index
+ * @param datasetIndex
+ */
+ getPixelForValue: helpers.noop,
+
+ /**
+ * Used to get the data value from a given pixel. This is the inverse of getPixelForValue
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ * @param pixel
+ */
+ getValueForPixel: helpers.noop,
+
+ /**
+ * Returns the location of the tick at the given index
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
+ getPixelForTick: function(index) {
+ var me = this;
+ var offset = me.options.offset;
+ if (me.isHorizontal()) {
+ var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
+ var tickWidth = innerWidth / Math.max((me._ticks.length - (offset ? 0 : 1)), 1);
+ var pixel = (tickWidth * index) + me.paddingLeft;
+
+ if (offset) {
+ pixel += tickWidth / 2;
+ }
+
+ var finalVal = me.left + Math.round(pixel);
+ finalVal += me.isFullWidth() ? me.margins.left : 0;
+ return finalVal;
+ }
+ var innerHeight = me.height - (me.paddingTop + me.paddingBottom);
+ return me.top + (index * (innerHeight / (me._ticks.length - 1)));
+ },
+
+ /**
+ * Utility for getting the pixel location of a percentage of scale
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
+ getPixelForDecimal: function(decimal) {
+ var me = this;
+ if (me.isHorizontal()) {
+ var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
+ var valueOffset = (innerWidth * decimal) + me.paddingLeft;
+
+ var finalVal = me.left + Math.round(valueOffset);
+ finalVal += me.isFullWidth() ? me.margins.left : 0;
+ return finalVal;
+ }
+ return me.top + (decimal * me.height);
+ },
+
+ /**
+ * Returns the pixel for the minimum chart value
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
+ getBasePixel: function() {
+ return this.getPixelForValue(this.getBaseValue());
+ },
+
+ getBaseValue: function() {
+ var me = this;
+ var min = me.min;
+ var max = me.max;
+
+ return me.beginAtZero ? 0 :
+ min < 0 && max < 0 ? max :
+ min > 0 && max > 0 ? min :
+ 0;
+ },
+
+ /**
+ * Returns a subset of ticks to be plotted to avoid overlapping labels.
+ * @private
+ */
+ _autoSkip: function(ticks) {
+ var skipRatio;
+ var me = this;
+ var isHorizontal = me.isHorizontal();
+ var optionTicks = me.options.ticks.minor;
+ var tickCount = ticks.length;
+ var labelRotationRadians = helpers.toRadians(me.labelRotation);
+ var cosRotation = Math.cos(labelRotationRadians);
+ var longestRotatedLabel = me.longestLabelWidth * cosRotation;
+ var result = [];
+ var i, tick, shouldSkip;
+
+ // figure out the maximum number of gridlines to show
+ var maxTicks;
+ if (optionTicks.maxTicksLimit) {
+ maxTicks = optionTicks.maxTicksLimit;
+ }
+
+ if (isHorizontal) {
+ skipRatio = false;
+
+ if ((longestRotatedLabel + optionTicks.autoSkipPadding) * tickCount > (me.width - (me.paddingLeft + me.paddingRight))) {
+ skipRatio = 1 + Math.floor(((longestRotatedLabel + optionTicks.autoSkipPadding) * tickCount) / (me.width - (me.paddingLeft + me.paddingRight)));
+ }
+
+ // if they defined a max number of optionTicks,
+ // increase skipRatio until that number is met
+ if (maxTicks && tickCount > maxTicks) {
+ skipRatio = Math.max(skipRatio, Math.floor(tickCount / maxTicks));
+ }
+ }
+
+ for (i = 0; i < tickCount; i++) {
+ tick = ticks[i];
+
+ // Since we always show the last tick,we need may need to hide the last shown one before
+ shouldSkip = (skipRatio > 1 && i % skipRatio > 0) || (i % skipRatio === 0 && i + skipRatio >= tickCount);
+ if (shouldSkip && i !== tickCount - 1) {
+ // leave tick in place but make sure it's not displayed (#4635)
+ delete tick.label;
+ }
+ result.push(tick);
+ }
+ return result;
+ },
+
+ // Actually draw the scale on the canvas
+ // @param {rectangle} chartArea : the area of the chart to draw full grid lines on
+ draw: function(chartArea) {
+ var me = this;
+ var options = me.options;
+ if (!options.display) {
+ return;
+ }
+
+ var context = me.ctx;
+ var globalDefaults = defaults.global;
+ var optionTicks = options.ticks.minor;
+ var optionMajorTicks = options.ticks.major || optionTicks;
+ var gridLines = options.gridLines;
+ var scaleLabel = options.scaleLabel;
+
+ var isRotated = me.labelRotation !== 0;
+ var isHorizontal = me.isHorizontal();
+
+ var ticks = optionTicks.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
+ var tickFontColor = helpers.valueOrDefault(optionTicks.fontColor, globalDefaults.defaultFontColor);
+ var tickFont = parseFontOptions(optionTicks);
+ var majorTickFontColor = helpers.valueOrDefault(optionMajorTicks.fontColor, globalDefaults.defaultFontColor);
+ var majorTickFont = parseFontOptions(optionMajorTicks);
+
+ var tl = gridLines.drawTicks ? gridLines.tickMarkLength : 0;
+
+ var scaleLabelFontColor = helpers.valueOrDefault(scaleLabel.fontColor, globalDefaults.defaultFontColor);
+ var scaleLabelFont = parseFontOptions(scaleLabel);
+ var scaleLabelPadding = helpers.options.toPadding(scaleLabel.padding);
+ var labelRotationRadians = helpers.toRadians(me.labelRotation);
+
+ var itemsToDraw = [];
+
+ var xTickStart = options.position === 'right' ? me.left : me.right - tl;
+ var xTickEnd = options.position === 'right' ? me.left + tl : me.right;
+ var yTickStart = options.position === 'bottom' ? me.top : me.bottom - tl;
+ var yTickEnd = options.position === 'bottom' ? me.top + tl : me.bottom;
+
+ helpers.each(ticks, function(tick, index) {
+ // autoskipper skipped this tick (#4635)
+ if (helpers.isNullOrUndef(tick.label)) {
+ return;
+ }
+
+ var label = tick.label;
+ var lineWidth, lineColor, borderDash, borderDashOffset;
+ if (index === me.zeroLineIndex && options.offset === gridLines.offsetGridLines) {
+ // Draw the first index specially
+ lineWidth = gridLines.zeroLineWidth;
+ lineColor = gridLines.zeroLineColor;
+ borderDash = gridLines.zeroLineBorderDash;
+ borderDashOffset = gridLines.zeroLineBorderDashOffset;
+ } else {
+ lineWidth = helpers.valueAtIndexOrDefault(gridLines.lineWidth, index);
+ lineColor = helpers.valueAtIndexOrDefault(gridLines.color, index);
+ borderDash = helpers.valueOrDefault(gridLines.borderDash, globalDefaults.borderDash);
+ borderDashOffset = helpers.valueOrDefault(gridLines.borderDashOffset, globalDefaults.borderDashOffset);
+ }
+
+ // Common properties
+ var tx1, ty1, tx2, ty2, x1, y1, x2, y2, labelX, labelY;
+ var textAlign = 'middle';
+ var textBaseline = 'middle';
+ var tickPadding = optionTicks.padding;
+
+ if (isHorizontal) {
+ var labelYOffset = tl + tickPadding;
+
+ if (options.position === 'bottom') {
+ // bottom
+ textBaseline = !isRotated ? 'top' : 'middle';
+ textAlign = !isRotated ? 'center' : 'right';
+ labelY = me.top + labelYOffset;
+ } else {
+ // top
+ textBaseline = !isRotated ? 'bottom' : 'middle';
+ textAlign = !isRotated ? 'center' : 'left';
+ labelY = me.bottom - labelYOffset;
+ }
+
+ var xLineValue = getLineValue(me, index, gridLines.offsetGridLines && ticks.length > 1);
+ if (xLineValue < me.left) {
+ lineColor = 'rgba(0,0,0,0)';
+ }
+ xLineValue += helpers.aliasPixel(lineWidth);
+
+ labelX = me.getPixelForTick(index) + optionTicks.labelOffset; // x values for optionTicks (need to consider offsetLabel option)
+
+ tx1 = tx2 = x1 = x2 = xLineValue;
+ ty1 = yTickStart;
+ ty2 = yTickEnd;
+ y1 = chartArea.top;
+ y2 = chartArea.bottom;
+ } else {
+ var isLeft = options.position === 'left';
+ var labelXOffset;
+
+ if (optionTicks.mirror) {
+ textAlign = isLeft ? 'left' : 'right';
+ labelXOffset = tickPadding;
+ } else {
+ textAlign = isLeft ? 'right' : 'left';
+ labelXOffset = tl + tickPadding;
+ }
+
+ labelX = isLeft ? me.right - labelXOffset : me.left + labelXOffset;
+
+ var yLineValue = getLineValue(me, index, gridLines.offsetGridLines && ticks.length > 1);
+ if (yLineValue < me.top) {
+ lineColor = 'rgba(0,0,0,0)';
+ }
+ yLineValue += helpers.aliasPixel(lineWidth);
+
+ labelY = me.getPixelForTick(index) + optionTicks.labelOffset;
+
+ tx1 = xTickStart;
+ tx2 = xTickEnd;
+ x1 = chartArea.left;
+ x2 = chartArea.right;
+ ty1 = ty2 = y1 = y2 = yLineValue;
+ }
+
+ itemsToDraw.push({
+ tx1: tx1,
+ ty1: ty1,
+ tx2: tx2,
+ ty2: ty2,
+ x1: x1,
+ y1: y1,
+ x2: x2,
+ y2: y2,
+ labelX: labelX,
+ labelY: labelY,
+ glWidth: lineWidth,
+ glColor: lineColor,
+ glBorderDash: borderDash,
+ glBorderDashOffset: borderDashOffset,
+ rotation: -1 * labelRotationRadians,
+ label: label,
+ major: tick.major,
+ textBaseline: textBaseline,
+ textAlign: textAlign
+ });
+ });
+
+ // Draw all of the tick labels, tick marks, and grid lines at the correct places
+ helpers.each(itemsToDraw, function(itemToDraw) {
+ if (gridLines.display) {
+ context.save();
+ context.lineWidth = itemToDraw.glWidth;
+ context.strokeStyle = itemToDraw.glColor;
+ if (context.setLineDash) {
+ context.setLineDash(itemToDraw.glBorderDash);
+ context.lineDashOffset = itemToDraw.glBorderDashOffset;
+ }
+
+ context.beginPath();
+
+ if (gridLines.drawTicks) {
+ context.moveTo(itemToDraw.tx1, itemToDraw.ty1);
+ context.lineTo(itemToDraw.tx2, itemToDraw.ty2);
+ }
+
+ if (gridLines.drawOnChartArea) {
+ context.moveTo(itemToDraw.x1, itemToDraw.y1);
+ context.lineTo(itemToDraw.x2, itemToDraw.y2);
+ }
+
+ context.stroke();
+ context.restore();
+ }
+
+ if (optionTicks.display) {
+ // Make sure we draw text in the correct color and font
+ context.save();
+ context.translate(itemToDraw.labelX, itemToDraw.labelY);
+ context.rotate(itemToDraw.rotation);
+ context.font = itemToDraw.major ? majorTickFont.font : tickFont.font;
+ context.fillStyle = itemToDraw.major ? majorTickFontColor : tickFontColor;
+ context.textBaseline = itemToDraw.textBaseline;
+ context.textAlign = itemToDraw.textAlign;
+
+ var label = itemToDraw.label;
+ if (helpers.isArray(label)) {
+ for (var i = 0, y = 0; i < label.length; ++i) {
+ // We just make sure the multiline element is a string here..
+ context.fillText('' + label[i], 0, y);
+ // apply same lineSpacing as calculated @ L#320
+ y += (tickFont.size * 1.5);
+ }
+ } else {
+ context.fillText(label, 0, 0);
+ }
+ context.restore();
+ }
+ });
+
+ if (scaleLabel.display) {
+ // Draw the scale label
+ var scaleLabelX;
+ var scaleLabelY;
+ var rotation = 0;
+ var halfLineHeight = parseLineHeight(scaleLabel) / 2;
+
+ if (isHorizontal) {
+ scaleLabelX = me.left + ((me.right - me.left) / 2); // midpoint of the width
+ scaleLabelY = options.position === 'bottom'
+ ? me.bottom - halfLineHeight - scaleLabelPadding.bottom
+ : me.top + halfLineHeight + scaleLabelPadding.top;
+ } else {
+ var isLeft = options.position === 'left';
+ scaleLabelX = isLeft
+ ? me.left + halfLineHeight + scaleLabelPadding.top
+ : me.right - halfLineHeight - scaleLabelPadding.top;
+ scaleLabelY = me.top + ((me.bottom - me.top) / 2);
+ rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;
+ }
+
+ context.save();
+ context.translate(scaleLabelX, scaleLabelY);
+ context.rotate(rotation);
+ context.textAlign = 'center';
+ context.textBaseline = 'middle';
+ context.fillStyle = scaleLabelFontColor; // render in correct colour
+ context.font = scaleLabelFont.font;
+ context.fillText(scaleLabel.labelString, 0, 0);
+ context.restore();
+ }
+
+ if (gridLines.drawBorder) {
+ // Draw the line at the edge of the axis
+ context.lineWidth = helpers.valueAtIndexOrDefault(gridLines.lineWidth, 0);
+ context.strokeStyle = helpers.valueAtIndexOrDefault(gridLines.color, 0);
+ var x1 = me.left;
+ var x2 = me.right;
+ var y1 = me.top;
+ var y2 = me.bottom;
+
+ var aliasPixel = helpers.aliasPixel(context.lineWidth);
+ if (isHorizontal) {
+ y1 = y2 = options.position === 'top' ? me.bottom : me.top;
+ y1 += aliasPixel;
+ y2 += aliasPixel;
+ } else {
+ x1 = x2 = options.position === 'left' ? me.right : me.left;
+ x1 += aliasPixel;
+ x2 += aliasPixel;
+ }
+
+ context.beginPath();
+ context.moveTo(x1, y1);
+ context.lineTo(x2, y2);
+ context.stroke();
+ }
+ }
+ });
+};
+
+},{"25":25,"26":26,"34":34,"45":45}],33:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+
+module.exports = function(Chart) {
+
+ Chart.scaleService = {
+ // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then
+ // use the new chart options to grab the correct scale
+ constructors: {},
+ // Use a registration function so that we can move to an ES6 map when we no longer need to support
+ // old browsers
+
+ // Scale config defaults
+ defaults: {},
+ registerScaleType: function(type, scaleConstructor, scaleDefaults) {
+ this.constructors[type] = scaleConstructor;
+ this.defaults[type] = helpers.clone(scaleDefaults);
+ },
+ getScaleConstructor: function(type) {
+ return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined;
+ },
+ getScaleDefaults: function(type) {
+ // Return the scale defaults merged with the global settings so that we always use the latest ones
+ return this.defaults.hasOwnProperty(type) ? helpers.merge({}, [defaults.scale, this.defaults[type]]) : {};
+ },
+ updateScaleDefaults: function(type, additions) {
+ var me = this;
+ if (me.defaults.hasOwnProperty(type)) {
+ me.defaults[type] = helpers.extend(me.defaults[type], additions);
+ }
+ },
+ addScalesToLayout: function(chart) {
+ // Adds each scale to the chart.boxes array to be sized accordingly
+ helpers.each(chart.scales, function(scale) {
+ // Set ILayoutItem parameters for backwards compatibility
+ scale.fullWidth = scale.options.fullWidth;
+ scale.position = scale.options.position;
+ scale.weight = scale.options.weight;
+ Chart.layoutService.addBox(chart, scale);
+ });
+ }
+ };
+};
+
+},{"25":25,"45":45}],34:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+
+/**
+ * Namespace to hold static tick generation functions
+ * @namespace Chart.Ticks
+ */
+module.exports = {
+ /**
+ * Namespace to hold generators for different types of ticks
+ * @namespace Chart.Ticks.generators
+ */
+ generators: {
+ /**
+ * Interface for the options provided to the numeric tick generator
+ * @interface INumericTickGenerationOptions
+ */
+ /**
+ * The maximum number of ticks to display
+ * @name INumericTickGenerationOptions#maxTicks
+ * @type Number
+ */
+ /**
+ * The distance between each tick.
+ * @name INumericTickGenerationOptions#stepSize
+ * @type Number
+ * @optional
+ */
+ /**
+ * Forced minimum for the ticks. If not specified, the minimum of the data range is used to calculate the tick minimum
+ * @name INumericTickGenerationOptions#min
+ * @type Number
+ * @optional
+ */
+ /**
+ * The maximum value of the ticks. If not specified, the maximum of the data range is used to calculate the tick maximum
+ * @name INumericTickGenerationOptions#max
+ * @type Number
+ * @optional
+ */
+
+ /**
+ * Generate a set of linear ticks
+ * @method Chart.Ticks.generators.linear
+ * @param generationOptions {INumericTickGenerationOptions} the options used to generate the ticks
+ * @param dataRange {IRange} the range of the data
+ * @returns {Array<Number>} array of tick values
+ */
+ linear: function(generationOptions, dataRange) {
+ var ticks = [];
+ // To get a "nice" value for the tick spacing, we will use the appropriately named
+ // "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
+ // for details.
+
+ var spacing;
+ if (generationOptions.stepSize && generationOptions.stepSize > 0) {
+ spacing = generationOptions.stepSize;
+ } else {
+ var niceRange = helpers.niceNum(dataRange.max - dataRange.min, false);
+ spacing = helpers.niceNum(niceRange / (generationOptions.maxTicks - 1), true);
+ }
+ var niceMin = Math.floor(dataRange.min / spacing) * spacing;
+ var niceMax = Math.ceil(dataRange.max / spacing) * spacing;
+
+ // If min, max and stepSize is set and they make an evenly spaced scale use it.
+ if (generationOptions.min && generationOptions.max && generationOptions.stepSize) {
+ // If very close to our whole number, use it.
+ if (helpers.almostWhole((generationOptions.max - generationOptions.min) / generationOptions.stepSize, spacing / 1000)) {
+ niceMin = generationOptions.min;
+ niceMax = generationOptions.max;
+ }
+ }
+
+ var numSpaces = (niceMax - niceMin) / spacing;
+ // If very close to our rounded value, use it.
+ if (helpers.almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) {
+ numSpaces = Math.round(numSpaces);
+ } else {
+ numSpaces = Math.ceil(numSpaces);
+ }
+
+ // Put the values into the ticks array
+ ticks.push(generationOptions.min !== undefined ? generationOptions.min : niceMin);
+ for (var j = 1; j < numSpaces; ++j) {
+ ticks.push(niceMin + (j * spacing));
+ }
+ ticks.push(generationOptions.max !== undefined ? generationOptions.max : niceMax);
+
+ return ticks;
+ },
+
+ /**
+ * Generate a set of logarithmic ticks
+ * @method Chart.Ticks.generators.logarithmic
+ * @param generationOptions {INumericTickGenerationOptions} the options used to generate the ticks
+ * @param dataRange {IRange} the range of the data
+ * @returns {Array<Number>} array of tick values
+ */
+ logarithmic: function(generationOptions, dataRange) {
+ var ticks = [];
+ var valueOrDefault = helpers.valueOrDefault;
+
+ // Figure out what the max number of ticks we can support it is based on the size of
+ // the axis area. For now, we say that the minimum tick spacing in pixels must be 50
+ // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
+ // the graph
+ var tickVal = valueOrDefault(generationOptions.min, Math.pow(10, Math.floor(helpers.log10(dataRange.min))));
+
+ var endExp = Math.floor(helpers.log10(dataRange.max));
+ var endSignificand = Math.ceil(dataRange.max / Math.pow(10, endExp));
+ var exp, significand;
+
+ if (tickVal === 0) {
+ exp = Math.floor(helpers.log10(dataRange.minNotZero));
+ significand = Math.floor(dataRange.minNotZero / Math.pow(10, exp));
+
+ ticks.push(tickVal);
+ tickVal = significand * Math.pow(10, exp);
+ } else {
+ exp = Math.floor(helpers.log10(tickVal));
+ significand = Math.floor(tickVal / Math.pow(10, exp));
+ }
+
+ do {
+ ticks.push(tickVal);
+
+ ++significand;
+ if (significand === 10) {
+ significand = 1;
+ ++exp;
+ }
+
+ tickVal = significand * Math.pow(10, exp);
+ } while (exp < endExp || (exp === endExp && significand < endSignificand));
+
+ var lastTick = valueOrDefault(generationOptions.max, tickVal);
+ ticks.push(lastTick);
+
+ return ticks;
+ }
+ },
+
+ /**
+ * Namespace to hold formatters for different types of ticks
+ * @namespace Chart.Ticks.formatters
+ */
+ formatters: {
+ /**
+ * Formatter for value labels
+ * @method Chart.Ticks.formatters.values
+ * @param value the value to display
+ * @return {String|Array} the label to display
+ */
+ values: function(value) {
+ return helpers.isArray(value) ? value : '' + value;
+ },
+
+ /**
+ * Formatter for linear numeric ticks
+ * @method Chart.Ticks.formatters.linear
+ * @param tickValue {Number} the value to be formatted
+ * @param index {Number} the position of the tickValue parameter in the ticks array
+ * @param ticks {Array<Number>} the list of ticks being converted
+ * @return {String} string representation of the tickValue parameter
+ */
+ linear: function(tickValue, index, ticks) {
+ // If we have lots of ticks, don't use the ones
+ var delta = ticks.length > 3 ? ticks[2] - ticks[1] : ticks[1] - ticks[0];
+
+ // If we have a number like 2.5 as the delta, figure out how many decimal places we need
+ if (Math.abs(delta) > 1) {
+ if (tickValue !== Math.floor(tickValue)) {
+ // not an integer
+ delta = tickValue - Math.floor(tickValue);
+ }
+ }
+
+ var logDelta = helpers.log10(Math.abs(delta));
+ var tickString = '';
+
+ if (tickValue !== 0) {
+ var numDecimal = -1 * Math.floor(logDelta);
+ numDecimal = Math.max(Math.min(numDecimal, 20), 0); // toFixed has a max of 20 decimal places
+ tickString = tickValue.toFixed(numDecimal);
+ } else {
+ tickString = '0'; // never show decimal places for 0
+ }
+
+ return tickString;
+ },
+
+ logarithmic: function(tickValue, index, ticks) {
+ var remain = tickValue / (Math.pow(10, Math.floor(helpers.log10(tickValue))));
+
+ if (tickValue === 0) {
+ return '0';
+ } else if (remain === 1 || remain === 2 || remain === 5 || index === 0 || index === ticks.length - 1) {
+ return tickValue.toExponential();
+ }
+ return '';
+ }
+ }
+};
+
+},{"45":45}],35:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ tooltips: {
+ enabled: true,
+ custom: null,
+ mode: 'nearest',
+ position: 'average',
+ intersect: true,
+ backgroundColor: 'rgba(0,0,0,0.8)',
+ titleFontStyle: 'bold',
+ titleSpacing: 2,
+ titleMarginBottom: 6,
+ titleFontColor: '#fff',
+ titleAlign: 'left',
+ bodySpacing: 2,
+ bodyFontColor: '#fff',
+ bodyAlign: 'left',
+ footerFontStyle: 'bold',
+ footerSpacing: 2,
+ footerMarginTop: 6,
+ footerFontColor: '#fff',
+ footerAlign: 'left',
+ yPadding: 6,
+ xPadding: 6,
+ caretPadding: 2,
+ caretSize: 5,
+ cornerRadius: 6,
+ multiKeyBackground: '#fff',
+ displayColors: true,
+ borderColor: 'rgba(0,0,0,0)',
+ borderWidth: 0,
+ callbacks: {
+ // Args are: (tooltipItems, data)
+ beforeTitle: helpers.noop,
+ title: function(tooltipItems, data) {
+ // Pick first xLabel for now
+ var title = '';
+ var labels = data.labels;
+ var labelCount = labels ? labels.length : 0;
+
+ if (tooltipItems.length > 0) {
+ var item = tooltipItems[0];
+
+ if (item.xLabel) {
+ title = item.xLabel;
+ } else if (labelCount > 0 && item.index < labelCount) {
+ title = labels[item.index];
+ }
+ }
+
+ return title;
+ },
+ afterTitle: helpers.noop,
+
+ // Args are: (tooltipItems, data)
+ beforeBody: helpers.noop,
+
+ // Args are: (tooltipItem, data)
+ beforeLabel: helpers.noop,
+ label: function(tooltipItem, data) {
+ var label = data.datasets[tooltipItem.datasetIndex].label || '';
+
+ if (label) {
+ label += ': ';
+ }
+ label += tooltipItem.yLabel;
+ return label;
+ },
+ labelColor: function(tooltipItem, chart) {
+ var meta = chart.getDatasetMeta(tooltipItem.datasetIndex);
+ var activeElement = meta.data[tooltipItem.index];
+ var view = activeElement._view;
+ return {
+ borderColor: view.borderColor,
+ backgroundColor: view.backgroundColor
+ };
+ },
+ labelTextColor: function() {
+ return this._options.bodyFontColor;
+ },
+ afterLabel: helpers.noop,
+
+ // Args are: (tooltipItems, data)
+ afterBody: helpers.noop,
+
+ // Args are: (tooltipItems, data)
+ beforeFooter: helpers.noop,
+ footer: helpers.noop,
+ afterFooter: helpers.noop
+ }
+ }
+});
+
+module.exports = function(Chart) {
+
+ /**
+ * Helper method to merge the opacity into a color
+ */
+ function mergeOpacity(colorString, opacity) {
+ var color = helpers.color(colorString);
+ return color.alpha(opacity * color.alpha()).rgbaString();
+ }
+
+ // Helper to push or concat based on if the 2nd parameter is an array or not
+ function pushOrConcat(base, toPush) {
+ if (toPush) {
+ if (helpers.isArray(toPush)) {
+ // base = base.concat(toPush);
+ Array.prototype.push.apply(base, toPush);
+ } else {
+ base.push(toPush);
+ }
+ }
+
+ return base;
+ }
+
+ // Private helper to create a tooltip item model
+ // @param element : the chart element (point, arc, bar) to create the tooltip item for
+ // @return : new tooltip item
+ function createTooltipItem(element) {
+ var xScale = element._xScale;
+ var yScale = element._yScale || element._scale; // handle radar || polarArea charts
+ var index = element._index;
+ var datasetIndex = element._datasetIndex;
+
+ return {
+ xLabel: xScale ? xScale.getLabelForIndex(index, datasetIndex) : '',
+ yLabel: yScale ? yScale.getLabelForIndex(index, datasetIndex) : '',
+ index: index,
+ datasetIndex: datasetIndex,
+ x: element._model.x,
+ y: element._model.y
+ };
+ }
+
+ /**
+ * Helper to get the reset model for the tooltip
+ * @param tooltipOpts {Object} the tooltip options
+ */
+ function getBaseModel(tooltipOpts) {
+ var globalDefaults = defaults.global;
+ var valueOrDefault = helpers.valueOrDefault;
+
+ return {
+ // Positioning
+ xPadding: tooltipOpts.xPadding,
+ yPadding: tooltipOpts.yPadding,
+ xAlign: tooltipOpts.xAlign,
+ yAlign: tooltipOpts.yAlign,
+
+ // Body
+ bodyFontColor: tooltipOpts.bodyFontColor,
+ _bodyFontFamily: valueOrDefault(tooltipOpts.bodyFontFamily, globalDefaults.defaultFontFamily),
+ _bodyFontStyle: valueOrDefault(tooltipOpts.bodyFontStyle, globalDefaults.defaultFontStyle),
+ _bodyAlign: tooltipOpts.bodyAlign,
+ bodyFontSize: valueOrDefault(tooltipOpts.bodyFontSize, globalDefaults.defaultFontSize),
+ bodySpacing: tooltipOpts.bodySpacing,
+
+ // Title
+ titleFontColor: tooltipOpts.titleFontColor,
+ _titleFontFamily: valueOrDefault(tooltipOpts.titleFontFamily, globalDefaults.defaultFontFamily),
+ _titleFontStyle: valueOrDefault(tooltipOpts.titleFontStyle, globalDefaults.defaultFontStyle),
+ titleFontSize: valueOrDefault(tooltipOpts.titleFontSize, globalDefaults.defaultFontSize),
+ _titleAlign: tooltipOpts.titleAlign,
+ titleSpacing: tooltipOpts.titleSpacing,
+ titleMarginBottom: tooltipOpts.titleMarginBottom,
+
+ // Footer
+ footerFontColor: tooltipOpts.footerFontColor,
+ _footerFontFamily: valueOrDefault(tooltipOpts.footerFontFamily, globalDefaults.defaultFontFamily),
+ _footerFontStyle: valueOrDefault(tooltipOpts.footerFontStyle, globalDefaults.defaultFontStyle),
+ footerFontSize: valueOrDefault(tooltipOpts.footerFontSize, globalDefaults.defaultFontSize),
+ _footerAlign: tooltipOpts.footerAlign,
+ footerSpacing: tooltipOpts.footerSpacing,
+ footerMarginTop: tooltipOpts.footerMarginTop,
+
+ // Appearance
+ caretSize: tooltipOpts.caretSize,
+ cornerRadius: tooltipOpts.cornerRadius,
+ backgroundColor: tooltipOpts.backgroundColor,
+ opacity: 0,
+ legendColorBackground: tooltipOpts.multiKeyBackground,
+ displayColors: tooltipOpts.displayColors,
+ borderColor: tooltipOpts.borderColor,
+ borderWidth: tooltipOpts.borderWidth
+ };
+ }
+
+ /**
+ * Get the size of the tooltip
+ */
+ function getTooltipSize(tooltip, model) {
+ var ctx = tooltip._chart.ctx;
+
+ var height = model.yPadding * 2; // Tooltip Padding
+ var width = 0;
+
+ // Count of all lines in the body
+ var body = model.body;
+ var combinedBodyLength = body.reduce(function(count, bodyItem) {
+ return count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length;
+ }, 0);
+ combinedBodyLength += model.beforeBody.length + model.afterBody.length;
+
+ var titleLineCount = model.title.length;
+ var footerLineCount = model.footer.length;
+ var titleFontSize = model.titleFontSize;
+ var bodyFontSize = model.bodyFontSize;
+ var footerFontSize = model.footerFontSize;
+
+ height += titleLineCount * titleFontSize; // Title Lines
+ height += titleLineCount ? (titleLineCount - 1) * model.titleSpacing : 0; // Title Line Spacing
+ height += titleLineCount ? model.titleMarginBottom : 0; // Title's bottom Margin
+ height += combinedBodyLength * bodyFontSize; // Body Lines
+ height += combinedBodyLength ? (combinedBodyLength - 1) * model.bodySpacing : 0; // Body Line Spacing
+ height += footerLineCount ? model.footerMarginTop : 0; // Footer Margin
+ height += footerLineCount * (footerFontSize); // Footer Lines
+ height += footerLineCount ? (footerLineCount - 1) * model.footerSpacing : 0; // Footer Line Spacing
+
+ // Title width
+ var widthPadding = 0;
+ var maxLineWidth = function(line) {
+ width = Math.max(width, ctx.measureText(line).width + widthPadding);
+ };
+
+ ctx.font = helpers.fontString(titleFontSize, model._titleFontStyle, model._titleFontFamily);
+ helpers.each(model.title, maxLineWidth);
+
+ // Body width
+ ctx.font = helpers.fontString(bodyFontSize, model._bodyFontStyle, model._bodyFontFamily);
+ helpers.each(model.beforeBody.concat(model.afterBody), maxLineWidth);
+
+ // Body lines may include some extra width due to the color box
+ widthPadding = model.displayColors ? (bodyFontSize + 2) : 0;
+ helpers.each(body, function(bodyItem) {
+ helpers.each(bodyItem.before, maxLineWidth);
+ helpers.each(bodyItem.lines, maxLineWidth);
+ helpers.each(bodyItem.after, maxLineWidth);
+ });
+
+ // Reset back to 0
+ widthPadding = 0;
+
+ // Footer width
+ ctx.font = helpers.fontString(footerFontSize, model._footerFontStyle, model._footerFontFamily);
+ helpers.each(model.footer, maxLineWidth);
+
+ // Add padding
+ width += 2 * model.xPadding;
+
+ return {
+ width: width,
+ height: height
+ };
+ }
+
+ /**
+ * Helper to get the alignment of a tooltip given the size
+ */
+ function determineAlignment(tooltip, size) {
+ var model = tooltip._model;
+ var chart = tooltip._chart;
+ var chartArea = tooltip._chart.chartArea;
+ var xAlign = 'center';
+ var yAlign = 'center';
+
+ if (model.y < size.height) {
+ yAlign = 'top';
+ } else if (model.y > (chart.height - size.height)) {
+ yAlign = 'bottom';
+ }
+
+ var lf, rf; // functions to determine left, right alignment
+ var olf, orf; // functions to determine if left/right alignment causes tooltip to go outside chart
+ var yf; // function to get the y alignment if the tooltip goes outside of the left or right edges
+ var midX = (chartArea.left + chartArea.right) / 2;
+ var midY = (chartArea.top + chartArea.bottom) / 2;
+
+ if (yAlign === 'center') {
+ lf = function(x) {
+ return x <= midX;
+ };
+ rf = function(x) {
+ return x > midX;
+ };
+ } else {
+ lf = function(x) {
+ return x <= (size.width / 2);
+ };
+ rf = function(x) {
+ return x >= (chart.width - (size.width / 2));
+ };
+ }
+
+ olf = function(x) {
+ return x + size.width > chart.width;
+ };
+ orf = function(x) {
+ return x - size.width < 0;
+ };
+ yf = function(y) {
+ return y <= midY ? 'top' : 'bottom';
+ };
+
+ if (lf(model.x)) {
+ xAlign = 'left';
+
+ // Is tooltip too wide and goes over the right side of the chart.?
+ if (olf(model.x)) {
+ xAlign = 'center';
+ yAlign = yf(model.y);
+ }
+ } else if (rf(model.x)) {
+ xAlign = 'right';
+
+ // Is tooltip too wide and goes outside left edge of canvas?
+ if (orf(model.x)) {
+ xAlign = 'center';
+ yAlign = yf(model.y);
+ }
+ }
+
+ var opts = tooltip._options;
+ return {
+ xAlign: opts.xAlign ? opts.xAlign : xAlign,
+ yAlign: opts.yAlign ? opts.yAlign : yAlign
+ };
+ }
+
+ /**
+ * @Helper to get the location a tooltip needs to be placed at given the initial position (via the vm) and the size and alignment
+ */
+ function getBackgroundPoint(vm, size, alignment) {
+ // Background Position
+ var x = vm.x;
+ var y = vm.y;
+
+ var caretSize = vm.caretSize;
+ var caretPadding = vm.caretPadding;
+ var cornerRadius = vm.cornerRadius;
+ var xAlign = alignment.xAlign;
+ var yAlign = alignment.yAlign;
+ var paddingAndSize = caretSize + caretPadding;
+ var radiusAndPadding = cornerRadius + caretPadding;
+
+ if (xAlign === 'right') {
+ x -= size.width;
+ } else if (xAlign === 'center') {
+ x -= (size.width / 2);
+ }
+
+ if (yAlign === 'top') {
+ y += paddingAndSize;
+ } else if (yAlign === 'bottom') {
+ y -= size.height + paddingAndSize;
+ } else {
+ y -= (size.height / 2);
+ }
+
+ if (yAlign === 'center') {
+ if (xAlign === 'left') {
+ x += paddingAndSize;
+ } else if (xAlign === 'right') {
+ x -= paddingAndSize;
+ }
+ } else if (xAlign === 'left') {
+ x -= radiusAndPadding;
+ } else if (xAlign === 'right') {
+ x += radiusAndPadding;
+ }
+
+ return {
+ x: x,
+ y: y
+ };
+ }
+
+ Chart.Tooltip = Element.extend({
+ initialize: function() {
+ this._model = getBaseModel(this._options);
+ this._lastActive = [];
+ },
+
+ // Get the title
+ // Args are: (tooltipItem, data)
+ getTitle: function() {
+ var me = this;
+ var opts = me._options;
+ var callbacks = opts.callbacks;
+
+ var beforeTitle = callbacks.beforeTitle.apply(me, arguments);
+ var title = callbacks.title.apply(me, arguments);
+ var afterTitle = callbacks.afterTitle.apply(me, arguments);
+
+ var lines = [];
+ lines = pushOrConcat(lines, beforeTitle);
+ lines = pushOrConcat(lines, title);
+ lines = pushOrConcat(lines, afterTitle);
+
+ return lines;
+ },
+
+ // Args are: (tooltipItem, data)
+ getBeforeBody: function() {
+ var lines = this._options.callbacks.beforeBody.apply(this, arguments);
+ return helpers.isArray(lines) ? lines : lines !== undefined ? [lines] : [];
+ },
+
+ // Args are: (tooltipItem, data)
+ getBody: function(tooltipItems, data) {
+ var me = this;
+ var callbacks = me._options.callbacks;
+ var bodyItems = [];
+
+ helpers.each(tooltipItems, function(tooltipItem) {
+ var bodyItem = {
+ before: [],
+ lines: [],
+ after: []
+ };
+ pushOrConcat(bodyItem.before, callbacks.beforeLabel.call(me, tooltipItem, data));
+ pushOrConcat(bodyItem.lines, callbacks.label.call(me, tooltipItem, data));
+ pushOrConcat(bodyItem.after, callbacks.afterLabel.call(me, tooltipItem, data));
+
+ bodyItems.push(bodyItem);
+ });
+
+ return bodyItems;
+ },
+
+ // Args are: (tooltipItem, data)
+ getAfterBody: function() {
+ var lines = this._options.callbacks.afterBody.apply(this, arguments);
+ return helpers.isArray(lines) ? lines : lines !== undefined ? [lines] : [];
+ },
+
+ // Get the footer and beforeFooter and afterFooter lines
+ // Args are: (tooltipItem, data)
+ getFooter: function() {
+ var me = this;
+ var callbacks = me._options.callbacks;
+
+ var beforeFooter = callbacks.beforeFooter.apply(me, arguments);
+ var footer = callbacks.footer.apply(me, arguments);
+ var afterFooter = callbacks.afterFooter.apply(me, arguments);
+
+ var lines = [];
+ lines = pushOrConcat(lines, beforeFooter);
+ lines = pushOrConcat(lines, footer);
+ lines = pushOrConcat(lines, afterFooter);
+
+ return lines;
+ },
+
+ update: function(changed) {
+ var me = this;
+ var opts = me._options;
+
+ // Need to regenerate the model because its faster than using extend and it is necessary due to the optimization in Chart.Element.transition
+ // that does _view = _model if ease === 1. This causes the 2nd tooltip update to set properties in both the view and model at the same time
+ // which breaks any animations.
+ var existingModel = me._model;
+ var model = me._model = getBaseModel(opts);
+ var active = me._active;
+
+ var data = me._data;
+
+ // In the case where active.length === 0 we need to keep these at existing values for good animations
+ var alignment = {
+ xAlign: existingModel.xAlign,
+ yAlign: existingModel.yAlign
+ };
+ var backgroundPoint = {
+ x: existingModel.x,
+ y: existingModel.y
+ };
+ var tooltipSize = {
+ width: existingModel.width,
+ height: existingModel.height
+ };
+ var tooltipPosition = {
+ x: existingModel.caretX,
+ y: existingModel.caretY
+ };
+
+ var i, len;
+
+ if (active.length) {
+ model.opacity = 1;
+
+ var labelColors = [];
+ var labelTextColors = [];
+ tooltipPosition = Chart.Tooltip.positioners[opts.position].call(me, active, me._eventPosition);
+
+ var tooltipItems = [];
+ for (i = 0, len = active.length; i < len; ++i) {
+ tooltipItems.push(createTooltipItem(active[i]));
+ }
+
+ // If the user provided a filter function, use it to modify the tooltip items
+ if (opts.filter) {
+ tooltipItems = tooltipItems.filter(function(a) {
+ return opts.filter(a, data);
+ });
+ }
+
+ // If the user provided a sorting function, use it to modify the tooltip items
+ if (opts.itemSort) {
+ tooltipItems = tooltipItems.sort(function(a, b) {
+ return opts.itemSort(a, b, data);
+ });
+ }
+
+ // Determine colors for boxes
+ helpers.each(tooltipItems, function(tooltipItem) {
+ labelColors.push(opts.callbacks.labelColor.call(me, tooltipItem, me._chart));
+ labelTextColors.push(opts.callbacks.labelTextColor.call(me, tooltipItem, me._chart));
+ });
+
+
+ // Build the Text Lines
+ model.title = me.getTitle(tooltipItems, data);
+ model.beforeBody = me.getBeforeBody(tooltipItems, data);
+ model.body = me.getBody(tooltipItems, data);
+ model.afterBody = me.getAfterBody(tooltipItems, data);
+ model.footer = me.getFooter(tooltipItems, data);
+
+ // Initial positioning and colors
+ model.x = Math.round(tooltipPosition.x);
+ model.y = Math.round(tooltipPosition.y);
+ model.caretPadding = opts.caretPadding;
+ model.labelColors = labelColors;
+ model.labelTextColors = labelTextColors;
+
+ // data points
+ model.dataPoints = tooltipItems;
+
+ // We need to determine alignment of the tooltip
+ tooltipSize = getTooltipSize(this, model);
+ alignment = determineAlignment(this, tooltipSize);
+ // Final Size and Position
+ backgroundPoint = getBackgroundPoint(model, tooltipSize, alignment);
+ } else {
+ model.opacity = 0;
+ }
+
+ model.xAlign = alignment.xAlign;
+ model.yAlign = alignment.yAlign;
+ model.x = backgroundPoint.x;
+ model.y = backgroundPoint.y;
+ model.width = tooltipSize.width;
+ model.height = tooltipSize.height;
+
+ // Point where the caret on the tooltip points to
+ model.caretX = tooltipPosition.x;
+ model.caretY = tooltipPosition.y;
+
+ me._model = model;
+
+ if (changed && opts.custom) {
+ opts.custom.call(me, model);
+ }
+
+ return me;
+ },
+ drawCaret: function(tooltipPoint, size) {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+ var caretPosition = this.getCaretPosition(tooltipPoint, size, vm);
+
+ ctx.lineTo(caretPosition.x1, caretPosition.y1);
+ ctx.lineTo(caretPosition.x2, caretPosition.y2);
+ ctx.lineTo(caretPosition.x3, caretPosition.y3);
+ },
+ getCaretPosition: function(tooltipPoint, size, vm) {
+ var x1, x2, x3, y1, y2, y3;
+ var caretSize = vm.caretSize;
+ var cornerRadius = vm.cornerRadius;
+ var xAlign = vm.xAlign;
+ var yAlign = vm.yAlign;
+ var ptX = tooltipPoint.x;
+ var ptY = tooltipPoint.y;
+ var width = size.width;
+ var height = size.height;
+
+ if (yAlign === 'center') {
+ y2 = ptY + (height / 2);
+
+ if (xAlign === 'left') {
+ x1 = ptX;
+ x2 = x1 - caretSize;
+ x3 = x1;
+
+ y1 = y2 + caretSize;
+ y3 = y2 - caretSize;
+ } else {
+ x1 = ptX + width;
+ x2 = x1 + caretSize;
+ x3 = x1;
+
+ y1 = y2 - caretSize;
+ y3 = y2 + caretSize;
+ }
+ } else {
+ if (xAlign === 'left') {
+ x2 = ptX + cornerRadius + (caretSize);
+ x1 = x2 - caretSize;
+ x3 = x2 + caretSize;
+ } else if (xAlign === 'right') {
+ x2 = ptX + width - cornerRadius - caretSize;
+ x1 = x2 - caretSize;
+ x3 = x2 + caretSize;
+ } else {
+ x2 = ptX + (width / 2);
+ x1 = x2 - caretSize;
+ x3 = x2 + caretSize;
+ }
+ if (yAlign === 'top') {
+ y1 = ptY;
+ y2 = y1 - caretSize;
+ y3 = y1;
+ } else {
+ y1 = ptY + height;
+ y2 = y1 + caretSize;
+ y3 = y1;
+ // invert drawing order
+ var tmp = x3;
+ x3 = x1;
+ x1 = tmp;
+ }
+ }
+ return {x1: x1, x2: x2, x3: x3, y1: y1, y2: y2, y3: y3};
+ },
+ drawTitle: function(pt, vm, ctx, opacity) {
+ var title = vm.title;
+
+ if (title.length) {
+ ctx.textAlign = vm._titleAlign;
+ ctx.textBaseline = 'top';
+
+ var titleFontSize = vm.titleFontSize;
+ var titleSpacing = vm.titleSpacing;
+
+ ctx.fillStyle = mergeOpacity(vm.titleFontColor, opacity);
+ ctx.font = helpers.fontString(titleFontSize, vm._titleFontStyle, vm._titleFontFamily);
+
+ var i, len;
+ for (i = 0, len = title.length; i < len; ++i) {
+ ctx.fillText(title[i], pt.x, pt.y);
+ pt.y += titleFontSize + titleSpacing; // Line Height and spacing
+
+ if (i + 1 === title.length) {
+ pt.y += vm.titleMarginBottom - titleSpacing; // If Last, add margin, remove spacing
+ }
+ }
+ }
+ },
+ drawBody: function(pt, vm, ctx, opacity) {
+ var bodyFontSize = vm.bodyFontSize;
+ var bodySpacing = vm.bodySpacing;
+ var body = vm.body;
+
+ ctx.textAlign = vm._bodyAlign;
+ ctx.textBaseline = 'top';
+ ctx.font = helpers.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
+
+ // Before Body
+ var xLinePadding = 0;
+ var fillLineOfText = function(line) {
+ ctx.fillText(line, pt.x + xLinePadding, pt.y);
+ pt.y += bodyFontSize + bodySpacing;
+ };
+
+ // Before body lines
+ ctx.fillStyle = mergeOpacity(vm.bodyFontColor, opacity);
+ helpers.each(vm.beforeBody, fillLineOfText);
+
+ var drawColorBoxes = vm.displayColors;
+ xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0;
+
+ // Draw body lines now
+ helpers.each(body, function(bodyItem, i) {
+ var textColor = mergeOpacity(vm.labelTextColors[i], opacity);
+ ctx.fillStyle = textColor;
+ helpers.each(bodyItem.before, fillLineOfText);
+
+ helpers.each(bodyItem.lines, function(line) {
+ // Draw Legend-like boxes if needed
+ if (drawColorBoxes) {
+ // Fill a white rect so that colours merge nicely if the opacity is < 1
+ ctx.fillStyle = mergeOpacity(vm.legendColorBackground, opacity);
+ ctx.fillRect(pt.x, pt.y, bodyFontSize, bodyFontSize);
+
+ // Border
+ ctx.lineWidth = 1;
+ ctx.strokeStyle = mergeOpacity(vm.labelColors[i].borderColor, opacity);
+ ctx.strokeRect(pt.x, pt.y, bodyFontSize, bodyFontSize);
+
+ // Inner square
+ ctx.fillStyle = mergeOpacity(vm.labelColors[i].backgroundColor, opacity);
+ ctx.fillRect(pt.x + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2);
+ ctx.fillStyle = textColor;
+ }
+
+ fillLineOfText(line);
+ });
+
+ helpers.each(bodyItem.after, fillLineOfText);
+ });
+
+ // Reset back to 0 for after body
+ xLinePadding = 0;
+
+ // After body lines
+ helpers.each(vm.afterBody, fillLineOfText);
+ pt.y -= bodySpacing; // Remove last body spacing
+ },
+ drawFooter: function(pt, vm, ctx, opacity) {
+ var footer = vm.footer;
+
+ if (footer.length) {
+ pt.y += vm.footerMarginTop;
+
+ ctx.textAlign = vm._footerAlign;
+ ctx.textBaseline = 'top';
+
+ ctx.fillStyle = mergeOpacity(vm.footerFontColor, opacity);
+ ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
+
+ helpers.each(footer, function(line) {
+ ctx.fillText(line, pt.x, pt.y);
+ pt.y += vm.footerFontSize + vm.footerSpacing;
+ });
+ }
+ },
+ drawBackground: function(pt, vm, ctx, tooltipSize, opacity) {
+ ctx.fillStyle = mergeOpacity(vm.backgroundColor, opacity);
+ ctx.strokeStyle = mergeOpacity(vm.borderColor, opacity);
+ ctx.lineWidth = vm.borderWidth;
+ var xAlign = vm.xAlign;
+ var yAlign = vm.yAlign;
+ var x = pt.x;
+ var y = pt.y;
+ var width = tooltipSize.width;
+ var height = tooltipSize.height;
+ var radius = vm.cornerRadius;
+
+ ctx.beginPath();
+ ctx.moveTo(x + radius, y);
+ if (yAlign === 'top') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x + width - radius, y);
+ ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
+ if (yAlign === 'center' && xAlign === 'right') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x + width, y + height - radius);
+ ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
+ if (yAlign === 'bottom') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x + radius, y + height);
+ ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
+ if (yAlign === 'center' && xAlign === 'left') {
+ this.drawCaret(pt, tooltipSize);
+ }
+ ctx.lineTo(x, y + radius);
+ ctx.quadraticCurveTo(x, y, x + radius, y);
+ ctx.closePath();
+
+ ctx.fill();
+
+ if (vm.borderWidth > 0) {
+ ctx.stroke();
+ }
+ },
+ draw: function() {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+
+ if (vm.opacity === 0) {
+ return;
+ }
+
+ var tooltipSize = {
+ width: vm.width,
+ height: vm.height
+ };
+ var pt = {
+ x: vm.x,
+ y: vm.y
+ };
+
+ // IE11/Edge does not like very small opacities, so snap to 0
+ var opacity = Math.abs(vm.opacity < 1e-3) ? 0 : vm.opacity;
+
+ // Truthy/falsey value for empty tooltip
+ var hasTooltipContent = vm.title.length || vm.beforeBody.length || vm.body.length || vm.afterBody.length || vm.footer.length;
+
+ if (this._options.enabled && hasTooltipContent) {
+ // Draw Background
+ this.drawBackground(pt, vm, ctx, tooltipSize, opacity);
+
+ // Draw Title, Body, and Footer
+ pt.x += vm.xPadding;
+ pt.y += vm.yPadding;
+
+ // Titles
+ this.drawTitle(pt, vm, ctx, opacity);
+
+ // Body
+ this.drawBody(pt, vm, ctx, opacity);
+
+ // Footer
+ this.drawFooter(pt, vm, ctx, opacity);
+ }
+ },
+
+ /**
+ * Handle an event
+ * @private
+ * @param {IEvent} event - The event to handle
+ * @returns {Boolean} true if the tooltip changed
+ */
+ handleEvent: function(e) {
+ var me = this;
+ var options = me._options;
+ var changed = false;
+
+ me._lastActive = me._lastActive || [];
+
+ // Find Active Elements for tooltips
+ if (e.type === 'mouseout') {
+ me._active = [];
+ } else {
+ me._active = me._chart.getElementsAtEventForMode(e, options.mode, options);
+ }
+
+ // Remember Last Actives
+ changed = !helpers.arrayEquals(me._active, me._lastActive);
+
+ // If tooltip didn't change, do not handle the target event
+ if (!changed) {
+ return false;
+ }
+
+ me._lastActive = me._active;
+
+ if (options.enabled || options.custom) {
+ me._eventPosition = {
+ x: e.x,
+ y: e.y
+ };
+
+ var model = me._model;
+ me.update(true);
+ me.pivot();
+
+ // See if our tooltip position changed
+ changed |= (model.x !== me._model.x) || (model.y !== me._model.y);
+ }
+
+ return changed;
+ }
+ });
+
+ /**
+ * @namespace Chart.Tooltip.positioners
+ */
+ Chart.Tooltip.positioners = {
+ /**
+ * Average mode places the tooltip at the average position of the elements shown
+ * @function Chart.Tooltip.positioners.average
+ * @param elements {ChartElement[]} the elements being displayed in the tooltip
+ * @returns {Point} tooltip position
+ */
+ average: function(elements) {
+ if (!elements.length) {
+ return false;
+ }
+
+ var i, len;
+ var x = 0;
+ var y = 0;
+ var count = 0;
+
+ for (i = 0, len = elements.length; i < len; ++i) {
+ var el = elements[i];
+ if (el && el.hasValue()) {
+ var pos = el.tooltipPosition();
+ x += pos.x;
+ y += pos.y;
+ ++count;
+ }
+ }
+
+ return {
+ x: Math.round(x / count),
+ y: Math.round(y / count)
+ };
+ },
+
+ /**
+ * Gets the tooltip position nearest of the item nearest to the event position
+ * @function Chart.Tooltip.positioners.nearest
+ * @param elements {Chart.Element[]} the tooltip elements
+ * @param eventPosition {Point} the position of the event in canvas coordinates
+ * @returns {Point} the tooltip position
+ */
+ nearest: function(elements, eventPosition) {
+ var x = eventPosition.x;
+ var y = eventPosition.y;
+ var minDistance = Number.POSITIVE_INFINITY;
+ var i, len, nearestElement;
+
+ for (i = 0, len = elements.length; i < len; ++i) {
+ var el = elements[i];
+ if (el && el.hasValue()) {
+ var center = el.getCenterPoint();
+ var d = helpers.distanceBetweenPoints(eventPosition, center);
+
+ if (d < minDistance) {
+ minDistance = d;
+ nearestElement = el;
+ }
+ }
+ }
+
+ if (nearestElement) {
+ var tp = nearestElement.tooltipPosition();
+ x = tp.x;
+ y = tp.y;
+ }
+
+ return {
+ x: x,
+ y: y
+ };
+ }
+ };
+};
+
+},{"25":25,"26":26,"45":45}],36:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ elements: {
+ arc: {
+ backgroundColor: defaults.global.defaultColor,
+ borderColor: '#fff',
+ borderWidth: 2
+ }
+ }
+});
+
+module.exports = Element.extend({
+ inLabelRange: function(mouseX) {
+ var vm = this._view;
+
+ if (vm) {
+ return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2));
+ }
+ return false;
+ },
+
+ inRange: function(chartX, chartY) {
+ var vm = this._view;
+
+ if (vm) {
+ var pointRelativePosition = helpers.getAngleFromPoint(vm, {x: chartX, y: chartY});
+ var angle = pointRelativePosition.angle;
+ var distance = pointRelativePosition.distance;
+
+ // Sanitise angle range
+ var startAngle = vm.startAngle;
+ var endAngle = vm.endAngle;
+ while (endAngle < startAngle) {
+ endAngle += 2.0 * Math.PI;
+ }
+ while (angle > endAngle) {
+ angle -= 2.0 * Math.PI;
+ }
+ while (angle < startAngle) {
+ angle += 2.0 * Math.PI;
+ }
+
+ // Check if within the range of the open/close angle
+ var betweenAngles = (angle >= startAngle && angle <= endAngle);
+ var withinRadius = (distance >= vm.innerRadius && distance <= vm.outerRadius);
+
+ return (betweenAngles && withinRadius);
+ }
+ return false;
+ },
+
+ getCenterPoint: function() {
+ var vm = this._view;
+ var halfAngle = (vm.startAngle + vm.endAngle) / 2;
+ var halfRadius = (vm.innerRadius + vm.outerRadius) / 2;
+ return {
+ x: vm.x + Math.cos(halfAngle) * halfRadius,
+ y: vm.y + Math.sin(halfAngle) * halfRadius
+ };
+ },
+
+ getArea: function() {
+ var vm = this._view;
+ return Math.PI * ((vm.endAngle - vm.startAngle) / (2 * Math.PI)) * (Math.pow(vm.outerRadius, 2) - Math.pow(vm.innerRadius, 2));
+ },
+
+ tooltipPosition: function() {
+ var vm = this._view;
+ var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2);
+ var rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius;
+
+ return {
+ x: vm.x + (Math.cos(centreAngle) * rangeFromCentre),
+ y: vm.y + (Math.sin(centreAngle) * rangeFromCentre)
+ };
+ },
+
+ draw: function() {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+ var sA = vm.startAngle;
+ var eA = vm.endAngle;
+
+ ctx.beginPath();
+
+ ctx.arc(vm.x, vm.y, vm.outerRadius, sA, eA);
+ ctx.arc(vm.x, vm.y, vm.innerRadius, eA, sA, true);
+
+ ctx.closePath();
+ ctx.strokeStyle = vm.borderColor;
+ ctx.lineWidth = vm.borderWidth;
+
+ ctx.fillStyle = vm.backgroundColor;
+
+ ctx.fill();
+ ctx.lineJoin = 'bevel';
+
+ if (vm.borderWidth) {
+ ctx.stroke();
+ }
+ }
+});
+
+},{"25":25,"26":26,"45":45}],37:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+var globalDefaults = defaults.global;
+
+defaults._set('global', {
+ elements: {
+ line: {
+ tension: 0.4,
+ backgroundColor: globalDefaults.defaultColor,
+ borderWidth: 3,
+ borderColor: globalDefaults.defaultColor,
+ borderCapStyle: 'butt',
+ borderDash: [],
+ borderDashOffset: 0.0,
+ borderJoinStyle: 'miter',
+ capBezierPoints: true,
+ fill: true, // do we fill in the area between the line and its base axis
+ }
+ }
+});
+
+module.exports = Element.extend({
+ draw: function() {
+ var me = this;
+ var vm = me._view;
+ var ctx = me._chart.ctx;
+ var spanGaps = vm.spanGaps;
+ var points = me._children.slice(); // clone array
+ var globalOptionLineElements = globalDefaults.elements.line;
+ var lastDrawnIndex = -1;
+ var index, current, previous, currentVM;
+
+ // If we are looping, adding the first point again
+ if (me._loop && points.length) {
+ points.push(points[0]);
+ }
+
+ ctx.save();
+
+ // Stroke Line Options
+ ctx.lineCap = vm.borderCapStyle || globalOptionLineElements.borderCapStyle;
+
+ // IE 9 and 10 do not support line dash
+ if (ctx.setLineDash) {
+ ctx.setLineDash(vm.borderDash || globalOptionLineElements.borderDash);
+ }
+
+ ctx.lineDashOffset = vm.borderDashOffset || globalOptionLineElements.borderDashOffset;
+ ctx.lineJoin = vm.borderJoinStyle || globalOptionLineElements.borderJoinStyle;
+ ctx.lineWidth = vm.borderWidth || globalOptionLineElements.borderWidth;
+ ctx.strokeStyle = vm.borderColor || globalDefaults.defaultColor;
+
+ // Stroke Line
+ ctx.beginPath();
+ lastDrawnIndex = -1;
+
+ for (index = 0; index < points.length; ++index) {
+ current = points[index];
+ previous = helpers.previousItem(points, index);
+ currentVM = current._view;
+
+ // First point moves to it's starting position no matter what
+ if (index === 0) {
+ if (!currentVM.skip) {
+ ctx.moveTo(currentVM.x, currentVM.y);
+ lastDrawnIndex = index;
+ }
+ } else {
+ previous = lastDrawnIndex === -1 ? previous : points[lastDrawnIndex];
+
+ if (!currentVM.skip) {
+ if ((lastDrawnIndex !== (index - 1) && !spanGaps) || lastDrawnIndex === -1) {
+ // There was a gap and this is the first point after the gap
+ ctx.moveTo(currentVM.x, currentVM.y);
+ } else {
+ // Line to next point
+ helpers.canvas.lineTo(ctx, previous._view, current._view);
+ }
+ lastDrawnIndex = index;
+ }
+ }
+ }
+
+ ctx.stroke();
+ ctx.restore();
+ }
+});
+
+},{"25":25,"26":26,"45":45}],38:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+var defaultColor = defaults.global.defaultColor;
+
+defaults._set('global', {
+ elements: {
+ point: {
+ radius: 3,
+ pointStyle: 'circle',
+ backgroundColor: defaultColor,
+ borderColor: defaultColor,
+ borderWidth: 1,
+ // Hover
+ hitRadius: 1,
+ hoverRadius: 4,
+ hoverBorderWidth: 1
+ }
+ }
+});
+
+function xRange(mouseX) {
+ var vm = this._view;
+ return vm ? (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)) : false;
+}
+
+function yRange(mouseY) {
+ var vm = this._view;
+ return vm ? (Math.pow(mouseY - vm.y, 2) < Math.pow(vm.radius + vm.hitRadius, 2)) : false;
+}
+
+module.exports = Element.extend({
+ inRange: function(mouseX, mouseY) {
+ var vm = this._view;
+ return vm ? ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(vm.hitRadius + vm.radius, 2)) : false;
+ },
+
+ inLabelRange: xRange,
+ inXRange: xRange,
+ inYRange: yRange,
+
+ getCenterPoint: function() {
+ var vm = this._view;
+ return {
+ x: vm.x,
+ y: vm.y
+ };
+ },
+
+ getArea: function() {
+ return Math.PI * Math.pow(this._view.radius, 2);
+ },
+
+ tooltipPosition: function() {
+ var vm = this._view;
+ return {
+ x: vm.x,
+ y: vm.y,
+ padding: vm.radius + vm.borderWidth
+ };
+ },
+
+ draw: function(chartArea) {
+ var vm = this._view;
+ var model = this._model;
+ var ctx = this._chart.ctx;
+ var pointStyle = vm.pointStyle;
+ var radius = vm.radius;
+ var x = vm.x;
+ var y = vm.y;
+ var color = helpers.color;
+ var errMargin = 1.01; // 1.01 is margin for Accumulated error. (Especially Edge, IE.)
+ var ratio = 0;
+
+ if (vm.skip) {
+ return;
+ }
+
+ ctx.strokeStyle = vm.borderColor || defaultColor;
+ ctx.lineWidth = helpers.valueOrDefault(vm.borderWidth, defaults.global.elements.point.borderWidth);
+ ctx.fillStyle = vm.backgroundColor || defaultColor;
+
+ // Cliping for Points.
+ // going out from inner charArea?
+ if ((chartArea !== undefined) && ((model.x < chartArea.left) || (chartArea.right * errMargin < model.x) || (model.y < chartArea.top) || (chartArea.bottom * errMargin < model.y))) {
+ // Point fade out
+ if (model.x < chartArea.left) {
+ ratio = (x - model.x) / (chartArea.left - model.x);
+ } else if (chartArea.right * errMargin < model.x) {
+ ratio = (model.x - x) / (model.x - chartArea.right);
+ } else if (model.y < chartArea.top) {
+ ratio = (y - model.y) / (chartArea.top - model.y);
+ } else if (chartArea.bottom * errMargin < model.y) {
+ ratio = (model.y - y) / (model.y - chartArea.bottom);
+ }
+ ratio = Math.round(ratio * 100) / 100;
+ ctx.strokeStyle = color(ctx.strokeStyle).alpha(ratio).rgbString();
+ ctx.fillStyle = color(ctx.fillStyle).alpha(ratio).rgbString();
+ }
+
+ helpers.canvas.drawPoint(ctx, pointStyle, radius, x, y);
+ }
+});
+
+},{"25":25,"26":26,"45":45}],39:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+
+defaults._set('global', {
+ elements: {
+ rectangle: {
+ backgroundColor: defaults.global.defaultColor,
+ borderColor: defaults.global.defaultColor,
+ borderSkipped: 'bottom',
+ borderWidth: 0
+ }
+ }
+});
+
+function isVertical(bar) {
+ return bar._view.width !== undefined;
+}
+
+/**
+ * Helper function to get the bounds of the bar regardless of the orientation
+ * @param bar {Chart.Element.Rectangle} the bar
+ * @return {Bounds} bounds of the bar
+ * @private
+ */
+function getBarBounds(bar) {
+ var vm = bar._view;
+ var x1, x2, y1, y2;
+
+ if (isVertical(bar)) {
+ // vertical
+ var halfWidth = vm.width / 2;
+ x1 = vm.x - halfWidth;
+ x2 = vm.x + halfWidth;
+ y1 = Math.min(vm.y, vm.base);
+ y2 = Math.max(vm.y, vm.base);
+ } else {
+ // horizontal bar
+ var halfHeight = vm.height / 2;
+ x1 = Math.min(vm.x, vm.base);
+ x2 = Math.max(vm.x, vm.base);
+ y1 = vm.y - halfHeight;
+ y2 = vm.y + halfHeight;
+ }
+
+ return {
+ left: x1,
+ top: y1,
+ right: x2,
+ bottom: y2
+ };
+}
+
+module.exports = Element.extend({
+ draw: function() {
+ var ctx = this._chart.ctx;
+ var vm = this._view;
+ var left, right, top, bottom, signX, signY, borderSkipped;
+ var borderWidth = vm.borderWidth;
+
+ if (!vm.horizontal) {
+ // bar
+ left = vm.x - vm.width / 2;
+ right = vm.x + vm.width / 2;
+ top = vm.y;
+ bottom = vm.base;
+ signX = 1;
+ signY = bottom > top ? 1 : -1;
+ borderSkipped = vm.borderSkipped || 'bottom';
+ } else {
+ // horizontal bar
+ left = vm.base;
+ right = vm.x;
+ top = vm.y - vm.height / 2;
+ bottom = vm.y + vm.height / 2;
+ signX = right > left ? 1 : -1;
+ signY = 1;
+ borderSkipped = vm.borderSkipped || 'left';
+ }
+
+ // Canvas doesn't allow us to stroke inside the width so we can
+ // adjust the sizes to fit if we're setting a stroke on the line
+ if (borderWidth) {
+ // borderWidth shold be less than bar width and bar height.
+ var barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom));
+ borderWidth = borderWidth > barSize ? barSize : borderWidth;
+ var halfStroke = borderWidth / 2;
+ // Adjust borderWidth when bar top position is near vm.base(zero).
+ var borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0);
+ var borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0);
+ var borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0);
+ var borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0);
+ // not become a vertical line?
+ if (borderLeft !== borderRight) {
+ top = borderTop;
+ bottom = borderBottom;
+ }
+ // not become a horizontal line?
+ if (borderTop !== borderBottom) {
+ left = borderLeft;
+ right = borderRight;
+ }
+ }
+
+ ctx.beginPath();
+ ctx.fillStyle = vm.backgroundColor;
+ ctx.strokeStyle = vm.borderColor;
+ ctx.lineWidth = borderWidth;
+
+ // Corner points, from bottom-left to bottom-right clockwise
+ // | 1 2 |
+ // | 0 3 |
+ var corners = [
+ [left, bottom],
+ [left, top],
+ [right, top],
+ [right, bottom]
+ ];
+
+ // Find first (starting) corner with fallback to 'bottom'
+ var borders = ['bottom', 'left', 'top', 'right'];
+ var startCorner = borders.indexOf(borderSkipped, 0);
+ if (startCorner === -1) {
+ startCorner = 0;
+ }
+
+ function cornerAt(index) {
+ return corners[(startCorner + index) % 4];
+ }
+
+ // Draw rectangle from 'startCorner'
+ var corner = cornerAt(0);
+ ctx.moveTo(corner[0], corner[1]);
+
+ for (var i = 1; i < 4; i++) {
+ corner = cornerAt(i);
+ ctx.lineTo(corner[0], corner[1]);
+ }
+
+ ctx.fill();
+ if (borderWidth) {
+ ctx.stroke();
+ }
+ },
+
+ height: function() {
+ var vm = this._view;
+ return vm.base - vm.y;
+ },
+
+ inRange: function(mouseX, mouseY) {
+ var inRange = false;
+
+ if (this._view) {
+ var bounds = getBarBounds(this);
+ inRange = mouseX >= bounds.left && mouseX <= bounds.right && mouseY >= bounds.top && mouseY <= bounds.bottom;
+ }
+
+ return inRange;
+ },
+
+ inLabelRange: function(mouseX, mouseY) {
+ var me = this;
+ if (!me._view) {
+ return false;
+ }
+
+ var inRange = false;
+ var bounds = getBarBounds(me);
+
+ if (isVertical(me)) {
+ inRange = mouseX >= bounds.left && mouseX <= bounds.right;
+ } else {
+ inRange = mouseY >= bounds.top && mouseY <= bounds.bottom;
+ }
+
+ return inRange;
+ },
+
+ inXRange: function(mouseX) {
+ var bounds = getBarBounds(this);
+ return mouseX >= bounds.left && mouseX <= bounds.right;
+ },
+
+ inYRange: function(mouseY) {
+ var bounds = getBarBounds(this);
+ return mouseY >= bounds.top && mouseY <= bounds.bottom;
+ },
+
+ getCenterPoint: function() {
+ var vm = this._view;
+ var x, y;
+ if (isVertical(this)) {
+ x = vm.x;
+ y = (vm.y + vm.base) / 2;
+ } else {
+ x = (vm.x + vm.base) / 2;
+ y = vm.y;
+ }
+
+ return {x: x, y: y};
+ },
+
+ getArea: function() {
+ var vm = this._view;
+ return vm.width * Math.abs(vm.y - vm.base);
+ },
+
+ tooltipPosition: function() {
+ var vm = this._view;
+ return {
+ x: vm.x,
+ y: vm.y
+ };
+ }
+});
+
+},{"25":25,"26":26}],40:[function(require,module,exports){
+'use strict';
+
+module.exports = {};
+module.exports.Arc = require(36);
+module.exports.Line = require(37);
+module.exports.Point = require(38);
+module.exports.Rectangle = require(39);
+
+},{"36":36,"37":37,"38":38,"39":39}],41:[function(require,module,exports){
+'use strict';
+
+var helpers = require(42);
+
+/**
+ * @namespace Chart.helpers.canvas
+ */
+var exports = module.exports = {
+ /**
+ * Clears the entire canvas associated to the given `chart`.
+ * @param {Chart} chart - The chart for which to clear the canvas.
+ */
+ clear: function(chart) {
+ chart.ctx.clearRect(0, 0, chart.width, chart.height);
+ },
+
+ /**
+ * Creates a "path" for a rectangle with rounded corners at position (x, y) with a
+ * given size (width, height) and the same `radius` for all corners.
+ * @param {CanvasRenderingContext2D} ctx - The canvas 2D Context.
+ * @param {Number} x - The x axis of the coordinate for the rectangle starting point.
+ * @param {Number} y - The y axis of the coordinate for the rectangle starting point.
+ * @param {Number} width - The rectangle's width.
+ * @param {Number} height - The rectangle's height.
+ * @param {Number} radius - The rounded amount (in pixels) for the four corners.
+ * @todo handle `radius` as top-left, top-right, bottom-right, bottom-left array/object?
+ */
+ roundedRect: function(ctx, x, y, width, height, radius) {
+ if (radius) {
+ var rx = Math.min(radius, width / 2);
+ var ry = Math.min(radius, height / 2);
+
+ ctx.moveTo(x + rx, y);
+ ctx.lineTo(x + width - rx, y);
+ ctx.quadraticCurveTo(x + width, y, x + width, y + ry);
+ ctx.lineTo(x + width, y + height - ry);
+ ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height);
+ ctx.lineTo(x + rx, y + height);
+ ctx.quadraticCurveTo(x, y + height, x, y + height - ry);
+ ctx.lineTo(x, y + ry);
+ ctx.quadraticCurveTo(x, y, x + rx, y);
+ } else {
+ ctx.rect(x, y, width, height);
+ }
+ },
+
+ drawPoint: function(ctx, style, radius, x, y) {
+ var type, edgeLength, xOffset, yOffset, height, size;
+
+ if (style && typeof style === 'object') {
+ type = style.toString();
+ if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') {
+ ctx.drawImage(style, x - style.width / 2, y - style.height / 2, style.width, style.height);
+ return;
+ }
+ }
+
+ if (isNaN(radius) || radius <= 0) {
+ return;
+ }
+
+ switch (style) {
+ // Default includes circle
+ default:
+ ctx.beginPath();
+ ctx.arc(x, y, radius, 0, Math.PI * 2);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'triangle':
+ ctx.beginPath();
+ edgeLength = 3 * radius / Math.sqrt(3);
+ height = edgeLength * Math.sqrt(3) / 2;
+ ctx.moveTo(x - edgeLength / 2, y + height / 3);
+ ctx.lineTo(x + edgeLength / 2, y + height / 3);
+ ctx.lineTo(x, y - 2 * height / 3);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'rect':
+ size = 1 / Math.SQRT2 * radius;
+ ctx.beginPath();
+ ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
+ ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
+ break;
+ case 'rectRounded':
+ var offset = radius / Math.SQRT2;
+ var leftX = x - offset;
+ var topY = y - offset;
+ var sideSize = Math.SQRT2 * radius;
+ ctx.beginPath();
+ this.roundedRect(ctx, leftX, topY, sideSize, sideSize, radius / 2);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'rectRot':
+ size = 1 / Math.SQRT2 * radius;
+ ctx.beginPath();
+ ctx.moveTo(x - size, y);
+ ctx.lineTo(x, y + size);
+ ctx.lineTo(x + size, y);
+ ctx.lineTo(x, y - size);
+ ctx.closePath();
+ ctx.fill();
+ break;
+ case 'cross':
+ ctx.beginPath();
+ ctx.moveTo(x, y + radius);
+ ctx.lineTo(x, y - radius);
+ ctx.moveTo(x - radius, y);
+ ctx.lineTo(x + radius, y);
+ ctx.closePath();
+ break;
+ case 'crossRot':
+ ctx.beginPath();
+ xOffset = Math.cos(Math.PI / 4) * radius;
+ yOffset = Math.sin(Math.PI / 4) * radius;
+ ctx.moveTo(x - xOffset, y - yOffset);
+ ctx.lineTo(x + xOffset, y + yOffset);
+ ctx.moveTo(x - xOffset, y + yOffset);
+ ctx.lineTo(x + xOffset, y - yOffset);
+ ctx.closePath();
+ break;
+ case 'star':
+ ctx.beginPath();
+ ctx.moveTo(x, y + radius);
+ ctx.lineTo(x, y - radius);
+ ctx.moveTo(x - radius, y);
+ ctx.lineTo(x + radius, y);
+ xOffset = Math.cos(Math.PI / 4) * radius;
+ yOffset = Math.sin(Math.PI / 4) * radius;
+ ctx.moveTo(x - xOffset, y - yOffset);
+ ctx.lineTo(x + xOffset, y + yOffset);
+ ctx.moveTo(x - xOffset, y + yOffset);
+ ctx.lineTo(x + xOffset, y - yOffset);
+ ctx.closePath();
+ break;
+ case 'line':
+ ctx.beginPath();
+ ctx.moveTo(x - radius, y);
+ ctx.lineTo(x + radius, y);
+ ctx.closePath();
+ break;
+ case 'dash':
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ ctx.lineTo(x + radius, y);
+ ctx.closePath();
+ break;
+ }
+
+ ctx.stroke();
+ },
+
+ clipArea: function(ctx, area) {
+ ctx.save();
+ ctx.beginPath();
+ ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);
+ ctx.clip();
+ },
+
+ unclipArea: function(ctx) {
+ ctx.restore();
+ },
+
+ lineTo: function(ctx, previous, target, flip) {
+ if (target.steppedLine) {
+ if ((target.steppedLine === 'after' && !flip) || (target.steppedLine !== 'after' && flip)) {
+ ctx.lineTo(previous.x, target.y);
+ } else {
+ ctx.lineTo(target.x, previous.y);
+ }
+ ctx.lineTo(target.x, target.y);
+ return;
+ }
+
+ if (!target.tension) {
+ ctx.lineTo(target.x, target.y);
+ return;
+ }
+
+ ctx.bezierCurveTo(
+ flip ? previous.controlPointPreviousX : previous.controlPointNextX,
+ flip ? previous.controlPointPreviousY : previous.controlPointNextY,
+ flip ? target.controlPointNextX : target.controlPointPreviousX,
+ flip ? target.controlPointNextY : target.controlPointPreviousY,
+ target.x,
+ target.y);
+ }
+};
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.canvas.clear instead.
+ * @namespace Chart.helpers.clear
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.clear = exports.clear;
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.canvas.roundedRect instead.
+ * @namespace Chart.helpers.drawRoundedRectangle
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.drawRoundedRectangle = function(ctx) {
+ ctx.beginPath();
+ exports.roundedRect.apply(exports, arguments);
+ ctx.closePath();
+};
+
+},{"42":42}],42:[function(require,module,exports){
+'use strict';
+
+/**
+ * @namespace Chart.helpers
+ */
+var helpers = {
+ /**
+ * An empty function that can be used, for example, for optional callback.
+ */
+ noop: function() {},
+
+ /**
+ * Returns a unique id, sequentially generated from a global variable.
+ * @returns {Number}
+ * @function
+ */
+ uid: (function() {
+ var id = 0;
+ return function() {
+ return id++;
+ };
+ }()),
+
+ /**
+ * Returns true if `value` is neither null nor undefined, else returns false.
+ * @param {*} value - The value to test.
+ * @returns {Boolean}
+ * @since 2.7.0
+ */
+ isNullOrUndef: function(value) {
+ return value === null || typeof value === 'undefined';
+ },
+
+ /**
+ * Returns true if `value` is an array, else returns false.
+ * @param {*} value - The value to test.
+ * @returns {Boolean}
+ * @function
+ */
+ isArray: Array.isArray ? Array.isArray : function(value) {
+ return Object.prototype.toString.call(value) === '[object Array]';
+ },
+
+ /**
+ * Returns true if `value` is an object (excluding null), else returns false.
+ * @param {*} value - The value to test.
+ * @returns {Boolean}
+ * @since 2.7.0
+ */
+ isObject: function(value) {
+ return value !== null && Object.prototype.toString.call(value) === '[object Object]';
+ },
+
+ /**
+ * Returns `value` if defined, else returns `defaultValue`.
+ * @param {*} value - The value to return if defined.
+ * @param {*} defaultValue - The value to return if `value` is undefined.
+ * @returns {*}
+ */
+ valueOrDefault: function(value, defaultValue) {
+ return typeof value === 'undefined' ? defaultValue : value;
+ },
+
+ /**
+ * Returns value at the given `index` in array if defined, else returns `defaultValue`.
+ * @param {Array} value - The array to lookup for value at `index`.
+ * @param {Number} index - The index in `value` to lookup for value.
+ * @param {*} defaultValue - The value to return if `value[index]` is undefined.
+ * @returns {*}
+ */
+ valueAtIndexOrDefault: function(value, index, defaultValue) {
+ return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : value, defaultValue);
+ },
+
+ /**
+ * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
+ * value returned by `fn`. If `fn` is not a function, this method returns undefined.
+ * @param {Function} fn - The function to call.
+ * @param {Array|undefined|null} args - The arguments with which `fn` should be called.
+ * @param {Object} [thisArg] - The value of `this` provided for the call to `fn`.
+ * @returns {*}
+ */
+ callback: function(fn, args, thisArg) {
+ if (fn && typeof fn.call === 'function') {
+ return fn.apply(thisArg, args);
+ }
+ },
+
+ /**
+ * Note(SB) for performance sake, this method should only be used when loopable type
+ * is unknown or in none intensive code (not called often and small loopable). Else
+ * it's preferable to use a regular for() loop and save extra function calls.
+ * @param {Object|Array} loopable - The object or array to be iterated.
+ * @param {Function} fn - The function to call for each item.
+ * @param {Object} [thisArg] - The value of `this` provided for the call to `fn`.
+ * @param {Boolean} [reverse] - If true, iterates backward on the loopable.
+ */
+ each: function(loopable, fn, thisArg, reverse) {
+ var i, len, keys;
+ if (helpers.isArray(loopable)) {
+ len = loopable.length;
+ if (reverse) {
+ for (i = len - 1; i >= 0; i--) {
+ fn.call(thisArg, loopable[i], i);
+ }
+ } else {
+ for (i = 0; i < len; i++) {
+ fn.call(thisArg, loopable[i], i);
+ }
+ }
+ } else if (helpers.isObject(loopable)) {
+ keys = Object.keys(loopable);
+ len = keys.length;
+ for (i = 0; i < len; i++) {
+ fn.call(thisArg, loopable[keys[i]], keys[i]);
+ }
+ }
+ },
+
+ /**
+ * Returns true if the `a0` and `a1` arrays have the same content, else returns false.
+ * @see http://stackoverflow.com/a/14853974
+ * @param {Array} a0 - The array to compare
+ * @param {Array} a1 - The array to compare
+ * @returns {Boolean}
+ */
+ arrayEquals: function(a0, a1) {
+ var i, ilen, v0, v1;
+
+ if (!a0 || !a1 || a0.length !== a1.length) {
+ return false;
+ }
+
+ for (i = 0, ilen = a0.length; i < ilen; ++i) {
+ v0 = a0[i];
+ v1 = a1[i];
+
+ if (v0 instanceof Array && v1 instanceof Array) {
+ if (!helpers.arrayEquals(v0, v1)) {
+ return false;
+ }
+ } else if (v0 !== v1) {
+ // NOTE: two different object instances will never be equal: {x:20} != {x:20}
+ return false;
+ }
+ }
+
+ return true;
+ },
+
+ /**
+ * Returns a deep copy of `source` without keeping references on objects and arrays.
+ * @param {*} source - The value to clone.
+ * @returns {*}
+ */
+ clone: function(source) {
+ if (helpers.isArray(source)) {
+ return source.map(helpers.clone);
+ }
+
+ if (helpers.isObject(source)) {
+ var target = {};
+ var keys = Object.keys(source);
+ var klen = keys.length;
+ var k = 0;
+
+ for (; k < klen; ++k) {
+ target[keys[k]] = helpers.clone(source[keys[k]]);
+ }
+
+ return target;
+ }
+
+ return source;
+ },
+
+ /**
+ * The default merger when Chart.helpers.merge is called without merger option.
+ * Note(SB): this method is also used by configMerge and scaleMerge as fallback.
+ * @private
+ */
+ _merger: function(key, target, source, options) {
+ var tval = target[key];
+ var sval = source[key];
+
+ if (helpers.isObject(tval) && helpers.isObject(sval)) {
+ helpers.merge(tval, sval, options);
+ } else {
+ target[key] = helpers.clone(sval);
+ }
+ },
+
+ /**
+ * Merges source[key] in target[key] only if target[key] is undefined.
+ * @private
+ */
+ _mergerIf: function(key, target, source) {
+ var tval = target[key];
+ var sval = source[key];
+
+ if (helpers.isObject(tval) && helpers.isObject(sval)) {
+ helpers.mergeIf(tval, sval);
+ } else if (!target.hasOwnProperty(key)) {
+ target[key] = helpers.clone(sval);
+ }
+ },
+
+ /**
+ * Recursively deep copies `source` properties into `target` with the given `options`.
+ * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
+ * @param {Object} target - The target object in which all sources are merged into.
+ * @param {Object|Array(Object)} source - Object(s) to merge into `target`.
+ * @param {Object} [options] - Merging options:
+ * @param {Function} [options.merger] - The merge method (key, target, source, options)
+ * @returns {Object} The `target` object.
+ */
+ merge: function(target, source, options) {
+ var sources = helpers.isArray(source) ? source : [source];
+ var ilen = sources.length;
+ var merge, i, keys, klen, k;
+
+ if (!helpers.isObject(target)) {
+ return target;
+ }
+
+ options = options || {};
+ merge = options.merger || helpers._merger;
+
+ for (i = 0; i < ilen; ++i) {
+ source = sources[i];
+ if (!helpers.isObject(source)) {
+ continue;
+ }
+
+ keys = Object.keys(source);
+ for (k = 0, klen = keys.length; k < klen; ++k) {
+ merge(keys[k], target, source, options);
+ }
+ }
+
+ return target;
+ },
+
+ /**
+ * Recursively deep copies `source` properties into `target` *only* if not defined in target.
+ * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
+ * @param {Object} target - The target object in which all sources are merged into.
+ * @param {Object|Array(Object)} source - Object(s) to merge into `target`.
+ * @returns {Object} The `target` object.
+ */
+ mergeIf: function(target, source) {
+ return helpers.merge(target, source, {merger: helpers._mergerIf});
+ },
+
+ /**
+ * Applies the contents of two or more objects together into the first object.
+ * @param {Object} target - The target object in which all objects are merged into.
+ * @param {Object} arg1 - Object containing additional properties to merge in target.
+ * @param {Object} argN - Additional objects containing properties to merge in target.
+ * @returns {Object} The `target` object.
+ */
+ extend: function(target) {
+ var setFn = function(value, key) {
+ target[key] = value;
+ };
+ for (var i = 1, ilen = arguments.length; i < ilen; ++i) {
+ helpers.each(arguments[i], setFn);
+ }
+ return target;
+ },
+
+ /**
+ * Basic javascript inheritance based on the model created in Backbone.js
+ */
+ inherits: function(extensions) {
+ var me = this;
+ var ChartElement = (extensions && extensions.hasOwnProperty('constructor')) ? extensions.constructor : function() {
+ return me.apply(this, arguments);
+ };
+
+ var Surrogate = function() {
+ this.constructor = ChartElement;
+ };
+
+ Surrogate.prototype = me.prototype;
+ ChartElement.prototype = new Surrogate();
+ ChartElement.extend = helpers.inherits;
+
+ if (extensions) {
+ helpers.extend(ChartElement.prototype, extensions);
+ }
+
+ ChartElement.__super__ = me.prototype;
+ return ChartElement;
+ }
+};
+
+module.exports = helpers;
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.callback instead.
+ * @function Chart.helpers.callCallback
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.callCallback = helpers.callback;
+
+/**
+ * Provided for backward compatibility, use Array.prototype.indexOf instead.
+ * Array.prototype.indexOf compatibility: Chrome, Opera, Safari, FF1.5+, IE9+
+ * @function Chart.helpers.indexOf
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.indexOf = function(array, item, fromIndex) {
+ return Array.prototype.indexOf.call(array, item, fromIndex);
+};
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.valueOrDefault instead.
+ * @function Chart.helpers.getValueOrDefault
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.getValueOrDefault = helpers.valueOrDefault;
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.valueAtIndexOrDefault instead.
+ * @function Chart.helpers.getValueAtIndexOrDefault
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.getValueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
+
+},{}],43:[function(require,module,exports){
+'use strict';
+
+var helpers = require(42);
+
+/**
+ * Easing functions adapted from Robert Penner's easing equations.
+ * @namespace Chart.helpers.easingEffects
+ * @see http://www.robertpenner.com/easing/
+ */
+var effects = {
+ linear: function(t) {
+ return t;
+ },
+
+ easeInQuad: function(t) {
+ return t * t;
+ },
+
+ easeOutQuad: function(t) {
+ return -t * (t - 2);
+ },
+
+ easeInOutQuad: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t;
+ }
+ return -0.5 * ((--t) * (t - 2) - 1);
+ },
+
+ easeInCubic: function(t) {
+ return t * t * t;
+ },
+
+ easeOutCubic: function(t) {
+ return (t = t - 1) * t * t + 1;
+ },
+
+ easeInOutCubic: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t * t;
+ }
+ return 0.5 * ((t -= 2) * t * t + 2);
+ },
+
+ easeInQuart: function(t) {
+ return t * t * t * t;
+ },
+
+ easeOutQuart: function(t) {
+ return -((t = t - 1) * t * t * t - 1);
+ },
+
+ easeInOutQuart: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t * t * t;
+ }
+ return -0.5 * ((t -= 2) * t * t * t - 2);
+ },
+
+ easeInQuint: function(t) {
+ return t * t * t * t * t;
+ },
+
+ easeOutQuint: function(t) {
+ return (t = t - 1) * t * t * t * t + 1;
+ },
+
+ easeInOutQuint: function(t) {
+ if ((t /= 0.5) < 1) {
+ return 0.5 * t * t * t * t * t;
+ }
+ return 0.5 * ((t -= 2) * t * t * t * t + 2);
+ },
+
+ easeInSine: function(t) {
+ return -Math.cos(t * (Math.PI / 2)) + 1;
+ },
+
+ easeOutSine: function(t) {
+ return Math.sin(t * (Math.PI / 2));
+ },
+
+ easeInOutSine: function(t) {
+ return -0.5 * (Math.cos(Math.PI * t) - 1);
+ },
+
+ easeInExpo: function(t) {
+ return (t === 0) ? 0 : Math.pow(2, 10 * (t - 1));
+ },
+
+ easeOutExpo: function(t) {
+ return (t === 1) ? 1 : -Math.pow(2, -10 * t) + 1;
+ },
+
+ easeInOutExpo: function(t) {
+ if (t === 0) {
+ return 0;
+ }
+ if (t === 1) {
+ return 1;
+ }
+ if ((t /= 0.5) < 1) {
+ return 0.5 * Math.pow(2, 10 * (t - 1));
+ }
+ return 0.5 * (-Math.pow(2, -10 * --t) + 2);
+ },
+
+ easeInCirc: function(t) {
+ if (t >= 1) {
+ return t;
+ }
+ return -(Math.sqrt(1 - t * t) - 1);
+ },
+
+ easeOutCirc: function(t) {
+ return Math.sqrt(1 - (t = t - 1) * t);
+ },
+
+ easeInOutCirc: function(t) {
+ if ((t /= 0.5) < 1) {
+ return -0.5 * (Math.sqrt(1 - t * t) - 1);
+ }
+ return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
+ },
+
+ easeInElastic: function(t) {
+ var s = 1.70158;
+ var p = 0;
+ var a = 1;
+ if (t === 0) {
+ return 0;
+ }
+ if (t === 1) {
+ return 1;
+ }
+ if (!p) {
+ p = 0.3;
+ }
+ if (a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p / (2 * Math.PI) * Math.asin(1 / a);
+ }
+ return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
+ },
+
+ easeOutElastic: function(t) {
+ var s = 1.70158;
+ var p = 0;
+ var a = 1;
+ if (t === 0) {
+ return 0;
+ }
+ if (t === 1) {
+ return 1;
+ }
+ if (!p) {
+ p = 0.3;
+ }
+ if (a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p / (2 * Math.PI) * Math.asin(1 / a);
+ }
+ return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) + 1;
+ },
+
+ easeInOutElastic: function(t) {
+ var s = 1.70158;
+ var p = 0;
+ var a = 1;
+ if (t === 0) {
+ return 0;
+ }
+ if ((t /= 0.5) === 2) {
+ return 1;
+ }
+ if (!p) {
+ p = 0.45;
+ }
+ if (a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p / (2 * Math.PI) * Math.asin(1 / a);
+ }
+ if (t < 1) {
+ return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
+ }
+ return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p) * 0.5 + 1;
+ },
+ easeInBack: function(t) {
+ var s = 1.70158;
+ return t * t * ((s + 1) * t - s);
+ },
+
+ easeOutBack: function(t) {
+ var s = 1.70158;
+ return (t = t - 1) * t * ((s + 1) * t + s) + 1;
+ },
+
+ easeInOutBack: function(t) {
+ var s = 1.70158;
+ if ((t /= 0.5) < 1) {
+ return 0.5 * (t * t * (((s *= (1.525)) + 1) * t - s));
+ }
+ return 0.5 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
+ },
+
+ easeInBounce: function(t) {
+ return 1 - effects.easeOutBounce(1 - t);
+ },
+
+ easeOutBounce: function(t) {
+ if (t < (1 / 2.75)) {
+ return 7.5625 * t * t;
+ }
+ if (t < (2 / 2.75)) {
+ return 7.5625 * (t -= (1.5 / 2.75)) * t + 0.75;
+ }
+ if (t < (2.5 / 2.75)) {
+ return 7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375;
+ }
+ return 7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375;
+ },
+
+ easeInOutBounce: function(t) {
+ if (t < 0.5) {
+ return effects.easeInBounce(t * 2) * 0.5;
+ }
+ return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5;
+ }
+};
+
+module.exports = {
+ effects: effects
+};
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use Chart.helpers.easing.effects instead.
+ * @function Chart.helpers.easingEffects
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.easingEffects = effects;
+
+},{"42":42}],44:[function(require,module,exports){
+'use strict';
+
+var helpers = require(42);
+
+/**
+ * @alias Chart.helpers.options
+ * @namespace
+ */
+module.exports = {
+ /**
+ * Converts the given line height `value` in pixels for a specific font `size`.
+ * @param {Number|String} value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').
+ * @param {Number} size - The font size (in pixels) used to resolve relative `value`.
+ * @returns {Number} The effective line height in pixels (size * 1.2 if value is invalid).
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
+ * @since 2.7.0
+ */
+ toLineHeight: function(value, size) {
+ var matches = ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);
+ if (!matches || matches[1] === 'normal') {
+ return size * 1.2;
+ }
+
+ value = +matches[2];
+
+ switch (matches[3]) {
+ case 'px':
+ return value;
+ case '%':
+ value /= 100;
+ break;
+ default:
+ break;
+ }
+
+ return size * value;
+ },
+
+ /**
+ * Converts the given value into a padding object with pre-computed width/height.
+ * @param {Number|Object} value - If a number, set the value to all TRBL component,
+ * else, if and object, use defined properties and sets undefined ones to 0.
+ * @returns {Object} The padding values (top, right, bottom, left, width, height)
+ * @since 2.7.0
+ */
+ toPadding: function(value) {
+ var t, r, b, l;
+
+ if (helpers.isObject(value)) {
+ t = +value.top || 0;
+ r = +value.right || 0;
+ b = +value.bottom || 0;
+ l = +value.left || 0;
+ } else {
+ t = r = b = l = +value || 0;
+ }
+
+ return {
+ top: t,
+ right: r,
+ bottom: b,
+ left: l,
+ height: t + b,
+ width: l + r
+ };
+ },
+
+ /**
+ * Evaluates the given `inputs` sequentially and returns the first defined value.
+ * @param {Array[]} inputs - An array of values, falling back to the last value.
+ * @param {Object} [context] - If defined and the current value is a function, the value
+ * is called with `context` as first argument and the result becomes the new input.
+ * @param {Number} [index] - If defined and the current value is an array, the value
+ * at `index` become the new input.
+ * @since 2.7.0
+ */
+ resolve: function(inputs, context, index) {
+ var i, ilen, value;
+
+ for (i = 0, ilen = inputs.length; i < ilen; ++i) {
+ value = inputs[i];
+ if (value === undefined) {
+ continue;
+ }
+ if (context !== undefined && typeof value === 'function') {
+ value = value(context);
+ }
+ if (index !== undefined && helpers.isArray(value)) {
+ value = value[index];
+ }
+ if (value !== undefined) {
+ return value;
+ }
+ }
+ }
+};
+
+},{"42":42}],45:[function(require,module,exports){
+'use strict';
+
+module.exports = require(42);
+module.exports.easing = require(43);
+module.exports.canvas = require(41);
+module.exports.options = require(44);
+
+},{"41":41,"42":42,"43":43,"44":44}],46:[function(require,module,exports){
+/**
+ * Platform fallback implementation (minimal).
+ * @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-319575939
+ */
+
+module.exports = {
+ acquireContext: function(item) {
+ if (item && item.canvas) {
+ // Support for any object associated to a canvas (including a context2d)
+ item = item.canvas;
+ }
+
+ return item && item.getContext('2d') || null;
+ }
+};
+
+},{}],47:[function(require,module,exports){
+/**
+ * Chart.Platform implementation for targeting a web browser
+ */
+
+'use strict';
+
+var helpers = require(45);
+
+var EXPANDO_KEY = '$chartjs';
+var CSS_PREFIX = 'chartjs-';
+var CSS_RENDER_MONITOR = CSS_PREFIX + 'render-monitor';
+var CSS_RENDER_ANIMATION = CSS_PREFIX + 'render-animation';
+var ANIMATION_START_EVENTS = ['animationstart', 'webkitAnimationStart'];
+
+/**
+ * DOM event types -> Chart.js event types.
+ * Note: only events with different types are mapped.
+ * @see https://developer.mozilla.org/en-US/docs/Web/Events
+ */
+var EVENT_TYPES = {
+ touchstart: 'mousedown',
+ touchmove: 'mousemove',
+ touchend: 'mouseup',
+ pointerenter: 'mouseenter',
+ pointerdown: 'mousedown',
+ pointermove: 'mousemove',
+ pointerup: 'mouseup',
+ pointerleave: 'mouseout',
+ pointerout: 'mouseout'
+};
+
+/**
+ * The "used" size is the final value of a dimension property after all calculations have
+ * been performed. This method uses the computed style of `element` but returns undefined
+ * if the computed style is not expressed in pixels. That can happen in some cases where
+ * `element` has a size relative to its parent and this last one is not yet displayed,
+ * for example because of `display: none` on a parent node.
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
+ * @returns {Number} Size in pixels or undefined if unknown.
+ */
+function readUsedSize(element, property) {
+ var value = helpers.getStyle(element, property);
+ var matches = value && value.match(/^(\d+)(\.\d+)?px$/);
+ return matches ? Number(matches[1]) : undefined;
+}
+
+/**
+ * Initializes the canvas style and render size without modifying the canvas display size,
+ * since responsiveness is handled by the controller.resize() method. The config is used
+ * to determine the aspect ratio to apply in case no explicit height has been specified.
+ */
+function initCanvas(canvas, config) {
+ var style = canvas.style;
+
+ // NOTE(SB) canvas.getAttribute('width') !== canvas.width: in the first case it
+ // returns null or '' if no explicit value has been set to the canvas attribute.
+ var renderHeight = canvas.getAttribute('height');
+ var renderWidth = canvas.getAttribute('width');
+
+ // Chart.js modifies some canvas values that we want to restore on destroy
+ canvas[EXPANDO_KEY] = {
+ initial: {
+ height: renderHeight,
+ width: renderWidth,
+ style: {
+ display: style.display,
+ height: style.height,
+ width: style.width
+ }
+ }
+ };
+
+ // Force canvas to display as block to avoid extra space caused by inline
+ // elements, which would interfere with the responsive resize process.
+ // https://github.com/chartjs/Chart.js/issues/2538
+ style.display = style.display || 'block';
+
+ if (renderWidth === null || renderWidth === '') {
+ var displayWidth = readUsedSize(canvas, 'width');
+ if (displayWidth !== undefined) {
+ canvas.width = displayWidth;
+ }
+ }
+
+ if (renderHeight === null || renderHeight === '') {
+ if (canvas.style.height === '') {
+ // If no explicit render height and style height, let's apply the aspect ratio,
+ // which one can be specified by the user but also by charts as default option
+ // (i.e. options.aspectRatio). If not specified, use canvas aspect ratio of 2.
+ canvas.height = canvas.width / (config.options.aspectRatio || 2);
+ } else {
+ var displayHeight = readUsedSize(canvas, 'height');
+ if (displayWidth !== undefined) {
+ canvas.height = displayHeight;
+ }
+ }
+ }
+
+ return canvas;
+}
+
+/**
+ * Detects support for options object argument in addEventListener.
+ * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
+ * @private
+ */
+var supportsEventListenerOptions = (function() {
+ var supports = false;
+ try {
+ var options = Object.defineProperty({}, 'passive', {
+ get: function() {
+ supports = true;
+ }
+ });
+ window.addEventListener('e', null, options);
+ } catch (e) {
+ // continue regardless of error
+ }
+ return supports;
+}());
+
+// Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
+// https://github.com/chartjs/Chart.js/issues/4287
+var eventListenerOptions = supportsEventListenerOptions ? {passive: true} : false;
+
+function addEventListener(node, type, listener) {
+ node.addEventListener(type, listener, eventListenerOptions);
+}
+
+function removeEventListener(node, type, listener) {
+ node.removeEventListener(type, listener, eventListenerOptions);
+}
+
+function createEvent(type, chart, x, y, nativeEvent) {
+ return {
+ type: type,
+ chart: chart,
+ native: nativeEvent || null,
+ x: x !== undefined ? x : null,
+ y: y !== undefined ? y : null,
+ };
+}
+
+function fromNativeEvent(event, chart) {
+ var type = EVENT_TYPES[event.type] || event.type;
+ var pos = helpers.getRelativePosition(event, chart);
+ return createEvent(type, chart, pos.x, pos.y, event);
+}
+
+function throttled(fn, thisArg) {
+ var ticking = false;
+ var args = [];
+
+ return function() {
+ args = Array.prototype.slice.call(arguments);
+ thisArg = thisArg || this;
+
+ if (!ticking) {
+ ticking = true;
+ helpers.requestAnimFrame.call(window, function() {
+ ticking = false;
+ fn.apply(thisArg, args);
+ });
+ }
+ };
+}
+
+// Implementation based on https://github.com/marcj/css-element-queries
+function createResizer(handler) {
+ var resizer = document.createElement('div');
+ var cls = CSS_PREFIX + 'size-monitor';
+ var maxSize = 1000000;
+ var style =
+ 'position:absolute;' +
+ 'left:0;' +
+ 'top:0;' +
+ 'right:0;' +
+ 'bottom:0;' +
+ 'overflow:hidden;' +
+ 'pointer-events:none;' +
+ 'visibility:hidden;' +
+ 'z-index:-1;';
+
+ resizer.style.cssText = style;
+ resizer.className = cls;
+ resizer.innerHTML =
+ '<div class="' + cls + '-expand" style="' + style + '">' +
+ '<div style="' +
+ 'position:absolute;' +
+ 'width:' + maxSize + 'px;' +
+ 'height:' + maxSize + 'px;' +
+ 'left:0;' +
+ 'top:0">' +
+ '</div>' +
+ '</div>' +
+ '<div class="' + cls + '-shrink" style="' + style + '">' +
+ '<div style="' +
+ 'position:absolute;' +
+ 'width:200%;' +
+ 'height:200%;' +
+ 'left:0; ' +
+ 'top:0">' +
+ '</div>' +
+ '</div>';
+
+ var expand = resizer.childNodes[0];
+ var shrink = resizer.childNodes[1];
+
+ resizer._reset = function() {
+ expand.scrollLeft = maxSize;
+ expand.scrollTop = maxSize;
+ shrink.scrollLeft = maxSize;
+ shrink.scrollTop = maxSize;
+ };
+ var onScroll = function() {
+ resizer._reset();
+ handler();
+ };
+
+ addEventListener(expand, 'scroll', onScroll.bind(expand, 'expand'));
+ addEventListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink'));
+
+ return resizer;
+}
+
+// https://davidwalsh.name/detect-node-insertion
+function watchForRender(node, handler) {
+ var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
+ var proxy = expando.renderProxy = function(e) {
+ if (e.animationName === CSS_RENDER_ANIMATION) {
+ handler();
+ }
+ };
+
+ helpers.each(ANIMATION_START_EVENTS, function(type) {
+ addEventListener(node, type, proxy);
+ });
+
+ // #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR class
+ // is removed then added back immediately (same animation frame?). Accessing the
+ // `offsetParent` property will force a reflow and re-evaluate the CSS animation.
+ // https://gist.github.com/paulirish/5d52fb081b3570c81e3a#box-metrics
+ // https://github.com/chartjs/Chart.js/issues/4737
+ expando.reflow = !!node.offsetParent;
+
+ node.classList.add(CSS_RENDER_MONITOR);
+}
+
+function unwatchForRender(node) {
+ var expando = node[EXPANDO_KEY] || {};
+ var proxy = expando.renderProxy;
+
+ if (proxy) {
+ helpers.each(ANIMATION_START_EVENTS, function(type) {
+ removeEventListener(node, type, proxy);
+ });
+
+ delete expando.renderProxy;
+ }
+
+ node.classList.remove(CSS_RENDER_MONITOR);
+}
+
+function addResizeListener(node, listener, chart) {
+ var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
+
+ // Let's keep track of this added resizer and thus avoid DOM query when removing it.
+ var resizer = expando.resizer = createResizer(throttled(function() {
+ if (expando.resizer) {
+ return listener(createEvent('resize', chart));
+ }
+ }));
+
+ // The resizer needs to be attached to the node parent, so we first need to be
+ // sure that `node` is attached to the DOM before injecting the resizer element.
+ watchForRender(node, function() {
+ if (expando.resizer) {
+ var container = node.parentNode;
+ if (container && container !== resizer.parentNode) {
+ container.insertBefore(resizer, container.firstChild);
+ }
+
+ // The container size might have changed, let's reset the resizer state.
+ resizer._reset();
+ }
+ });
+}
+
+function removeResizeListener(node) {
+ var expando = node[EXPANDO_KEY] || {};
+ var resizer = expando.resizer;
+
+ delete expando.resizer;
+ unwatchForRender(node);
+
+ if (resizer && resizer.parentNode) {
+ resizer.parentNode.removeChild(resizer);
+ }
+}
+
+function injectCSS(platform, css) {
+ // http://stackoverflow.com/q/3922139
+ var style = platform._style || document.createElement('style');
+ if (!platform._style) {
+ platform._style = style;
+ css = '/* Chart.js */\n' + css;
+ style.setAttribute('type', 'text/css');
+ document.getElementsByTagName('head')[0].appendChild(style);
+ }
+
+ style.appendChild(document.createTextNode(css));
+}
+
+module.exports = {
+ /**
+ * This property holds whether this platform is enabled for the current environment.
+ * Currently used by platform.js to select the proper implementation.
+ * @private
+ */
+ _enabled: typeof window !== 'undefined' && typeof document !== 'undefined',
+
+ initialize: function() {
+ var keyframes = 'from{opacity:0.99}to{opacity:1}';
+
+ injectCSS(this,
+ // DOM rendering detection
+ // https://davidwalsh.name/detect-node-insertion
+ '@-webkit-keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
+ '@keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
+ '.' + CSS_RENDER_MONITOR + '{' +
+ '-webkit-animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
+ 'animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
+ '}'
+ );
+ },
+
+ acquireContext: function(item, config) {
+ if (typeof item === 'string') {
+ item = document.getElementById(item);
+ } else if (item.length) {
+ // Support for array based queries (such as jQuery)
+ item = item[0];
+ }
+
+ if (item && item.canvas) {
+ // Support for any object associated to a canvas (including a context2d)
+ item = item.canvas;
+ }
+
+ // To prevent canvas fingerprinting, some add-ons undefine the getContext
+ // method, for example: https://github.com/kkapsner/CanvasBlocker
+ // https://github.com/chartjs/Chart.js/issues/2807
+ var context = item && item.getContext && item.getContext('2d');
+
+ // `instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when the item is
+ // inside an iframe or when running in a protected environment. We could guess the
+ // types from their toString() value but let's keep things flexible and assume it's
+ // a sufficient condition if the item has a context2D which has item as `canvas`.
+ // https://github.com/chartjs/Chart.js/issues/3887
+ // https://github.com/chartjs/Chart.js/issues/4102
+ // https://github.com/chartjs/Chart.js/issues/4152
+ if (context && context.canvas === item) {
+ initCanvas(item, config);
+ return context;
+ }
+
+ return null;
+ },
+
+ releaseContext: function(context) {
+ var canvas = context.canvas;
+ if (!canvas[EXPANDO_KEY]) {
+ return;
+ }
+
+ var initial = canvas[EXPANDO_KEY].initial;
+ ['height', 'width'].forEach(function(prop) {
+ var value = initial[prop];
+ if (helpers.isNullOrUndef(value)) {
+ canvas.removeAttribute(prop);
+ } else {
+ canvas.setAttribute(prop, value);
+ }
+ });
+
+ helpers.each(initial.style || {}, function(value, key) {
+ canvas.style[key] = value;
+ });
+
+ // The canvas render size might have been changed (and thus the state stack discarded),
+ // we can't use save() and restore() to restore the initial state. So make sure that at
+ // least the canvas context is reset to the default state by setting the canvas width.
+ // https://www.w3.org/TR/2011/WD-html5-20110525/the-canvas-element.html
+ canvas.width = canvas.width;
+
+ delete canvas[EXPANDO_KEY];
+ },
+
+ addEventListener: function(chart, type, listener) {
+ var canvas = chart.canvas;
+ if (type === 'resize') {
+ // Note: the resize event is not supported on all browsers.
+ addResizeListener(canvas, listener, chart);
+ return;
+ }
+
+ var expando = listener[EXPANDO_KEY] || (listener[EXPANDO_KEY] = {});
+ var proxies = expando.proxies || (expando.proxies = {});
+ var proxy = proxies[chart.id + '_' + type] = function(event) {
+ listener(fromNativeEvent(event, chart));
+ };
+
+ addEventListener(canvas, type, proxy);
+ },
+
+ removeEventListener: function(chart, type, listener) {
+ var canvas = chart.canvas;
+ if (type === 'resize') {
+ // Note: the resize event is not supported on all browsers.
+ removeResizeListener(canvas, listener);
+ return;
+ }
+
+ var expando = listener[EXPANDO_KEY] || {};
+ var proxies = expando.proxies || {};
+ var proxy = proxies[chart.id + '_' + type];
+ if (!proxy) {
+ return;
+ }
+
+ removeEventListener(canvas, type, proxy);
+ }
+};
+
+// DEPRECATIONS
+
+/**
+ * Provided for backward compatibility, use EventTarget.addEventListener instead.
+ * EventTarget.addEventListener compatibility: Chrome, Opera 7, Safari, FF1.5+, IE9+
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
+ * @function Chart.helpers.addEvent
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.addEvent = addEventListener;
+
+/**
+ * Provided for backward compatibility, use EventTarget.removeEventListener instead.
+ * EventTarget.removeEventListener compatibility: Chrome, Opera 7, Safari, FF1.5+, IE9+
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
+ * @function Chart.helpers.removeEvent
+ * @deprecated since version 2.7.0
+ * @todo remove at version 3
+ * @private
+ */
+helpers.removeEvent = removeEventListener;
+
+},{"45":45}],48:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+var basic = require(46);
+var dom = require(47);
+
+// @TODO Make possible to select another platform at build time.
+var implementation = dom._enabled ? dom : basic;
+
+/**
+ * @namespace Chart.platform
+ * @see https://chartjs.gitbooks.io/proposals/content/Platform.html
+ * @since 2.4.0
+ */
+module.exports = helpers.extend({
+ /**
+ * @since 2.7.0
+ */
+ initialize: function() {},
+
+ /**
+ * Called at chart construction time, returns a context2d instance implementing
+ * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
+ * @param {*} item - The native item from which to acquire context (platform specific)
+ * @param {Object} options - The chart options
+ * @returns {CanvasRenderingContext2D} context2d instance
+ */
+ acquireContext: function() {},
+
+ /**
+ * Called at chart destruction time, releases any resources associated to the context
+ * previously returned by the acquireContext() method.
+ * @param {CanvasRenderingContext2D} context - The context2d instance
+ * @returns {Boolean} true if the method succeeded, else false
+ */
+ releaseContext: function() {},
+
+ /**
+ * Registers the specified listener on the given chart.
+ * @param {Chart} chart - Chart from which to listen for event
+ * @param {String} type - The ({@link IEvent}) type to listen for
+ * @param {Function} listener - Receives a notification (an object that implements
+ * the {@link IEvent} interface) when an event of the specified type occurs.
+ */
+ addEventListener: function() {},
+
+ /**
+ * Removes the specified listener previously registered with addEventListener.
+ * @param {Chart} chart -Chart from which to remove the listener
+ * @param {String} type - The ({@link IEvent}) type to remove
+ * @param {Function} listener - The listener function to remove from the event target.
+ */
+ removeEventListener: function() {}
+
+}, implementation);
+
+/**
+ * @interface IPlatform
+ * Allows abstracting platform dependencies away from the chart
+ * @borrows Chart.platform.acquireContext as acquireContext
+ * @borrows Chart.platform.releaseContext as releaseContext
+ * @borrows Chart.platform.addEventListener as addEventListener
+ * @borrows Chart.platform.removeEventListener as removeEventListener
+ */
+
+/**
+ * @interface IEvent
+ * @prop {String} type - The event type name, possible values are:
+ * 'contextmenu', 'mouseenter', 'mousedown', 'mousemove', 'mouseup', 'mouseout',
+ * 'click', 'dblclick', 'keydown', 'keypress', 'keyup' and 'resize'
+ * @prop {*} native - The original native event (null for emulated events, e.g. 'resize')
+ * @prop {Number} x - The mouse x position, relative to the canvas (null for incompatible events)
+ * @prop {Number} y - The mouse y position, relative to the canvas (null for incompatible events)
+ */
+
+},{"45":45,"46":46,"47":47}],49:[function(require,module,exports){
+/**
+ * Plugin based on discussion from the following Chart.js issues:
+ * @see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
+ * @see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897
+ */
+
+'use strict';
+
+var defaults = require(25);
+var elements = require(40);
+var helpers = require(45);
+
+defaults._set('global', {
+ plugins: {
+ filler: {
+ propagate: true
+ }
+ }
+});
+
+module.exports = function() {
+
+ var mappers = {
+ dataset: function(source) {
+ var index = source.fill;
+ var chart = source.chart;
+ var meta = chart.getDatasetMeta(index);
+ var visible = meta && chart.isDatasetVisible(index);
+ var points = (visible && meta.dataset._children) || [];
+ var length = points.length || 0;
+
+ return !length ? null : function(point, i) {
+ return (i < length && points[i]._view) || null;
+ };
+ },
+
+ boundary: function(source) {
+ var boundary = source.boundary;
+ var x = boundary ? boundary.x : null;
+ var y = boundary ? boundary.y : null;
+
+ return function(point) {
+ return {
+ x: x === null ? point.x : x,
+ y: y === null ? point.y : y,
+ };
+ };
+ }
+ };
+
+ // @todo if (fill[0] === '#')
+ function decodeFill(el, index, count) {
+ var model = el._model || {};
+ var fill = model.fill;
+ var target;
+
+ if (fill === undefined) {
+ fill = !!model.backgroundColor;
+ }
+
+ if (fill === false || fill === null) {
+ return false;
+ }
+
+ if (fill === true) {
+ return 'origin';
+ }
+
+ target = parseFloat(fill, 10);
+ if (isFinite(target) && Math.floor(target) === target) {
+ if (fill[0] === '-' || fill[0] === '+') {
+ target = index + target;
+ }
+
+ if (target === index || target < 0 || target >= count) {
+ return false;
+ }
+
+ return target;
+ }
+
+ switch (fill) {
+ // compatibility
+ case 'bottom':
+ return 'start';
+ case 'top':
+ return 'end';
+ case 'zero':
+ return 'origin';
+ // supported boundaries
+ case 'origin':
+ case 'start':
+ case 'end':
+ return fill;
+ // invalid fill values
+ default:
+ return false;
+ }
+ }
+
+ function computeBoundary(source) {
+ var model = source.el._model || {};
+ var scale = source.el._scale || {};
+ var fill = source.fill;
+ var target = null;
+ var horizontal;
+
+ if (isFinite(fill)) {
+ return null;
+ }
+
+ // Backward compatibility: until v3, we still need to support boundary values set on
+ // the model (scaleTop, scaleBottom and scaleZero) because some external plugins and
+ // controllers might still use it (e.g. the Smith chart).
+
+ if (fill === 'start') {
+ target = model.scaleBottom === undefined ? scale.bottom : model.scaleBottom;
+ } else if (fill === 'end') {
+ target = model.scaleTop === undefined ? scale.top : model.scaleTop;
+ } else if (model.scaleZero !== undefined) {
+ target = model.scaleZero;
+ } else if (scale.getBasePosition) {
+ target = scale.getBasePosition();
+ } else if (scale.getBasePixel) {
+ target = scale.getBasePixel();
+ }
+
+ if (target !== undefined && target !== null) {
+ if (target.x !== undefined && target.y !== undefined) {
+ return target;
+ }
+
+ if (typeof target === 'number' && isFinite(target)) {
+ horizontal = scale.isHorizontal();
+ return {
+ x: horizontal ? target : null,
+ y: horizontal ? null : target
+ };
+ }
+ }
+
+ return null;
+ }
+
+ function resolveTarget(sources, index, propagate) {
+ var source = sources[index];
+ var fill = source.fill;
+ var visited = [index];
+ var target;
+
+ if (!propagate) {
+ return fill;
+ }
+
+ while (fill !== false && visited.indexOf(fill) === -1) {
+ if (!isFinite(fill)) {
+ return fill;
+ }
+
+ target = sources[fill];
+ if (!target) {
+ return false;
+ }
+
+ if (target.visible) {
+ return fill;
+ }
+
+ visited.push(fill);
+ fill = target.fill;
+ }
+
+ return false;
+ }
+
+ function createMapper(source) {
+ var fill = source.fill;
+ var type = 'dataset';
+
+ if (fill === false) {
+ return null;
+ }
+
+ if (!isFinite(fill)) {
+ type = 'boundary';
+ }
+
+ return mappers[type](source);
+ }
+
+ function isDrawable(point) {
+ return point && !point.skip;
+ }
+
+ function drawArea(ctx, curve0, curve1, len0, len1) {
+ var i;
+
+ if (!len0 || !len1) {
+ return;
+ }
+
+ // building first area curve (normal)
+ ctx.moveTo(curve0[0].x, curve0[0].y);
+ for (i = 1; i < len0; ++i) {
+ helpers.canvas.lineTo(ctx, curve0[i - 1], curve0[i]);
+ }
+
+ // joining the two area curves
+ ctx.lineTo(curve1[len1 - 1].x, curve1[len1 - 1].y);
+
+ // building opposite area curve (reverse)
+ for (i = len1 - 1; i > 0; --i) {
+ helpers.canvas.lineTo(ctx, curve1[i], curve1[i - 1], true);
+ }
+ }
+
+ function doFill(ctx, points, mapper, view, color, loop) {
+ var count = points.length;
+ var span = view.spanGaps;
+ var curve0 = [];
+ var curve1 = [];
+ var len0 = 0;
+ var len1 = 0;
+ var i, ilen, index, p0, p1, d0, d1;
+
+ ctx.beginPath();
+
+ for (i = 0, ilen = (count + !!loop); i < ilen; ++i) {
+ index = i % count;
+ p0 = points[index]._view;
+ p1 = mapper(p0, index, view);
+ d0 = isDrawable(p0);
+ d1 = isDrawable(p1);
+
+ if (d0 && d1) {
+ len0 = curve0.push(p0);
+ len1 = curve1.push(p1);
+ } else if (len0 && len1) {
+ if (!span) {
+ drawArea(ctx, curve0, curve1, len0, len1);
+ len0 = len1 = 0;
+ curve0 = [];
+ curve1 = [];
+ } else {
+ if (d0) {
+ curve0.push(p0);
+ }
+ if (d1) {
+ curve1.push(p1);
+ }
+ }
+ }
+ }
+
+ drawArea(ctx, curve0, curve1, len0, len1);
+
+ ctx.closePath();
+ ctx.fillStyle = color;
+ ctx.fill();
+ }
+
+ return {
+ id: 'filler',
+
+ afterDatasetsUpdate: function(chart, options) {
+ var count = (chart.data.datasets || []).length;
+ var propagate = options.propagate;
+ var sources = [];
+ var meta, i, el, source;
+
+ for (i = 0; i < count; ++i) {
+ meta = chart.getDatasetMeta(i);
+ el = meta.dataset;
+ source = null;
+
+ if (el && el._model && el instanceof elements.Line) {
+ source = {
+ visible: chart.isDatasetVisible(i),
+ fill: decodeFill(el, i, count),
+ chart: chart,
+ el: el
+ };
+ }
+
+ meta.$filler = source;
+ sources.push(source);
+ }
+
+ for (i = 0; i < count; ++i) {
+ source = sources[i];
+ if (!source) {
+ continue;
+ }
+
+ source.fill = resolveTarget(sources, i, propagate);
+ source.boundary = computeBoundary(source);
+ source.mapper = createMapper(source);
+ }
+ },
+
+ beforeDatasetDraw: function(chart, args) {
+ var meta = args.meta.$filler;
+ if (!meta) {
+ return;
+ }
+
+ var ctx = chart.ctx;
+ var el = meta.el;
+ var view = el._view;
+ var points = el._children || [];
+ var mapper = meta.mapper;
+ var color = view.backgroundColor || defaults.global.defaultColor;
+
+ if (mapper && color && points.length) {
+ helpers.canvas.clipArea(ctx, chart.chartArea);
+ doFill(ctx, points, mapper, view, color, el._loop);
+ helpers.canvas.unclipArea(ctx);
+ }
+ }
+ };
+};
+
+},{"25":25,"40":40,"45":45}],50:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ legend: {
+ display: true,
+ position: 'top',
+ fullWidth: true,
+ reverse: false,
+ weight: 1000,
+
+ // a callback that will handle
+ onClick: function(e, legendItem) {
+ var index = legendItem.datasetIndex;
+ var ci = this.chart;
+ var meta = ci.getDatasetMeta(index);
+
+ // See controller.isDatasetVisible comment
+ meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
+
+ // We hid a dataset ... rerender the chart
+ ci.update();
+ },
+
+ onHover: null,
+
+ labels: {
+ boxWidth: 40,
+ padding: 10,
+ // Generates labels shown in the legend
+ // Valid properties to return:
+ // text : text to display
+ // fillStyle : fill of coloured box
+ // strokeStyle: stroke of coloured box
+ // hidden : if this legend item refers to a hidden item
+ // lineCap : cap style for line
+ // lineDash
+ // lineDashOffset :
+ // lineJoin :
+ // lineWidth :
+ generateLabels: function(chart) {
+ var data = chart.data;
+ return helpers.isArray(data.datasets) ? data.datasets.map(function(dataset, i) {
+ return {
+ text: dataset.label,
+ fillStyle: (!helpers.isArray(dataset.backgroundColor) ? dataset.backgroundColor : dataset.backgroundColor[0]),
+ hidden: !chart.isDatasetVisible(i),
+ lineCap: dataset.borderCapStyle,
+ lineDash: dataset.borderDash,
+ lineDashOffset: dataset.borderDashOffset,
+ lineJoin: dataset.borderJoinStyle,
+ lineWidth: dataset.borderWidth,
+ strokeStyle: dataset.borderColor,
+ pointStyle: dataset.pointStyle,
+
+ // Below is extra data used for toggling the datasets
+ datasetIndex: i
+ };
+ }, this) : [];
+ }
+ }
+ },
+
+ legendCallback: function(chart) {
+ var text = [];
+ text.push('<ul class="' + chart.id + '-legend">');
+ for (var i = 0; i < chart.data.datasets.length; i++) {
+ text.push('<li><span style="background-color:' + chart.data.datasets[i].backgroundColor + '"></span>');
+ if (chart.data.datasets[i].label) {
+ text.push(chart.data.datasets[i].label);
+ }
+ text.push('</li>');
+ }
+ text.push('</ul>');
+ return text.join('');
+ }
+});
+
+module.exports = function(Chart) {
+
+ var layout = Chart.layoutService;
+ var noop = helpers.noop;
+
+ /**
+ * Helper function to get the box width based on the usePointStyle option
+ * @param labelopts {Object} the label options on the legend
+ * @param fontSize {Number} the label font size
+ * @return {Number} width of the color box area
+ */
+ function getBoxWidth(labelOpts, fontSize) {
+ return labelOpts.usePointStyle ?
+ fontSize * Math.SQRT2 :
+ labelOpts.boxWidth;
+ }
+
+ Chart.Legend = Element.extend({
+
+ initialize: function(config) {
+ helpers.extend(this, config);
+
+ // Contains hit boxes for each dataset (in dataset order)
+ this.legendHitBoxes = [];
+
+ // Are we in doughnut mode which has a different data type
+ this.doughnutMode = false;
+ },
+
+ // These methods are ordered by lifecycle. Utilities then follow.
+ // Any function defined here is inherited by all legend types.
+ // Any function can be extended by the legend type
+
+ beforeUpdate: noop,
+ update: function(maxWidth, maxHeight, margins) {
+ var me = this;
+
+ // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
+ me.beforeUpdate();
+
+ // Absorb the master measurements
+ me.maxWidth = maxWidth;
+ me.maxHeight = maxHeight;
+ me.margins = margins;
+
+ // Dimensions
+ me.beforeSetDimensions();
+ me.setDimensions();
+ me.afterSetDimensions();
+ // Labels
+ me.beforeBuildLabels();
+ me.buildLabels();
+ me.afterBuildLabels();
+
+ // Fit
+ me.beforeFit();
+ me.fit();
+ me.afterFit();
+ //
+ me.afterUpdate();
+
+ return me.minSize;
+ },
+ afterUpdate: noop,
+
+ //
+
+ beforeSetDimensions: noop,
+ setDimensions: function() {
+ var me = this;
+ // Set the unconstrained dimension before label rotation
+ if (me.isHorizontal()) {
+ // Reset position before calculating rotation
+ me.width = me.maxWidth;
+ me.left = 0;
+ me.right = me.width;
+ } else {
+ me.height = me.maxHeight;
+
+ // Reset position before calculating rotation
+ me.top = 0;
+ me.bottom = me.height;
+ }
+
+ // Reset padding
+ me.paddingLeft = 0;
+ me.paddingTop = 0;
+ me.paddingRight = 0;
+ me.paddingBottom = 0;
+
+ // Reset minSize
+ me.minSize = {
+ width: 0,
+ height: 0
+ };
+ },
+ afterSetDimensions: noop,
+
+ //
+
+ beforeBuildLabels: noop,
+ buildLabels: function() {
+ var me = this;
+ var labelOpts = me.options.labels || {};
+ var legendItems = helpers.callback(labelOpts.generateLabels, [me.chart], me) || [];
+
+ if (labelOpts.filter) {
+ legendItems = legendItems.filter(function(item) {
+ return labelOpts.filter(item, me.chart.data);
+ });
+ }
+
+ if (me.options.reverse) {
+ legendItems.reverse();
+ }
+
+ me.legendItems = legendItems;
+ },
+ afterBuildLabels: noop,
+
+ //
+
+ beforeFit: noop,
+ fit: function() {
+ var me = this;
+ var opts = me.options;
+ var labelOpts = opts.labels;
+ var display = opts.display;
+
+ var ctx = me.ctx;
+
+ var globalDefault = defaults.global;
+ var valueOrDefault = helpers.valueOrDefault;
+ var fontSize = valueOrDefault(labelOpts.fontSize, globalDefault.defaultFontSize);
+ var fontStyle = valueOrDefault(labelOpts.fontStyle, globalDefault.defaultFontStyle);
+ var fontFamily = valueOrDefault(labelOpts.fontFamily, globalDefault.defaultFontFamily);
+ var labelFont = helpers.fontString(fontSize, fontStyle, fontFamily);
+
+ // Reset hit boxes
+ var hitboxes = me.legendHitBoxes = [];
+
+ var minSize = me.minSize;
+ var isHorizontal = me.isHorizontal();
+
+ if (isHorizontal) {
+ minSize.width = me.maxWidth; // fill all the width
+ minSize.height = display ? 10 : 0;
+ } else {
+ minSize.width = display ? 10 : 0;
+ minSize.height = me.maxHeight; // fill all the height
+ }
+
+ // Increase sizes here
+ if (display) {
+ ctx.font = labelFont;
+
+ if (isHorizontal) {
+ // Labels
+
+ // Width of each line of legend boxes. Labels wrap onto multiple lines when there are too many to fit on one
+ var lineWidths = me.lineWidths = [0];
+ var totalHeight = me.legendItems.length ? fontSize + (labelOpts.padding) : 0;
+
+ ctx.textAlign = 'left';
+ ctx.textBaseline = 'top';
+
+ helpers.each(me.legendItems, function(legendItem, i) {
+ var boxWidth = getBoxWidth(labelOpts, fontSize);
+ var width = boxWidth + (fontSize / 2) + ctx.measureText(legendItem.text).width;
+
+ if (lineWidths[lineWidths.length - 1] + width + labelOpts.padding >= me.width) {
+ totalHeight += fontSize + (labelOpts.padding);
+ lineWidths[lineWidths.length] = me.left;
+ }
+
+ // Store the hitbox width and height here. Final position will be updated in `draw`
+ hitboxes[i] = {
+ left: 0,
+ top: 0,
+ width: width,
+ height: fontSize
+ };
+
+ lineWidths[lineWidths.length - 1] += width + labelOpts.padding;
+ });
+
+ minSize.height += totalHeight;
+
+ } else {
+ var vPadding = labelOpts.padding;
+ var columnWidths = me.columnWidths = [];
+ var totalWidth = labelOpts.padding;
+ var currentColWidth = 0;
+ var currentColHeight = 0;
+ var itemHeight = fontSize + vPadding;
+
+ helpers.each(me.legendItems, function(legendItem, i) {
+ var boxWidth = getBoxWidth(labelOpts, fontSize);
+ var itemWidth = boxWidth + (fontSize / 2) + ctx.measureText(legendItem.text).width;
+
+ // If too tall, go to new column
+ if (currentColHeight + itemHeight > minSize.height) {
+ totalWidth += currentColWidth + labelOpts.padding;
+ columnWidths.push(currentColWidth); // previous column width
+
+ currentColWidth = 0;
+ currentColHeight = 0;
+ }
+
+ // Get max width
+ currentColWidth = Math.max(currentColWidth, itemWidth);
+ currentColHeight += itemHeight;
+
+ // Store the hitbox width and height here. Final position will be updated in `draw`
+ hitboxes[i] = {
+ left: 0,
+ top: 0,
+ width: itemWidth,
+ height: fontSize
+ };
+ });
+
+ totalWidth += currentColWidth;
+ columnWidths.push(currentColWidth);
+ minSize.width += totalWidth;
+ }
+ }
+
+ me.width = minSize.width;
+ me.height = minSize.height;
+ },
+ afterFit: noop,
+
+ // Shared Methods
+ isHorizontal: function() {
+ return this.options.position === 'top' || this.options.position === 'bottom';
+ },
+
+ // Actually draw the legend on the canvas
+ draw: function() {
+ var me = this;
+ var opts = me.options;
+ var labelOpts = opts.labels;
+ var globalDefault = defaults.global;
+ var lineDefault = globalDefault.elements.line;
+ var legendWidth = me.width;
+ var lineWidths = me.lineWidths;
+
+ if (opts.display) {
+ var ctx = me.ctx;
+ var valueOrDefault = helpers.valueOrDefault;
+ var fontColor = valueOrDefault(labelOpts.fontColor, globalDefault.defaultFontColor);
+ var fontSize = valueOrDefault(labelOpts.fontSize, globalDefault.defaultFontSize);
+ var fontStyle = valueOrDefault(labelOpts.fontStyle, globalDefault.defaultFontStyle);
+ var fontFamily = valueOrDefault(labelOpts.fontFamily, globalDefault.defaultFontFamily);
+ var labelFont = helpers.fontString(fontSize, fontStyle, fontFamily);
+ var cursor;
+
+ // Canvas setup
+ ctx.textAlign = 'left';
+ ctx.textBaseline = 'middle';
+ ctx.lineWidth = 0.5;
+ ctx.strokeStyle = fontColor; // for strikethrough effect
+ ctx.fillStyle = fontColor; // render in correct colour
+ ctx.font = labelFont;
+
+ var boxWidth = getBoxWidth(labelOpts, fontSize);
+ var hitboxes = me.legendHitBoxes;
+
+ // current position
+ var drawLegendBox = function(x, y, legendItem) {
+ if (isNaN(boxWidth) || boxWidth <= 0) {
+ return;
+ }
+
+ // Set the ctx for the box
+ ctx.save();
+
+ ctx.fillStyle = valueOrDefault(legendItem.fillStyle, globalDefault.defaultColor);
+ ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle);
+ ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset);
+ ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle);
+ ctx.lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth);
+ ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, globalDefault.defaultColor);
+ var isLineWidthZero = (valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth) === 0);
+
+ if (ctx.setLineDash) {
+ // IE 9 and 10 do not support line dash
+ ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash));
+ }
+
+ if (opts.labels && opts.labels.usePointStyle) {
+ // Recalculate x and y for drawPoint() because its expecting
+ // x and y to be center of figure (instead of top left)
+ var radius = fontSize * Math.SQRT2 / 2;
+ var offSet = radius / Math.SQRT2;
+ var centerX = x + offSet;
+ var centerY = y + offSet;
+
+ // Draw pointStyle as legend symbol
+ helpers.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY);
+ } else {
+ // Draw box as legend symbol
+ if (!isLineWidthZero) {
+ ctx.strokeRect(x, y, boxWidth, fontSize);
+ }
+ ctx.fillRect(x, y, boxWidth, fontSize);
+ }
+
+ ctx.restore();
+ };
+ var fillText = function(x, y, legendItem, textWidth) {
+ var halfFontSize = fontSize / 2;
+ var xLeft = boxWidth + halfFontSize + x;
+ var yMiddle = y + halfFontSize;
+
+ ctx.fillText(legendItem.text, xLeft, yMiddle);
+
+ if (legendItem.hidden) {
+ // Strikethrough the text if hidden
+ ctx.beginPath();
+ ctx.lineWidth = 2;
+ ctx.moveTo(xLeft, yMiddle);
+ ctx.lineTo(xLeft + textWidth, yMiddle);
+ ctx.stroke();
+ }
+ };
+
+ // Horizontal
+ var isHorizontal = me.isHorizontal();
+ if (isHorizontal) {
+ cursor = {
+ x: me.left + ((legendWidth - lineWidths[0]) / 2),
+ y: me.top + labelOpts.padding,
+ line: 0
+ };
+ } else {
+ cursor = {
+ x: me.left + labelOpts.padding,
+ y: me.top + labelOpts.padding,
+ line: 0
+ };
+ }
+
+ var itemHeight = fontSize + labelOpts.padding;
+ helpers.each(me.legendItems, function(legendItem, i) {
+ var textWidth = ctx.measureText(legendItem.text).width;
+ var width = boxWidth + (fontSize / 2) + textWidth;
+ var x = cursor.x;
+ var y = cursor.y;
+
+ if (isHorizontal) {
+ if (x + width >= legendWidth) {
+ y = cursor.y += itemHeight;
+ cursor.line++;
+ x = cursor.x = me.left + ((legendWidth - lineWidths[cursor.line]) / 2);
+ }
+ } else if (y + itemHeight > me.bottom) {
+ x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding;
+ y = cursor.y = me.top + labelOpts.padding;
+ cursor.line++;
+ }
+
+ drawLegendBox(x, y, legendItem);
+
+ hitboxes[i].left = x;
+ hitboxes[i].top = y;
+
+ // Fill the actual label
+ fillText(x, y, legendItem, textWidth);
+
+ if (isHorizontal) {
+ cursor.x += width + (labelOpts.padding);
+ } else {
+ cursor.y += itemHeight;
+ }
+
+ });
+ }
+ },
+
+ /**
+ * Handle an event
+ * @private
+ * @param {IEvent} event - The event to handle
+ * @return {Boolean} true if a change occured
+ */
+ handleEvent: function(e) {
+ var me = this;
+ var opts = me.options;
+ var type = e.type === 'mouseup' ? 'click' : e.type;
+ var changed = false;
+
+ if (type === 'mousemove') {
+ if (!opts.onHover) {
+ return;
+ }
+ } else if (type === 'click') {
+ if (!opts.onClick) {
+ return;
+ }
+ } else {
+ return;
+ }
+
+ // Chart event already has relative position in it
+ var x = e.x;
+ var y = e.y;
+
+ if (x >= me.left && x <= me.right && y >= me.top && y <= me.bottom) {
+ // See if we are touching one of the dataset boxes
+ var lh = me.legendHitBoxes;
+ for (var i = 0; i < lh.length; ++i) {
+ var hitBox = lh[i];
+
+ if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) {
+ // Touching an element
+ if (type === 'click') {
+ // use e.native for backwards compatibility
+ opts.onClick.call(me, e.native, me.legendItems[i]);
+ changed = true;
+ break;
+ } else if (type === 'mousemove') {
+ // use e.native for backwards compatibility
+ opts.onHover.call(me, e.native, me.legendItems[i]);
+ changed = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return changed;
+ }
+ });
+
+ function createNewLegendAndAttach(chart, legendOpts) {
+ var legend = new Chart.Legend({
+ ctx: chart.ctx,
+ options: legendOpts,
+ chart: chart
+ });
+
+ layout.configure(chart, legend, legendOpts);
+ layout.addBox(chart, legend);
+ chart.legend = legend;
+ }
+
+ return {
+ id: 'legend',
+
+ beforeInit: function(chart) {
+ var legendOpts = chart.options.legend;
+
+ if (legendOpts) {
+ createNewLegendAndAttach(chart, legendOpts);
+ }
+ },
+
+ beforeUpdate: function(chart) {
+ var legendOpts = chart.options.legend;
+ var legend = chart.legend;
+
+ if (legendOpts) {
+ helpers.mergeIf(legendOpts, defaults.global.legend);
+
+ if (legend) {
+ layout.configure(chart, legend, legendOpts);
+ legend.options = legendOpts;
+ } else {
+ createNewLegendAndAttach(chart, legendOpts);
+ }
+ } else if (legend) {
+ layout.removeBox(chart, legend);
+ delete chart.legend;
+ }
+ },
+
+ afterEvent: function(chart, e) {
+ var legend = chart.legend;
+ if (legend) {
+ legend.handleEvent(e);
+ }
+ }
+ };
+};
+
+},{"25":25,"26":26,"45":45}],51:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var Element = require(26);
+var helpers = require(45);
+
+defaults._set('global', {
+ title: {
+ display: false,
+ fontStyle: 'bold',
+ fullWidth: true,
+ lineHeight: 1.2,
+ padding: 10,
+ position: 'top',
+ text: '',
+ weight: 2000 // by default greater than legend (1000) to be above
+ }
+});
+
+module.exports = function(Chart) {
+
+ var layout = Chart.layoutService;
+ var noop = helpers.noop;
+
+ Chart.Title = Element.extend({
+ initialize: function(config) {
+ var me = this;
+ helpers.extend(me, config);
+
+ // Contains hit boxes for each dataset (in dataset order)
+ me.legendHitBoxes = [];
+ },
+
+ // These methods are ordered by lifecycle. Utilities then follow.
+
+ beforeUpdate: noop,
+ update: function(maxWidth, maxHeight, margins) {
+ var me = this;
+
+ // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
+ me.beforeUpdate();
+
+ // Absorb the master measurements
+ me.maxWidth = maxWidth;
+ me.maxHeight = maxHeight;
+ me.margins = margins;
+
+ // Dimensions
+ me.beforeSetDimensions();
+ me.setDimensions();
+ me.afterSetDimensions();
+ // Labels
+ me.beforeBuildLabels();
+ me.buildLabels();
+ me.afterBuildLabels();
+
+ // Fit
+ me.beforeFit();
+ me.fit();
+ me.afterFit();
+ //
+ me.afterUpdate();
+
+ return me.minSize;
+
+ },
+ afterUpdate: noop,
+
+ //
+
+ beforeSetDimensions: noop,
+ setDimensions: function() {
+ var me = this;
+ // Set the unconstrained dimension before label rotation
+ if (me.isHorizontal()) {
+ // Reset position before calculating rotation
+ me.width = me.maxWidth;
+ me.left = 0;
+ me.right = me.width;
+ } else {
+ me.height = me.maxHeight;
+
+ // Reset position before calculating rotation
+ me.top = 0;
+ me.bottom = me.height;
+ }
+
+ // Reset padding
+ me.paddingLeft = 0;
+ me.paddingTop = 0;
+ me.paddingRight = 0;
+ me.paddingBottom = 0;
+
+ // Reset minSize
+ me.minSize = {
+ width: 0,
+ height: 0
+ };
+ },
+ afterSetDimensions: noop,
+
+ //
+
+ beforeBuildLabels: noop,
+ buildLabels: noop,
+ afterBuildLabels: noop,
+
+ //
+
+ beforeFit: noop,
+ fit: function() {
+ var me = this;
+ var valueOrDefault = helpers.valueOrDefault;
+ var opts = me.options;
+ var display = opts.display;
+ var fontSize = valueOrDefault(opts.fontSize, defaults.global.defaultFontSize);
+ var minSize = me.minSize;
+ var lineCount = helpers.isArray(opts.text) ? opts.text.length : 1;
+ var lineHeight = helpers.options.toLineHeight(opts.lineHeight, fontSize);
+ var textSize = display ? (lineCount * lineHeight) + (opts.padding * 2) : 0;
+
+ if (me.isHorizontal()) {
+ minSize.width = me.maxWidth; // fill all the width
+ minSize.height = textSize;
+ } else {
+ minSize.width = textSize;
+ minSize.height = me.maxHeight; // fill all the height
+ }
+
+ me.width = minSize.width;
+ me.height = minSize.height;
+
+ },
+ afterFit: noop,
+
+ // Shared Methods
+ isHorizontal: function() {
+ var pos = this.options.position;
+ return pos === 'top' || pos === 'bottom';
+ },
+
+ // Actually draw the title block on the canvas
+ draw: function() {
+ var me = this;
+ var ctx = me.ctx;
+ var valueOrDefault = helpers.valueOrDefault;
+ var opts = me.options;
+ var globalDefaults = defaults.global;
+
+ if (opts.display) {
+ var fontSize = valueOrDefault(opts.fontSize, globalDefaults.defaultFontSize);
+ var fontStyle = valueOrDefault(opts.fontStyle, globalDefaults.defaultFontStyle);
+ var fontFamily = valueOrDefault(opts.fontFamily, globalDefaults.defaultFontFamily);
+ var titleFont = helpers.fontString(fontSize, fontStyle, fontFamily);
+ var lineHeight = helpers.options.toLineHeight(opts.lineHeight, fontSize);
+ var offset = lineHeight / 2 + opts.padding;
+ var rotation = 0;
+ var top = me.top;
+ var left = me.left;
+ var bottom = me.bottom;
+ var right = me.right;
+ var maxWidth, titleX, titleY;
+
+ ctx.fillStyle = valueOrDefault(opts.fontColor, globalDefaults.defaultFontColor); // render in correct colour
+ ctx.font = titleFont;
+
+ // Horizontal
+ if (me.isHorizontal()) {
+ titleX = left + ((right - left) / 2); // midpoint of the width
+ titleY = top + offset;
+ maxWidth = right - left;
+ } else {
+ titleX = opts.position === 'left' ? left + offset : right - offset;
+ titleY = top + ((bottom - top) / 2);
+ maxWidth = bottom - top;
+ rotation = Math.PI * (opts.position === 'left' ? -0.5 : 0.5);
+ }
+
+ ctx.save();
+ ctx.translate(titleX, titleY);
+ ctx.rotate(rotation);
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+
+ var text = opts.text;
+ if (helpers.isArray(text)) {
+ var y = 0;
+ for (var i = 0; i < text.length; ++i) {
+ ctx.fillText(text[i], 0, y, maxWidth);
+ y += lineHeight;
+ }
+ } else {
+ ctx.fillText(text, 0, 0, maxWidth);
+ }
+
+ ctx.restore();
+ }
+ }
+ });
+
+ function createNewTitleBlockAndAttach(chart, titleOpts) {
+ var title = new Chart.Title({
+ ctx: chart.ctx,
+ options: titleOpts,
+ chart: chart
+ });
+
+ layout.configure(chart, title, titleOpts);
+ layout.addBox(chart, title);
+ chart.titleBlock = title;
+ }
+
+ return {
+ id: 'title',
+
+ beforeInit: function(chart) {
+ var titleOpts = chart.options.title;
+
+ if (titleOpts) {
+ createNewTitleBlockAndAttach(chart, titleOpts);
+ }
+ },
+
+ beforeUpdate: function(chart) {
+ var titleOpts = chart.options.title;
+ var titleBlock = chart.titleBlock;
+
+ if (titleOpts) {
+ helpers.mergeIf(titleOpts, defaults.global.title);
+
+ if (titleBlock) {
+ layout.configure(chart, titleBlock, titleOpts);
+ titleBlock.options = titleOpts;
+ } else {
+ createNewTitleBlockAndAttach(chart, titleOpts);
+ }
+ } else if (titleBlock) {
+ Chart.layoutService.removeBox(chart, titleBlock);
+ delete chart.titleBlock;
+ }
+ }
+ };
+};
+
+},{"25":25,"26":26,"45":45}],52:[function(require,module,exports){
+'use strict';
+
+module.exports = function(Chart) {
+
+ // Default config for a category scale
+ var defaultConfig = {
+ position: 'bottom'
+ };
+
+ var DatasetScale = Chart.Scale.extend({
+ /**
+ * Internal function to get the correct labels. If data.xLabels or data.yLabels are defined, use those
+ * else fall back to data.labels
+ * @private
+ */
+ getLabels: function() {
+ var data = this.chart.data;
+ return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
+ },
+
+ determineDataLimits: function() {
+ var me = this;
+ var labels = me.getLabels();
+ me.minIndex = 0;
+ me.maxIndex = labels.length - 1;
+ var findIndex;
+
+ if (me.options.ticks.min !== undefined) {
+ // user specified min value
+ findIndex = labels.indexOf(me.options.ticks.min);
+ me.minIndex = findIndex !== -1 ? findIndex : me.minIndex;
+ }
+
+ if (me.options.ticks.max !== undefined) {
+ // user specified max value
+ findIndex = labels.indexOf(me.options.ticks.max);
+ me.maxIndex = findIndex !== -1 ? findIndex : me.maxIndex;
+ }
+
+ me.min = labels[me.minIndex];
+ me.max = labels[me.maxIndex];
+ },
+
+ buildTicks: function() {
+ var me = this;
+ var labels = me.getLabels();
+ // If we are viewing some subset of labels, slice the original array
+ me.ticks = (me.minIndex === 0 && me.maxIndex === labels.length - 1) ? labels : labels.slice(me.minIndex, me.maxIndex + 1);
+ },
+
+ getLabelForIndex: function(index, datasetIndex) {
+ var me = this;
+ var data = me.chart.data;
+ var isHorizontal = me.isHorizontal();
+
+ if (data.yLabels && !isHorizontal) {
+ return me.getRightValue(data.datasets[datasetIndex].data[index]);
+ }
+ return me.ticks[index - me.minIndex];
+ },
+
+ // Used to get data value locations. Value can either be an index or a numerical value
+ getPixelForValue: function(value, index) {
+ var me = this;
+ var offset = me.options.offset;
+ // 1 is added because we need the length but we have the indexes
+ var offsetAmt = Math.max((me.maxIndex + 1 - me.minIndex - (offset ? 0 : 1)), 1);
+
+ // If value is a data object, then index is the index in the data array,
+ // not the index of the scale. We need to change that.
+ var valueCategory;
+ if (value !== undefined && value !== null) {
+ valueCategory = me.isHorizontal() ? value.x : value.y;
+ }
+ if (valueCategory !== undefined || (value !== undefined && isNaN(index))) {
+ var labels = me.getLabels();
+ value = valueCategory || value;
+ var idx = labels.indexOf(value);
+ index = idx !== -1 ? idx : index;
+ }
+
+ if (me.isHorizontal()) {
+ var valueWidth = me.width / offsetAmt;
+ var widthOffset = (valueWidth * (index - me.minIndex));
+
+ if (offset) {
+ widthOffset += (valueWidth / 2);
+ }
+
+ return me.left + Math.round(widthOffset);
+ }
+ var valueHeight = me.height / offsetAmt;
+ var heightOffset = (valueHeight * (index - me.minIndex));
+
+ if (offset) {
+ heightOffset += (valueHeight / 2);
+ }
+
+ return me.top + Math.round(heightOffset);
+ },
+ getPixelForTick: function(index) {
+ return this.getPixelForValue(this.ticks[index], index + this.minIndex, null);
+ },
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var offset = me.options.offset;
+ var value;
+ var offsetAmt = Math.max((me._ticks.length - (offset ? 0 : 1)), 1);
+ var horz = me.isHorizontal();
+ var valueDimension = (horz ? me.width : me.height) / offsetAmt;
+
+ pixel -= horz ? me.left : me.top;
+
+ if (offset) {
+ pixel -= (valueDimension / 2);
+ }
+
+ if (pixel <= 0) {
+ value = 0;
+ } else {
+ value = Math.round(pixel / valueDimension);
+ }
+
+ return value + me.minIndex;
+ },
+ getBasePixel: function() {
+ return this.bottom;
+ }
+ });
+
+ Chart.scaleService.registerScaleType('category', DatasetScale, defaultConfig);
+
+};
+
+},{}],53:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var defaultConfig = {
+ position: 'left',
+ ticks: {
+ callback: Ticks.formatters.linear
+ }
+ };
+
+ var LinearScale = Chart.LinearScaleBase.extend({
+
+ determineDataLimits: function() {
+ var me = this;
+ var opts = me.options;
+ var chart = me.chart;
+ var data = chart.data;
+ var datasets = data.datasets;
+ var isHorizontal = me.isHorizontal();
+ var DEFAULT_MIN = 0;
+ var DEFAULT_MAX = 1;
+
+ function IDMatches(meta) {
+ return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
+ }
+
+ // First Calculate the range
+ me.min = null;
+ me.max = null;
+
+ var hasStacks = opts.stacked;
+ if (hasStacks === undefined) {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ if (hasStacks) {
+ return;
+ }
+
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) &&
+ meta.stack !== undefined) {
+ hasStacks = true;
+ }
+ });
+ }
+
+ if (opts.stacked || hasStacks) {
+ var valuesPerStack = {};
+
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ var key = [
+ meta.type,
+ // we have a separate stack for stack=undefined datasets when the opts.stacked is undefined
+ ((opts.stacked === undefined && meta.stack === undefined) ? datasetIndex : ''),
+ meta.stack
+ ].join('.');
+
+ if (valuesPerStack[key] === undefined) {
+ valuesPerStack[key] = {
+ positiveValues: [],
+ negativeValues: []
+ };
+ }
+
+ // Store these per type
+ var positiveValues = valuesPerStack[key].positiveValues;
+ var negativeValues = valuesPerStack[key].negativeValues;
+
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ positiveValues[index] = positiveValues[index] || 0;
+ negativeValues[index] = negativeValues[index] || 0;
+
+ if (opts.relativePoints) {
+ positiveValues[index] = 100;
+ } else if (value < 0) {
+ negativeValues[index] += value;
+ } else {
+ positiveValues[index] += value;
+ }
+ });
+ }
+ });
+
+ helpers.each(valuesPerStack, function(valuesForType) {
+ var values = valuesForType.positiveValues.concat(valuesForType.negativeValues);
+ var minVal = helpers.min(values);
+ var maxVal = helpers.max(values);
+ me.min = me.min === null ? minVal : Math.min(me.min, minVal);
+ me.max = me.max === null ? maxVal : Math.max(me.max, maxVal);
+ });
+
+ } else {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ if (me.min === null) {
+ me.min = value;
+ } else if (value < me.min) {
+ me.min = value;
+ }
+
+ if (me.max === null) {
+ me.max = value;
+ } else if (value > me.max) {
+ me.max = value;
+ }
+ });
+ }
+ });
+ }
+
+ me.min = isFinite(me.min) && !isNaN(me.min) ? me.min : DEFAULT_MIN;
+ me.max = isFinite(me.max) && !isNaN(me.max) ? me.max : DEFAULT_MAX;
+
+ // Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
+ this.handleTickRangeOptions();
+ },
+ getTickLimit: function() {
+ var maxTicks;
+ var me = this;
+ var tickOpts = me.options.ticks;
+
+ if (me.isHorizontal()) {
+ maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.width / 50));
+ } else {
+ // The factor of 2 used to scale the font size has been experimentally determined.
+ var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, defaults.global.defaultFontSize);
+ maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.height / (2 * tickFontSize)));
+ }
+
+ return maxTicks;
+ },
+ // Called after the ticks are built. We need
+ handleDirectionalChanges: function() {
+ if (!this.isHorizontal()) {
+ // We are in a vertical orientation. The top value is the highest. So reverse the array
+ this.ticks.reverse();
+ }
+ },
+ getLabelForIndex: function(index, datasetIndex) {
+ return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
+ },
+ // Utils
+ getPixelForValue: function(value) {
+ // This must be called after fit has been run so that
+ // this.left, this.top, this.right, and this.bottom have been defined
+ var me = this;
+ var start = me.start;
+
+ var rightValue = +me.getRightValue(value);
+ var pixel;
+ var range = me.end - start;
+
+ if (me.isHorizontal()) {
+ pixel = me.left + (me.width / range * (rightValue - start));
+ return Math.round(pixel);
+ }
+
+ pixel = me.bottom - (me.height / range * (rightValue - start));
+ return Math.round(pixel);
+ },
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var isHorizontal = me.isHorizontal();
+ var innerDimension = isHorizontal ? me.width : me.height;
+ var offset = (isHorizontal ? pixel - me.left : me.bottom - pixel) / innerDimension;
+ return me.start + ((me.end - me.start) * offset);
+ },
+ getPixelForTick: function(index) {
+ return this.getPixelForValue(this.ticksAsNumbers[index]);
+ }
+ });
+ Chart.scaleService.registerScaleType('linear', LinearScale, defaultConfig);
+
+};
+
+},{"25":25,"34":34,"45":45}],54:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var noop = helpers.noop;
+
+ Chart.LinearScaleBase = Chart.Scale.extend({
+ getRightValue: function(value) {
+ if (typeof value === 'string') {
+ return +value;
+ }
+ return Chart.Scale.prototype.getRightValue.call(this, value);
+ },
+
+ handleTickRangeOptions: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+
+ // If we are forcing it to begin at 0, but 0 will already be rendered on the chart,
+ // do nothing since that would make the chart weird. If the user really wants a weird chart
+ // axis, they can manually override it
+ if (tickOpts.beginAtZero) {
+ var minSign = helpers.sign(me.min);
+ var maxSign = helpers.sign(me.max);
+
+ if (minSign < 0 && maxSign < 0) {
+ // move the top up to 0
+ me.max = 0;
+ } else if (minSign > 0 && maxSign > 0) {
+ // move the bottom down to 0
+ me.min = 0;
+ }
+ }
+
+ var setMin = tickOpts.min !== undefined || tickOpts.suggestedMin !== undefined;
+ var setMax = tickOpts.max !== undefined || tickOpts.suggestedMax !== undefined;
+
+ if (tickOpts.min !== undefined) {
+ me.min = tickOpts.min;
+ } else if (tickOpts.suggestedMin !== undefined) {
+ if (me.min === null) {
+ me.min = tickOpts.suggestedMin;
+ } else {
+ me.min = Math.min(me.min, tickOpts.suggestedMin);
+ }
+ }
+
+ if (tickOpts.max !== undefined) {
+ me.max = tickOpts.max;
+ } else if (tickOpts.suggestedMax !== undefined) {
+ if (me.max === null) {
+ me.max = tickOpts.suggestedMax;
+ } else {
+ me.max = Math.max(me.max, tickOpts.suggestedMax);
+ }
+ }
+
+ if (setMin !== setMax) {
+ // We set the min or the max but not both.
+ // So ensure that our range is good
+ // Inverted or 0 length range can happen when
+ // ticks.min is set, and no datasets are visible
+ if (me.min >= me.max) {
+ if (setMin) {
+ me.max = me.min + 1;
+ } else {
+ me.min = me.max - 1;
+ }
+ }
+ }
+
+ if (me.min === me.max) {
+ me.max++;
+
+ if (!tickOpts.beginAtZero) {
+ me.min--;
+ }
+ }
+ },
+ getTickLimit: noop,
+ handleDirectionalChanges: noop,
+
+ buildTicks: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+
+ // Figure out what the max number of ticks we can support it is based on the size of
+ // the axis area. For now, we say that the minimum tick spacing in pixels must be 50
+ // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
+ // the graph. Make sure we always have at least 2 ticks
+ var maxTicks = me.getTickLimit();
+ maxTicks = Math.max(2, maxTicks);
+
+ var numericGeneratorOptions = {
+ maxTicks: maxTicks,
+ min: tickOpts.min,
+ max: tickOpts.max,
+ stepSize: helpers.valueOrDefault(tickOpts.fixedStepSize, tickOpts.stepSize)
+ };
+ var ticks = me.ticks = Ticks.generators.linear(numericGeneratorOptions, me);
+
+ me.handleDirectionalChanges();
+
+ // At this point, we need to update our max and min given the tick values since we have expanded the
+ // range of the scale
+ me.max = helpers.max(ticks);
+ me.min = helpers.min(ticks);
+
+ if (tickOpts.reverse) {
+ ticks.reverse();
+
+ me.start = me.max;
+ me.end = me.min;
+ } else {
+ me.start = me.min;
+ me.end = me.max;
+ }
+ },
+ convertTicksToLabels: function() {
+ var me = this;
+ me.ticksAsNumbers = me.ticks.slice();
+ me.zeroLineIndex = me.ticks.indexOf(0);
+
+ Chart.Scale.prototype.convertTicksToLabels.call(me);
+ }
+ });
+};
+
+},{"34":34,"45":45}],55:[function(require,module,exports){
+'use strict';
+
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var defaultConfig = {
+ position: 'left',
+
+ // label settings
+ ticks: {
+ callback: Ticks.formatters.logarithmic
+ }
+ };
+
+ var LogarithmicScale = Chart.Scale.extend({
+ determineDataLimits: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ var chart = me.chart;
+ var data = chart.data;
+ var datasets = data.datasets;
+ var valueOrDefault = helpers.valueOrDefault;
+ var isHorizontal = me.isHorizontal();
+ function IDMatches(meta) {
+ return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
+ }
+
+ // Calculate Range
+ me.min = null;
+ me.max = null;
+ me.minNotZero = null;
+
+ var hasStacks = opts.stacked;
+ if (hasStacks === undefined) {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ if (hasStacks) {
+ return;
+ }
+
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) &&
+ meta.stack !== undefined) {
+ hasStacks = true;
+ }
+ });
+ }
+
+ if (opts.stacked || hasStacks) {
+ var valuesPerStack = {};
+
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ var key = [
+ meta.type,
+ // we have a separate stack for stack=undefined datasets when the opts.stacked is undefined
+ ((opts.stacked === undefined && meta.stack === undefined) ? datasetIndex : ''),
+ meta.stack
+ ].join('.');
+
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ if (valuesPerStack[key] === undefined) {
+ valuesPerStack[key] = [];
+ }
+
+ helpers.each(dataset.data, function(rawValue, index) {
+ var values = valuesPerStack[key];
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ values[index] = values[index] || 0;
+
+ if (opts.relativePoints) {
+ values[index] = 100;
+ } else {
+ // Don't need to split positive and negative since the log scale can't handle a 0 crossing
+ values[index] += value;
+ }
+ });
+ }
+ });
+
+ helpers.each(valuesPerStack, function(valuesForType) {
+ var minVal = helpers.min(valuesForType);
+ var maxVal = helpers.max(valuesForType);
+ me.min = me.min === null ? minVal : Math.min(me.min, minVal);
+ me.max = me.max === null ? maxVal : Math.max(me.max, maxVal);
+ });
+
+ } else {
+ helpers.each(datasets, function(dataset, datasetIndex) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+ if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ if (me.min === null) {
+ me.min = value;
+ } else if (value < me.min) {
+ me.min = value;
+ }
+
+ if (me.max === null) {
+ me.max = value;
+ } else if (value > me.max) {
+ me.max = value;
+ }
+
+ if (value !== 0 && (me.minNotZero === null || value < me.minNotZero)) {
+ me.minNotZero = value;
+ }
+ });
+ }
+ });
+ }
+
+ me.min = valueOrDefault(tickOpts.min, me.min);
+ me.max = valueOrDefault(tickOpts.max, me.max);
+
+ if (me.min === me.max) {
+ if (me.min !== 0 && me.min !== null) {
+ me.min = Math.pow(10, Math.floor(helpers.log10(me.min)) - 1);
+ me.max = Math.pow(10, Math.floor(helpers.log10(me.max)) + 1);
+ } else {
+ me.min = 1;
+ me.max = 10;
+ }
+ }
+ },
+ buildTicks: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+
+ var generationOptions = {
+ min: tickOpts.min,
+ max: tickOpts.max
+ };
+ var ticks = me.ticks = Ticks.generators.logarithmic(generationOptions, me);
+
+ if (!me.isHorizontal()) {
+ // We are in a vertical orientation. The top value is the highest. So reverse the array
+ ticks.reverse();
+ }
+
+ // At this point, we need to update our max and min given the tick values since we have expanded the
+ // range of the scale
+ me.max = helpers.max(ticks);
+ me.min = helpers.min(ticks);
+
+ if (tickOpts.reverse) {
+ ticks.reverse();
+
+ me.start = me.max;
+ me.end = me.min;
+ } else {
+ me.start = me.min;
+ me.end = me.max;
+ }
+ },
+ convertTicksToLabels: function() {
+ this.tickValues = this.ticks.slice();
+
+ Chart.Scale.prototype.convertTicksToLabels.call(this);
+ },
+ // Get the correct tooltip label
+ getLabelForIndex: function(index, datasetIndex) {
+ return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
+ },
+ getPixelForTick: function(index) {
+ return this.getPixelForValue(this.tickValues[index]);
+ },
+ getPixelForValue: function(value) {
+ var me = this;
+ var start = me.start;
+ var newVal = +me.getRightValue(value);
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ var innerDimension, pixel, range;
+
+ if (me.isHorizontal()) {
+ range = helpers.log10(me.end) - helpers.log10(start); // todo: if start === 0
+ if (newVal === 0) {
+ pixel = me.left;
+ } else {
+ innerDimension = me.width;
+ pixel = me.left + (innerDimension / range * (helpers.log10(newVal) - helpers.log10(start)));
+ }
+ } else {
+ // Bottom - top since pixels increase downward on a screen
+ innerDimension = me.height;
+ if (start === 0 && !tickOpts.reverse) {
+ range = helpers.log10(me.end) - helpers.log10(me.minNotZero);
+ if (newVal === start) {
+ pixel = me.bottom;
+ } else if (newVal === me.minNotZero) {
+ pixel = me.bottom - innerDimension * 0.02;
+ } else {
+ pixel = me.bottom - innerDimension * 0.02 - (innerDimension * 0.98 / range * (helpers.log10(newVal) - helpers.log10(me.minNotZero)));
+ }
+ } else if (me.end === 0 && tickOpts.reverse) {
+ range = helpers.log10(me.start) - helpers.log10(me.minNotZero);
+ if (newVal === me.end) {
+ pixel = me.top;
+ } else if (newVal === me.minNotZero) {
+ pixel = me.top + innerDimension * 0.02;
+ } else {
+ pixel = me.top + innerDimension * 0.02 + (innerDimension * 0.98 / range * (helpers.log10(newVal) - helpers.log10(me.minNotZero)));
+ }
+ } else if (newVal === 0) {
+ pixel = tickOpts.reverse ? me.top : me.bottom;
+ } else {
+ range = helpers.log10(me.end) - helpers.log10(start);
+ innerDimension = me.height;
+ pixel = me.bottom - (innerDimension / range * (helpers.log10(newVal) - helpers.log10(start)));
+ }
+ }
+ return pixel;
+ },
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var range = helpers.log10(me.end) - helpers.log10(me.start);
+ var value, innerDimension;
+
+ if (me.isHorizontal()) {
+ innerDimension = me.width;
+ value = me.start * Math.pow(10, (pixel - me.left) * range / innerDimension);
+ } else { // todo: if start === 0
+ innerDimension = me.height;
+ value = Math.pow(10, (me.bottom - pixel) * range / innerDimension) / me.start;
+ }
+ return value;
+ }
+ });
+ Chart.scaleService.registerScaleType('logarithmic', LogarithmicScale, defaultConfig);
+
+};
+
+},{"34":34,"45":45}],56:[function(require,module,exports){
+'use strict';
+
+var defaults = require(25);
+var helpers = require(45);
+var Ticks = require(34);
+
+module.exports = function(Chart) {
+
+ var globalDefaults = defaults.global;
+
+ var defaultConfig = {
+ display: true,
+
+ // Boolean - Whether to animate scaling the chart from the centre
+ animate: true,
+ position: 'chartArea',
+
+ angleLines: {
+ display: true,
+ color: 'rgba(0, 0, 0, 0.1)',
+ lineWidth: 1
+ },
+
+ gridLines: {
+ circular: false
+ },
+
+ // label settings
+ ticks: {
+ // Boolean - Show a backdrop to the scale label
+ showLabelBackdrop: true,
+
+ // String - The colour of the label backdrop
+ backdropColor: 'rgba(255,255,255,0.75)',
+
+ // Number - The backdrop padding above & below the label in pixels
+ backdropPaddingY: 2,
+
+ // Number - The backdrop padding to the side of the label in pixels
+ backdropPaddingX: 2,
+
+ callback: Ticks.formatters.linear
+ },
+
+ pointLabels: {
+ // Boolean - if true, show point labels
+ display: true,
+
+ // Number - Point label font size in pixels
+ fontSize: 10,
+
+ // Function - Used to convert point labels
+ callback: function(label) {
+ return label;
+ }
+ }
+ };
+
+ function getValueCount(scale) {
+ var opts = scale.options;
+ return opts.angleLines.display || opts.pointLabels.display ? scale.chart.data.labels.length : 0;
+ }
+
+ function getPointLabelFontOptions(scale) {
+ var pointLabelOptions = scale.options.pointLabels;
+ var fontSize = helpers.valueOrDefault(pointLabelOptions.fontSize, globalDefaults.defaultFontSize);
+ var fontStyle = helpers.valueOrDefault(pointLabelOptions.fontStyle, globalDefaults.defaultFontStyle);
+ var fontFamily = helpers.valueOrDefault(pointLabelOptions.fontFamily, globalDefaults.defaultFontFamily);
+ var font = helpers.fontString(fontSize, fontStyle, fontFamily);
+
+ return {
+ size: fontSize,
+ style: fontStyle,
+ family: fontFamily,
+ font: font
+ };
+ }
+
+ function measureLabelSize(ctx, fontSize, label) {
+ if (helpers.isArray(label)) {
+ return {
+ w: helpers.longestText(ctx, ctx.font, label),
+ h: (label.length * fontSize) + ((label.length - 1) * 1.5 * fontSize)
+ };
+ }
+
+ return {
+ w: ctx.measureText(label).width,
+ h: fontSize
+ };
+ }
+
+ function determineLimits(angle, pos, size, min, max) {
+ if (angle === min || angle === max) {
+ return {
+ start: pos - (size / 2),
+ end: pos + (size / 2)
+ };
+ } else if (angle < min || angle > max) {
+ return {
+ start: pos - size - 5,
+ end: pos
+ };
+ }
+
+ return {
+ start: pos,
+ end: pos + size + 5
+ };
+ }
+
+ /**
+ * Helper function to fit a radial linear scale with point labels
+ */
+ function fitWithPointLabels(scale) {
+ /*
+ * Right, this is really confusing and there is a lot of maths going on here
+ * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
+ *
+ * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
+ *
+ * Solution:
+ *
+ * We assume the radius of the polygon is half the size of the canvas at first
+ * at each index we check if the text overlaps.
+ *
+ * Where it does, we store that angle and that index.
+ *
+ * After finding the largest index and angle we calculate how much we need to remove
+ * from the shape radius to move the point inwards by that x.
+ *
+ * We average the left and right distances to get the maximum shape radius that can fit in the box
+ * along with labels.
+ *
+ * Once we have that, we can find the centre point for the chart, by taking the x text protrusion
+ * on each side, removing that from the size, halving it and adding the left x protrusion width.
+ *
+ * This will mean we have a shape fitted to the canvas, as large as it can be with the labels
+ * and position it in the most space efficient manner
+ *
+ * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
+ */
+
+ var plFont = getPointLabelFontOptions(scale);
+
+ // Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
+ // Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
+ var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
+ var furthestLimits = {
+ r: scale.width,
+ l: 0,
+ t: scale.height,
+ b: 0
+ };
+ var furthestAngles = {};
+ var i, textSize, pointPosition;
+
+ scale.ctx.font = plFont.font;
+ scale._pointLabelSizes = [];
+
+ var valueCount = getValueCount(scale);
+ for (i = 0; i < valueCount; i++) {
+ pointPosition = scale.getPointPosition(i, largestPossibleRadius);
+ textSize = measureLabelSize(scale.ctx, plFont.size, scale.pointLabels[i] || '');
+ scale._pointLabelSizes[i] = textSize;
+
+ // Add quarter circle to make degree 0 mean top of circle
+ var angleRadians = scale.getIndexAngle(i);
+ var angle = helpers.toDegrees(angleRadians) % 360;
+ var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);
+ var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);
+
+ if (hLimits.start < furthestLimits.l) {
+ furthestLimits.l = hLimits.start;
+ furthestAngles.l = angleRadians;
+ }
+
+ if (hLimits.end > furthestLimits.r) {
+ furthestLimits.r = hLimits.end;
+ furthestAngles.r = angleRadians;
+ }
+
+ if (vLimits.start < furthestLimits.t) {
+ furthestLimits.t = vLimits.start;
+ furthestAngles.t = angleRadians;
+ }
+
+ if (vLimits.end > furthestLimits.b) {
+ furthestLimits.b = vLimits.end;
+ furthestAngles.b = angleRadians;
+ }
+ }
+
+ scale.setReductions(largestPossibleRadius, furthestLimits, furthestAngles);
+ }
+
+ /**
+ * Helper function to fit a radial linear scale with no point labels
+ */
+ function fit(scale) {
+ var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
+ scale.drawingArea = Math.round(largestPossibleRadius);
+ scale.setCenterPoint(0, 0, 0, 0);
+ }
+
+ function getTextAlignForAngle(angle) {
+ if (angle === 0 || angle === 180) {
+ return 'center';
+ } else if (angle < 180) {
+ return 'left';
+ }
+
+ return 'right';
+ }
+
+ function fillText(ctx, text, position, fontSize) {
+ if (helpers.isArray(text)) {
+ var y = position.y;
+ var spacing = 1.5 * fontSize;
+
+ for (var i = 0; i < text.length; ++i) {
+ ctx.fillText(text[i], position.x, y);
+ y += spacing;
+ }
+ } else {
+ ctx.fillText(text, position.x, position.y);
+ }
+ }
+
+ function adjustPointPositionForLabelHeight(angle, textSize, position) {
+ if (angle === 90 || angle === 270) {
+ position.y -= (textSize.h / 2);
+ } else if (angle > 270 || angle < 90) {
+ position.y -= textSize.h;
+ }
+ }
+
+ function drawPointLabels(scale) {
+ var ctx = scale.ctx;
+ var valueOrDefault = helpers.valueOrDefault;
+ var opts = scale.options;
+ var angleLineOpts = opts.angleLines;
+ var pointLabelOpts = opts.pointLabels;
+
+ ctx.lineWidth = angleLineOpts.lineWidth;
+ ctx.strokeStyle = angleLineOpts.color;
+
+ var outerDistance = scale.getDistanceFromCenterForValue(opts.ticks.reverse ? scale.min : scale.max);
+
+ // Point Label Font
+ var plFont = getPointLabelFontOptions(scale);
+
+ ctx.textBaseline = 'top';
+
+ for (var i = getValueCount(scale) - 1; i >= 0; i--) {
+ if (angleLineOpts.display) {
+ var outerPosition = scale.getPointPosition(i, outerDistance);
+ ctx.beginPath();
+ ctx.moveTo(scale.xCenter, scale.yCenter);
+ ctx.lineTo(outerPosition.x, outerPosition.y);
+ ctx.stroke();
+ ctx.closePath();
+ }
+
+ if (pointLabelOpts.display) {
+ // Extra 3px out for some label spacing
+ var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
+
+ // Keep this in loop since we may support array properties here
+ var pointLabelFontColor = valueOrDefault(pointLabelOpts.fontColor, globalDefaults.defaultFontColor);
+ ctx.font = plFont.font;
+ ctx.fillStyle = pointLabelFontColor;
+
+ var angleRadians = scale.getIndexAngle(i);
+ var angle = helpers.toDegrees(angleRadians);
+ ctx.textAlign = getTextAlignForAngle(angle);
+ adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], pointLabelPosition);
+ fillText(ctx, scale.pointLabels[i] || '', pointLabelPosition, plFont.size);
+ }
+ }
+ }
+
+ function drawRadiusLine(scale, gridLineOpts, radius, index) {
+ var ctx = scale.ctx;
+ ctx.strokeStyle = helpers.valueAtIndexOrDefault(gridLineOpts.color, index - 1);
+ ctx.lineWidth = helpers.valueAtIndexOrDefault(gridLineOpts.lineWidth, index - 1);
+
+ if (scale.options.gridLines.circular) {
+ // Draw circular arcs between the points
+ ctx.beginPath();
+ ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2);
+ ctx.closePath();
+ ctx.stroke();
+ } else {
+ // Draw straight lines connecting each index
+ var valueCount = getValueCount(scale);
+
+ if (valueCount === 0) {
+ return;
+ }
+
+ ctx.beginPath();
+ var pointPosition = scale.getPointPosition(0, radius);
+ ctx.moveTo(pointPosition.x, pointPosition.y);
+
+ for (var i = 1; i < valueCount; i++) {
+ pointPosition = scale.getPointPosition(i, radius);
+ ctx.lineTo(pointPosition.x, pointPosition.y);
+ }
+
+ ctx.closePath();
+ ctx.stroke();
+ }
+ }
+
+ function numberOrZero(param) {
+ return helpers.isNumber(param) ? param : 0;
+ }
+
+ var LinearRadialScale = Chart.LinearScaleBase.extend({
+ setDimensions: function() {
+ var me = this;
+ var opts = me.options;
+ var tickOpts = opts.ticks;
+ // Set the unconstrained dimension before label rotation
+ me.width = me.maxWidth;
+ me.height = me.maxHeight;
+ me.xCenter = Math.round(me.width / 2);
+ me.yCenter = Math.round(me.height / 2);
+
+ var minSize = helpers.min([me.height, me.width]);
+ var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
+ me.drawingArea = opts.display ? (minSize / 2) - (tickFontSize / 2 + tickOpts.backdropPaddingY) : (minSize / 2);
+ },
+ determineDataLimits: function() {
+ var me = this;
+ var chart = me.chart;
+ var min = Number.POSITIVE_INFINITY;
+ var max = Number.NEGATIVE_INFINITY;
+
+ helpers.each(chart.data.datasets, function(dataset, datasetIndex) {
+ if (chart.isDatasetVisible(datasetIndex)) {
+ var meta = chart.getDatasetMeta(datasetIndex);
+
+ helpers.each(dataset.data, function(rawValue, index) {
+ var value = +me.getRightValue(rawValue);
+ if (isNaN(value) || meta.data[index].hidden) {
+ return;
+ }
+
+ min = Math.min(value, min);
+ max = Math.max(value, max);
+ });
+ }
+ });
+
+ me.min = (min === Number.POSITIVE_INFINITY ? 0 : min);
+ me.max = (max === Number.NEGATIVE_INFINITY ? 0 : max);
+
+ // Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
+ me.handleTickRangeOptions();
+ },
+ getTickLimit: function() {
+ var tickOpts = this.options.ticks;
+ var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
+ return Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(this.drawingArea / (1.5 * tickFontSize)));
+ },
+ convertTicksToLabels: function() {
+ var me = this;
+
+ Chart.LinearScaleBase.prototype.convertTicksToLabels.call(me);
+
+ // Point labels
+ me.pointLabels = me.chart.data.labels.map(me.options.pointLabels.callback, me);
+ },
+ getLabelForIndex: function(index, datasetIndex) {
+ return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
+ },
+ fit: function() {
+ if (this.options.pointLabels.display) {
+ fitWithPointLabels(this);
+ } else {
+ fit(this);
+ }
+ },
+ /**
+ * Set radius reductions and determine new radius and center point
+ * @private
+ */
+ setReductions: function(largestPossibleRadius, furthestLimits, furthestAngles) {
+ var me = this;
+ var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l);
+ var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r);
+ var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t);
+ var radiusReductionBottom = -Math.max(furthestLimits.b - me.height, 0) / Math.cos(furthestAngles.b);
+
+ radiusReductionLeft = numberOrZero(radiusReductionLeft);
+ radiusReductionRight = numberOrZero(radiusReductionRight);
+ radiusReductionTop = numberOrZero(radiusReductionTop);
+ radiusReductionBottom = numberOrZero(radiusReductionBottom);
+
+ me.drawingArea = Math.min(
+ Math.round(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2),
+ Math.round(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2));
+ me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom);
+ },
+ setCenterPoint: function(leftMovement, rightMovement, topMovement, bottomMovement) {
+ var me = this;
+ var maxRight = me.width - rightMovement - me.drawingArea;
+ var maxLeft = leftMovement + me.drawingArea;
+ var maxTop = topMovement + me.drawingArea;
+ var maxBottom = me.height - bottomMovement - me.drawingArea;
+
+ me.xCenter = Math.round(((maxLeft + maxRight) / 2) + me.left);
+ me.yCenter = Math.round(((maxTop + maxBottom) / 2) + me.top);
+ },
+
+ getIndexAngle: function(index) {
+ var angleMultiplier = (Math.PI * 2) / getValueCount(this);
+ var startAngle = this.chart.options && this.chart.options.startAngle ?
+ this.chart.options.startAngle :
+ 0;
+
+ var startAngleRadians = startAngle * Math.PI * 2 / 360;
+
+ // Start from the top instead of right, so remove a quarter of the circle
+ return index * angleMultiplier + startAngleRadians;
+ },
+ getDistanceFromCenterForValue: function(value) {
+ var me = this;
+
+ if (value === null) {
+ return 0; // null always in center
+ }
+
+ // Take into account half font size + the yPadding of the top value
+ var scalingFactor = me.drawingArea / (me.max - me.min);
+ if (me.options.ticks.reverse) {
+ return (me.max - value) * scalingFactor;
+ }
+ return (value - me.min) * scalingFactor;
+ },
+ getPointPosition: function(index, distanceFromCenter) {
+ var me = this;
+ var thisAngle = me.getIndexAngle(index) - (Math.PI / 2);
+ return {
+ x: Math.round(Math.cos(thisAngle) * distanceFromCenter) + me.xCenter,
+ y: Math.round(Math.sin(thisAngle) * distanceFromCenter) + me.yCenter
+ };
+ },
+ getPointPositionForValue: function(index, value) {
+ return this.getPointPosition(index, this.getDistanceFromCenterForValue(value));
+ },
+
+ getBasePosition: function() {
+ var me = this;
+ var min = me.min;
+ var max = me.max;
+
+ return me.getPointPositionForValue(0,
+ me.beginAtZero ? 0 :
+ min < 0 && max < 0 ? max :
+ min > 0 && max > 0 ? min :
+ 0);
+ },
+
+ draw: function() {
+ var me = this;
+ var opts = me.options;
+ var gridLineOpts = opts.gridLines;
+ var tickOpts = opts.ticks;
+ var valueOrDefault = helpers.valueOrDefault;
+
+ if (opts.display) {
+ var ctx = me.ctx;
+ var startAngle = this.getIndexAngle(0);
+
+ // Tick Font
+ var tickFontSize = valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
+ var tickFontStyle = valueOrDefault(tickOpts.fontStyle, globalDefaults.defaultFontStyle);
+ var tickFontFamily = valueOrDefault(tickOpts.fontFamily, globalDefaults.defaultFontFamily);
+ var tickLabelFont = helpers.fontString(tickFontSize, tickFontStyle, tickFontFamily);
+
+ helpers.each(me.ticks, function(label, index) {
+ // Don't draw a centre value (if it is minimum)
+ if (index > 0 || tickOpts.reverse) {
+ var yCenterOffset = me.getDistanceFromCenterForValue(me.ticksAsNumbers[index]);
+
+ // Draw circular lines around the scale
+ if (gridLineOpts.display && index !== 0) {
+ drawRadiusLine(me, gridLineOpts, yCenterOffset, index);
+ }
+
+ if (tickOpts.display) {
+ var tickFontColor = valueOrDefault(tickOpts.fontColor, globalDefaults.defaultFontColor);
+ ctx.font = tickLabelFont;
+
+ ctx.save();
+ ctx.translate(me.xCenter, me.yCenter);
+ ctx.rotate(startAngle);
+
+ if (tickOpts.showLabelBackdrop) {
+ var labelWidth = ctx.measureText(label).width;
+ ctx.fillStyle = tickOpts.backdropColor;
+ ctx.fillRect(
+ -labelWidth / 2 - tickOpts.backdropPaddingX,
+ -yCenterOffset - tickFontSize / 2 - tickOpts.backdropPaddingY,
+ labelWidth + tickOpts.backdropPaddingX * 2,
+ tickFontSize + tickOpts.backdropPaddingY * 2
+ );
+ }
+
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillStyle = tickFontColor;
+ ctx.fillText(label, 0, -yCenterOffset);
+ ctx.restore();
+ }
+ }
+ });
+
+ if (opts.angleLines.display || opts.pointLabels.display) {
+ drawPointLabels(me);
+ }
+ }
+ }
+ });
+ Chart.scaleService.registerScaleType('radialLinear', LinearRadialScale, defaultConfig);
+
+};
+
+},{"25":25,"34":34,"45":45}],57:[function(require,module,exports){
+/* global window: false */
+'use strict';
+
+var moment = require(1);
+moment = typeof moment === 'function' ? moment : window.moment;
+
+var defaults = require(25);
+var helpers = require(45);
+
+// Integer constants are from the ES6 spec.
+var MIN_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
+var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
+
+var INTERVALS = {
+ millisecond: {
+ common: true,
+ size: 1,
+ steps: [1, 2, 5, 10, 20, 50, 100, 250, 500]
+ },
+ second: {
+ common: true,
+ size: 1000,
+ steps: [1, 2, 5, 10, 30]
+ },
+ minute: {
+ common: true,
+ size: 60000,
+ steps: [1, 2, 5, 10, 30]
+ },
+ hour: {
+ common: true,
+ size: 3600000,
+ steps: [1, 2, 3, 6, 12]
+ },
+ day: {
+ common: true,
+ size: 86400000,
+ steps: [1, 2, 5]
+ },
+ week: {
+ common: false,
+ size: 604800000,
+ steps: [1, 2, 3, 4]
+ },
+ month: {
+ common: true,
+ size: 2.628e9,
+ steps: [1, 2, 3]
+ },
+ quarter: {
+ common: false,
+ size: 7.884e9,
+ steps: [1, 2, 3, 4]
+ },
+ year: {
+ common: true,
+ size: 3.154e10
+ }
+};
+
+var UNITS = Object.keys(INTERVALS);
+
+function sorter(a, b) {
+ return a - b;
+}
+
+function arrayUnique(items) {
+ var hash = {};
+ var out = [];
+ var i, ilen, item;
+
+ for (i = 0, ilen = items.length; i < ilen; ++i) {
+ item = items[i];
+ if (!hash[item]) {
+ hash[item] = true;
+ out.push(item);
+ }
+ }
+
+ return out;
+}
+
+/**
+ * Returns an array of {time, pos} objects used to interpolate a specific `time` or position
+ * (`pos`) on the scale, by searching entries before and after the requested value. `pos` is
+ * a decimal between 0 and 1: 0 being the start of the scale (left or top) and 1 the other
+ * extremity (left + width or top + height). Note that it would be more optimized to directly
+ * store pre-computed pixels, but the scale dimensions are not guaranteed at the time we need
+ * to create the lookup table. The table ALWAYS contains at least two items: min and max.
+ *
+ * @param {Number[]} timestamps - timestamps sorted from lowest to highest.
+ * @param {String} distribution - If 'linear', timestamps will be spread linearly along the min
+ * and max range, so basically, the table will contains only two items: {min, 0} and {max, 1}.
+ * If 'series', timestamps will be positioned at the same distance from each other. In this
+ * case, only timestamps that break the time linearity are registered, meaning that in the
+ * best case, all timestamps are linear, the table contains only min and max.
+ */
+function buildLookupTable(timestamps, min, max, distribution) {
+ if (distribution === 'linear' || !timestamps.length) {
+ return [
+ {time: min, pos: 0},
+ {time: max, pos: 1}
+ ];
+ }
+
+ var table = [];
+ var items = [min];
+ var i, ilen, prev, curr, next;
+
+ for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
+ curr = timestamps[i];
+ if (curr > min && curr < max) {
+ items.push(curr);
+ }
+ }
+
+ items.push(max);
+
+ for (i = 0, ilen = items.length; i < ilen; ++i) {
+ next = items[i + 1];
+ prev = items[i - 1];
+ curr = items[i];
+
+ // only add points that breaks the scale linearity
+ if (prev === undefined || next === undefined || Math.round((next + prev) / 2) !== curr) {
+ table.push({time: curr, pos: i / (ilen - 1)});
+ }
+ }
+
+ return table;
+}
+
+// @see adapted from http://www.anujgakhar.com/2014/03/01/binary-search-in-javascript/
+function lookup(table, key, value) {
+ var lo = 0;
+ var hi = table.length - 1;
+ var mid, i0, i1;
+
+ while (lo >= 0 && lo <= hi) {
+ mid = (lo + hi) >> 1;
+ i0 = table[mid - 1] || null;
+ i1 = table[mid];
+
+ if (!i0) {
+ // given value is outside table (before first item)
+ return {lo: null, hi: i1};
+ } else if (i1[key] < value) {
+ lo = mid + 1;
+ } else if (i0[key] > value) {
+ hi = mid - 1;
+ } else {
+ return {lo: i0, hi: i1};
+ }
+ }
+
+ // given value is outside table (after last item)
+ return {lo: i1, hi: null};
+}
+
+/**
+ * Linearly interpolates the given source `value` using the table items `skey` values and
+ * returns the associated `tkey` value. For example, interpolate(table, 'time', 42, 'pos')
+ * returns the position for a timestamp equal to 42. If value is out of bounds, values at
+ * index [0, 1] or [n - 1, n] are used for the interpolation.
+ */
+function interpolate(table, skey, sval, tkey) {
+ var range = lookup(table, skey, sval);
+
+ // Note: the lookup table ALWAYS contains at least 2 items (min and max)
+ var prev = !range.lo ? table[0] : !range.hi ? table[table.length - 2] : range.lo;
+ var next = !range.lo ? table[1] : !range.hi ? table[table.length - 1] : range.hi;
+
+ var span = next[skey] - prev[skey];
+ var ratio = span ? (sval - prev[skey]) / span : 0;
+ var offset = (next[tkey] - prev[tkey]) * ratio;
+
+ return prev[tkey] + offset;
+}
+
+/**
+ * Convert the given value to a moment object using the given time options.
+ * @see http://momentjs.com/docs/#/parsing/
+ */
+function momentify(value, options) {
+ var parser = options.parser;
+ var format = options.parser || options.format;
+
+ if (typeof parser === 'function') {
+ return parser(value);
+ }
+
+ if (typeof value === 'string' && typeof format === 'string') {
+ return moment(value, format);
+ }
+
+ if (!(value instanceof moment)) {
+ value = moment(value);
+ }
+
+ if (value.isValid()) {
+ return value;
+ }
+
+ // Labels are in an incompatible moment format and no `parser` has been provided.
+ // The user might still use the deprecated `format` option to convert his inputs.
+ if (typeof format === 'function') {
+ return format(value);
+ }
+
+ return value;
+}
+
+function parse(input, scale) {
+ if (helpers.isNullOrUndef(input)) {
+ return null;
+ }
+
+ var options = scale.options.time;
+ var value = momentify(scale.getRightValue(input), options);
+ if (!value.isValid()) {
+ return null;
+ }
+
+ if (options.round) {
+ value.startOf(options.round);
+ }
+
+ return value.valueOf();
+}
+
+/**
+ * Returns the number of unit to skip to be able to display up to `capacity` number of ticks
+ * in `unit` for the given `min` / `max` range and respecting the interval steps constraints.
+ */
+function determineStepSize(min, max, unit, capacity) {
+ var range = max - min;
+ var interval = INTERVALS[unit];
+ var milliseconds = interval.size;
+ var steps = interval.steps;
+ var i, ilen, factor;
+
+ if (!steps) {
+ return Math.ceil(range / ((capacity || 1) * milliseconds));
+ }
+
+ for (i = 0, ilen = steps.length; i < ilen; ++i) {
+ factor = steps[i];
+ if (Math.ceil(range / (milliseconds * factor)) <= capacity) {
+ break;
+ }
+ }
+
+ return factor;
+}
+
+/**
+ * Figures out what unit results in an appropriate number of auto-generated ticks
+ */
+function determineUnitForAutoTicks(minUnit, min, max, capacity) {
+ var ilen = UNITS.length;
+ var i, interval, factor;
+
+ for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
+ interval = INTERVALS[UNITS[i]];
+ factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
+
+ if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
+ return UNITS[i];
+ }
+ }
+
+ return UNITS[ilen - 1];
+}
+
+/**
+ * Figures out what unit to format a set of ticks with
+ */
+function determineUnitForFormatting(ticks, minUnit, min, max) {
+ var duration = moment.duration(moment(max).diff(moment(min)));
+ var ilen = UNITS.length;
+ var i, unit;
+
+ for (i = ilen - 1; i >= UNITS.indexOf(minUnit); i--) {
+ unit = UNITS[i];
+ if (INTERVALS[unit].common && duration.as(unit) >= ticks.length) {
+ return unit;
+ }
+ }
+
+ return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];
+}
+
+function determineMajorUnit(unit) {
+ for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {
+ if (INTERVALS[UNITS[i]].common) {
+ return UNITS[i];
+ }
+ }
+}
+
+/**
+ * Generates a maximum of `capacity` timestamps between min and max, rounded to the
+ * `minor` unit, aligned on the `major` unit and using the given scale time `options`.
+ * Important: this method can return ticks outside the min and max range, it's the
+ * responsibility of the calling code to clamp values if needed.
+ */
+function generate(min, max, capacity, options) {
+ var timeOpts = options.time;
+ var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, capacity);
+ var major = determineMajorUnit(minor);
+ var stepSize = helpers.valueOrDefault(timeOpts.stepSize, timeOpts.unitStepSize);
+ var weekday = minor === 'week' ? timeOpts.isoWeekday : false;
+ var majorTicksEnabled = options.ticks.major.enabled;
+ var interval = INTERVALS[minor];
+ var first = moment(min);
+ var last = moment(max);
+ var ticks = [];
+ var time;
+
+ if (!stepSize) {
+ stepSize = determineStepSize(min, max, minor, capacity);
+ }
+
+ // For 'week' unit, handle the first day of week option
+ if (weekday) {
+ first = first.isoWeekday(weekday);
+ last = last.isoWeekday(weekday);
+ }
+
+ // Align first/last ticks on unit
+ first = first.startOf(weekday ? 'day' : minor);
+ last = last.startOf(weekday ? 'day' : minor);
+
+ // Make sure that the last tick include max
+ if (last < max) {
+ last.add(1, minor);
+ }
+
+ time = moment(first);
+
+ if (majorTicksEnabled && major && !weekday && !timeOpts.round) {
+ // Align the first tick on the previous `minor` unit aligned on the `major` unit:
+ // we first aligned time on the previous `major` unit then add the number of full
+ // stepSize there is between first and the previous major time.
+ time.startOf(major);
+ time.add(~~((first - time) / (interval.size * stepSize)) * stepSize, minor);
+ }
+
+ for (; time < last; time.add(stepSize, minor)) {
+ ticks.push(+time);
+ }
+
+ ticks.push(+time);
+
+ return ticks;
+}
+
+/**
+ * Returns the right and left offsets from edges in the form of {left, right}.
+ * Offsets are added when the `offset` option is true.
+ */
+function computeOffsets(table, ticks, min, max, options) {
+ var left = 0;
+ var right = 0;
+ var upper, lower;
+
+ if (options.offset && ticks.length) {
+ if (!options.time.min) {
+ upper = ticks.length > 1 ? ticks[1] : max;
+ lower = ticks[0];
+ left = (
+ interpolate(table, 'time', upper, 'pos') -
+ interpolate(table, 'time', lower, 'pos')
+ ) / 2;
+ }
+ if (!options.time.max) {
+ upper = ticks[ticks.length - 1];
+ lower = ticks.length > 1 ? ticks[ticks.length - 2] : min;
+ right = (
+ interpolate(table, 'time', upper, 'pos') -
+ interpolate(table, 'time', lower, 'pos')
+ ) / 2;
+ }
+ }
+
+ return {left: left, right: right};
+}
+
+function ticksFromTimestamps(values, majorUnit) {
+ var ticks = [];
+ var i, ilen, value, major;
+
+ for (i = 0, ilen = values.length; i < ilen; ++i) {
+ value = values[i];
+ major = majorUnit ? value === +moment(value).startOf(majorUnit) : false;
+
+ ticks.push({
+ value: value,
+ major: major
+ });
+ }
+
+ return ticks;
+}
+
+module.exports = function(Chart) {
+
+ var defaultConfig = {
+ position: 'bottom',
+
+ /**
+ * Data distribution along the scale:
+ * - 'linear': data are spread according to their time (distances can vary),
+ * - 'series': data are spread at the same distance from each other.
+ * @see https://github.com/chartjs/Chart.js/pull/4507
+ * @since 2.7.0
+ */
+ distribution: 'linear',
+
+ /**
+ * Scale boundary strategy (bypassed by min/max time options)
+ * - `data`: make sure data are fully visible, ticks outside are removed
+ * - `ticks`: make sure ticks are fully visible, data outside are truncated
+ * @see https://github.com/chartjs/Chart.js/pull/4556
+ * @since 2.7.0
+ */
+ bounds: 'data',
+
+ time: {
+ parser: false, // false == a pattern string from http://momentjs.com/docs/#/parsing/string-format/ or a custom callback that converts its argument to a moment
+ format: false, // DEPRECATED false == date objects, moment object, callback or a pattern string from http://momentjs.com/docs/#/parsing/string-format/
+ unit: false, // false == automatic or override with week, month, year, etc.
+ round: false, // none, or override with week, month, year, etc.
+ displayFormat: false, // DEPRECATED
+ isoWeekday: false, // override week start day - see http://momentjs.com/docs/#/get-set/iso-weekday/
+ minUnit: 'millisecond',
+
+ // defaults to unit's corresponding unitFormat below or override using pattern string from http://momentjs.com/docs/#/displaying/format/
+ displayFormats: {
+ millisecond: 'h:mm:ss.SSS a', // 11:20:01.123 AM,
+ second: 'h:mm:ss a', // 11:20:01 AM
+ minute: 'h:mm a', // 11:20 AM
+ hour: 'hA', // 5PM
+ day: 'MMM D', // Sep 4
+ week: 'll', // Week 46, or maybe "[W]WW - YYYY" ?
+ month: 'MMM YYYY', // Sept 2015
+ quarter: '[Q]Q - YYYY', // Q3
+ year: 'YYYY' // 2015
+ },
+ },
+ ticks: {
+ autoSkip: false,
+
+ /**
+ * Ticks generation input values:
+ * - 'auto': generates "optimal" ticks based on scale size and time options.
+ * - 'data': generates ticks from data (including labels from data {t|x|y} objects).
+ * - 'labels': generates ticks from user given `data.labels` values ONLY.
+ * @see https://github.com/chartjs/Chart.js/pull/4507
+ * @since 2.7.0
+ */
+ source: 'auto',
+
+ major: {
+ enabled: false
+ }
+ }
+ };
+
+ var TimeScale = Chart.Scale.extend({
+ initialize: function() {
+ if (!moment) {
+ throw new Error('Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com');
+ }
+
+ this.mergeTicksOptions();
+
+ Chart.Scale.prototype.initialize.call(this);
+ },
+
+ update: function() {
+ var me = this;
+ var options = me.options;
+
+ // DEPRECATIONS: output a message only one time per update
+ if (options.time && options.time.format) {
+ console.warn('options.time.format is deprecated and replaced by options.time.parser.');
+ }
+
+ return Chart.Scale.prototype.update.apply(me, arguments);
+ },
+
+ /**
+ * Allows data to be referenced via 't' attribute
+ */
+ getRightValue: function(rawValue) {
+ if (rawValue && rawValue.t !== undefined) {
+ rawValue = rawValue.t;
+ }
+ return Chart.Scale.prototype.getRightValue.call(this, rawValue);
+ },
+
+ determineDataLimits: function() {
+ var me = this;
+ var chart = me.chart;
+ var timeOpts = me.options.time;
+ var min = MAX_INTEGER;
+ var max = MIN_INTEGER;
+ var timestamps = [];
+ var datasets = [];
+ var labels = [];
+ var i, j, ilen, jlen, data, timestamp;
+
+ // Convert labels to timestamps
+ for (i = 0, ilen = chart.data.labels.length; i < ilen; ++i) {
+ labels.push(parse(chart.data.labels[i], me));
+ }
+
+ // Convert data to timestamps
+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
+ if (chart.isDatasetVisible(i)) {
+ data = chart.data.datasets[i].data;
+
+ // Let's consider that all data have the same format.
+ if (helpers.isObject(data[0])) {
+ datasets[i] = [];
+
+ for (j = 0, jlen = data.length; j < jlen; ++j) {
+ timestamp = parse(data[j], me);
+ timestamps.push(timestamp);
+ datasets[i][j] = timestamp;
+ }
+ } else {
+ timestamps.push.apply(timestamps, labels);
+ datasets[i] = labels.slice(0);
+ }
+ } else {
+ datasets[i] = [];
+ }
+ }
+
+ if (labels.length) {
+ // Sort labels **after** data have been converted
+ labels = arrayUnique(labels).sort(sorter);
+ min = Math.min(min, labels[0]);
+ max = Math.max(max, labels[labels.length - 1]);
+ }
+
+ if (timestamps.length) {
+ timestamps = arrayUnique(timestamps).sort(sorter);
+ min = Math.min(min, timestamps[0]);
+ max = Math.max(max, timestamps[timestamps.length - 1]);
+ }
+
+ min = parse(timeOpts.min, me) || min;
+ max = parse(timeOpts.max, me) || max;
+
+ // In case there is no valid min/max, let's use today limits
+ min = min === MAX_INTEGER ? +moment().startOf('day') : min;
+ max = max === MIN_INTEGER ? +moment().endOf('day') + 1 : max;
+
+ // Make sure that max is strictly higher than min (required by the lookup table)
+ me.min = Math.min(min, max);
+ me.max = Math.max(min + 1, max);
+
+ // PRIVATE
+ me._horizontal = me.isHorizontal();
+ me._table = [];
+ me._timestamps = {
+ data: timestamps,
+ datasets: datasets,
+ labels: labels
+ };
+ },
+
+ buildTicks: function() {
+ var me = this;
+ var min = me.min;
+ var max = me.max;
+ var options = me.options;
+ var timeOpts = options.time;
+ var timestamps = [];
+ var ticks = [];
+ var i, ilen, timestamp;
+
+ switch (options.ticks.source) {
+ case 'data':
+ timestamps = me._timestamps.data;
+ break;
+ case 'labels':
+ timestamps = me._timestamps.labels;
+ break;
+ case 'auto':
+ default:
+ timestamps = generate(min, max, me.getLabelCapacity(min), options);
+ }
+
+ if (options.bounds === 'ticks' && timestamps.length) {
+ min = timestamps[0];
+ max = timestamps[timestamps.length - 1];
+ }
+
+ // Enforce limits with user min/max options
+ min = parse(timeOpts.min, me) || min;
+ max = parse(timeOpts.max, me) || max;
+
+ // Remove ticks outside the min/max range
+ for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
+ timestamp = timestamps[i];
+ if (timestamp >= min && timestamp <= max) {
+ ticks.push(timestamp);
+ }
+ }
+
+ me.min = min;
+ me.max = max;
+
+ // PRIVATE
+ me._unit = timeOpts.unit || determineUnitForFormatting(ticks, timeOpts.minUnit, me.min, me.max);
+ me._majorUnit = determineMajorUnit(me._unit);
+ me._table = buildLookupTable(me._timestamps.data, min, max, options.distribution);
+ me._offsets = computeOffsets(me._table, ticks, min, max, options);
+
+ return ticksFromTimestamps(ticks, me._majorUnit);
+ },
+
+ getLabelForIndex: function(index, datasetIndex) {
+ var me = this;
+ var data = me.chart.data;
+ var timeOpts = me.options.time;
+ var label = data.labels && index < data.labels.length ? data.labels[index] : '';
+ var value = data.datasets[datasetIndex].data[index];
+
+ if (helpers.isObject(value)) {
+ label = me.getRightValue(value);
+ }
+ if (timeOpts.tooltipFormat) {
+ label = momentify(label, timeOpts).format(timeOpts.tooltipFormat);
+ }
+
+ return label;
+ },
+
+ /**
+ * Function to format an individual tick mark
+ * @private
+ */
+ tickFormatFunction: function(tick, index, ticks, formatOverride) {
+ var me = this;
+ var options = me.options;
+ var time = tick.valueOf();
+ var formats = options.time.displayFormats;
+ var minorFormat = formats[me._unit];
+ var majorUnit = me._majorUnit;
+ var majorFormat = formats[majorUnit];
+ var majorTime = tick.clone().startOf(majorUnit).valueOf();
+ var majorTickOpts = options.ticks.major;
+ var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
+ var label = tick.format(formatOverride ? formatOverride : major ? majorFormat : minorFormat);
+ var tickOpts = major ? majorTickOpts : options.ticks.minor;
+ var formatter = helpers.valueOrDefault(tickOpts.callback, tickOpts.userCallback);
+
+ return formatter ? formatter(label, index, ticks) : label;
+ },
+
+ convertTicksToLabels: function(ticks) {
+ var labels = [];
+ var i, ilen;
+
+ for (i = 0, ilen = ticks.length; i < ilen; ++i) {
+ labels.push(this.tickFormatFunction(moment(ticks[i].value), i, ticks));
+ }
+
+ return labels;
+ },
+
+ /**
+ * @private
+ */
+ getPixelForOffset: function(time) {
+ var me = this;
+ var size = me._horizontal ? me.width : me.height;
+ var start = me._horizontal ? me.left : me.top;
+ var pos = interpolate(me._table, 'time', time, 'pos');
+
+ return start + size * (me._offsets.left + pos) / (me._offsets.left + 1 + me._offsets.right);
+ },
+
+ getPixelForValue: function(value, index, datasetIndex) {
+ var me = this;
+ var time = null;
+
+ if (index !== undefined && datasetIndex !== undefined) {
+ time = me._timestamps.datasets[datasetIndex][index];
+ }
+
+ if (time === null) {
+ time = parse(value, me);
+ }
+
+ if (time !== null) {
+ return me.getPixelForOffset(time);
+ }
+ },
+
+ getPixelForTick: function(index) {
+ var ticks = this.getTicks();
+ return index >= 0 && index < ticks.length ?
+ this.getPixelForOffset(ticks[index].value) :
+ null;
+ },
+
+ getValueForPixel: function(pixel) {
+ var me = this;
+ var size = me._horizontal ? me.width : me.height;
+ var start = me._horizontal ? me.left : me.top;
+ var pos = (size ? (pixel - start) / size : 0) * (me._offsets.left + 1 + me._offsets.left) - me._offsets.right;
+ var time = interpolate(me._table, 'pos', pos, 'time');
+
+ return moment(time);
+ },
+
+ /**
+ * Crude approximation of what the label width might be
+ * @private
+ */
+ getLabelWidth: function(label) {
+ var me = this;
+ var ticksOpts = me.options.ticks;
+ var tickLabelWidth = me.ctx.measureText(label).width;
+ var angle = helpers.toRadians(ticksOpts.maxRotation);
+ var cosRotation = Math.cos(angle);
+ var sinRotation = Math.sin(angle);
+ var tickFontSize = helpers.valueOrDefault(ticksOpts.fontSize, defaults.global.defaultFontSize);
+
+ return (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation);
+ },
+
+ /**
+ * @private
+ */
+ getLabelCapacity: function(exampleTime) {
+ var me = this;
+
+ var formatOverride = me.options.time.displayFormats.millisecond; // Pick the longest format for guestimation
+
+ var exampleLabel = me.tickFormatFunction(moment(exampleTime), 0, [], formatOverride);
+ var tickLabelWidth = me.getLabelWidth(exampleLabel);
+ var innerWidth = me.isHorizontal() ? me.width : me.height;
+
+ return Math.floor(innerWidth / tickLabelWidth);
+ }
+ });
+
+ Chart.scaleService.registerScaleType('time', TimeScale, defaultConfig);
+};
+
+},{"1":1,"25":25,"45":45}]},{},[7])(7)
+}); \ No newline at end of file
diff --git a/main/survey/js/ChartJS/Chart.min.js b/main/survey/js/ChartJS/Chart.min.js
new file mode 100644
index 0000000..08fca4f
--- /dev/null
+++ b/main/survey/js/ChartJS/Chart.min.js
@@ -0,0 +1,10 @@
+/*!
+ * Chart.js
+ * http://chartjs.org/
+ * Version: 2.7.1
+ *
+ * Copyright 2017 Nick Downie
+ * Released under the MIT license
+ * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
+ */
+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Chart=t()}}(function(){return function t(e,n,i){function a(r,l){if(!n[r]){if(!e[r]){var s="function"==typeof require&&require;if(!l&&s)return s(r,!0);if(o)return o(r,!0);var u=new Error("Cannot find module '"+r+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[r]={exports:{}};e[r][0].call(d.exports,function(t){var n=e[r][1][t];return a(n||t)},d,d.exports,t,e,n,i)}return n[r].exports}for(var o="function"==typeof require&&require,r=0;r<i.length;r++)a(i[r]);return a}({1:[function(t,e,n){},{}],2:[function(t,e,n){function i(t){if(t){var e=[0,0,0],n=1,i=t.match(/^#([a-fA-F0-9]{3})$/i);if(i){i=i[1];for(a=0;a<e.length;a++)e[a]=parseInt(i[a]+i[a],16)}else if(i=t.match(/^#([a-fA-F0-9]{6})$/i)){i=i[1];for(a=0;a<e.length;a++)e[a]=parseInt(i.slice(2*a,2*a+2),16)}else if(i=t.match(/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i)){for(a=0;a<e.length;a++)e[a]=parseInt(i[a+1]);n=parseFloat(i[4])}else if(i=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i)){for(a=0;a<e.length;a++)e[a]=Math.round(2.55*parseFloat(i[a+1]));n=parseFloat(i[4])}else if(i=t.match(/(\w+)/)){if("transparent"==i[1])return[0,0,0,0];if(!(e=c[i[1]]))return}for(var a=0;a<e.length;a++)e[a]=u(e[a],0,255);return n=n||0==n?u(n,0,1):1,e[3]=n,e}}function a(t){if(t){var e=t.match(/^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/);if(e){var n=parseFloat(e[4]);return[u(parseInt(e[1]),0,360),u(parseFloat(e[2]),0,100),u(parseFloat(e[3]),0,100),u(isNaN(n)?1:n,0,1)]}}}function o(t){if(t){var e=t.match(/^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/);if(e){var n=parseFloat(e[4]);return[u(parseInt(e[1]),0,360),u(parseFloat(e[2]),0,100),u(parseFloat(e[3]),0,100),u(isNaN(n)?1:n,0,1)]}}}function r(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function l(t,e){return"rgba("+Math.round(t[0]/255*100)+"%, "+Math.round(t[1]/255*100)+"%, "+Math.round(t[2]/255*100)+"%, "+(e||t[3]||1)+")"}function s(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function u(t,e,n){return Math.min(Math.max(e,t),n)}function d(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var c=t(6);e.exports={getRgba:i,getHsla:a,getRgb:function(t){var e=i(t);return e&&e.slice(0,3)},getHsl:function(t){var e=a(t);return e&&e.slice(0,3)},getHwb:o,getAlpha:function(t){var e=i(t);return e?e[3]:(e=a(t))?e[3]:(e=o(t))?e[3]:void 0},hexString:function(t){return"#"+d(t[0])+d(t[1])+d(t[2])},rgbString:function(t,e){return e<1||t[3]&&t[3]<1?r(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"},rgbaString:r,percentString:function(t,e){return e<1||t[3]&&t[3]<1?l(t,e):"rgb("+Math.round(t[0]/255*100)+"%, "+Math.round(t[1]/255*100)+"%, "+Math.round(t[2]/255*100)+"%)"},percentaString:l,hslString:function(t,e){return e<1||t[3]&&t[3]<1?s(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"},hslaString:s,hwbString:function(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"},keyword:function(t){return h[t.slice(0,3)]}};var h={};for(var f in c)h[c[f]]=f},{6:6}],3:[function(t,e,n){var i=t(5),a=t(2),o=function(t){if(t instanceof o)return t;if(!(this instanceof o))return new o(t);this.valid=!1,this.values={rgb:[0,0,0],hsl:[0,0,0],hsv:[0,0,0],hwb:[0,0,0],cmyk:[0,0,0,0],alpha:1};var e;"string"==typeof t?(e=a.getRgba(t))?this.setValues("rgb",e):(e=a.getHsla(t))?this.setValues("hsl",e):(e=a.getHwb(t))&&this.setValues("hwb",e):"object"==typeof t&&(void 0!==(e=t).r||void 0!==e.red?this.setValues("rgb",e):void 0!==e.l||void 0!==e.lightness?this.setValues("hsl",e):void 0!==e.v||void 0!==e.value?this.setValues("hsv",e):void 0!==e.w||void 0!==e.whiteness?this.setValues("hwb",e):void 0===e.c&&void 0===e.cyan||this.setValues("cmyk",e))};o.prototype={isValid:function(){return this.valid},rgb:function(){return this.setSpace("rgb",arguments)},hsl:function(){return this.setSpace("hsl",arguments)},hsv:function(){return this.setSpace("hsv",arguments)},hwb:function(){return this.setSpace("hwb",arguments)},cmyk:function(){return this.setSpace("cmyk",arguments)},rgbArray:function(){return this.values.rgb},hslArray:function(){return this.values.hsl},hsvArray:function(){return this.values.hsv},hwbArray:function(){var t=this.values;return 1!==t.alpha?t.hwb.concat([t.alpha]):t.hwb},cmykArray:function(){return this.values.cmyk},rgbaArray:function(){var t=this.values;return t.rgb.concat([t.alpha])},hslaArray:function(){var t=this.values;return t.hsl.concat([t.alpha])},alpha:function(t){return void 0===t?this.values.alpha:(this.setValues("alpha",t),this)},red:function(t){return this.setChannel("rgb",0,t)},green:function(t){return this.setChannel("rgb",1,t)},blue:function(t){return this.setChannel("rgb",2,t)},hue:function(t){return t&&(t=(t%=360)<0?360+t:t),this.setChannel("hsl",0,t)},saturation:function(t){return this.setChannel("hsl",1,t)},lightness:function(t){return this.setChannel("hsl",2,t)},saturationv:function(t){return this.setChannel("hsv",1,t)},whiteness:function(t){return this.setChannel("hwb",1,t)},blackness:function(t){return this.setChannel("hwb",2,t)},value:function(t){return this.setChannel("hsv",2,t)},cyan:function(t){return this.setChannel("cmyk",0,t)},magenta:function(t){return this.setChannel("cmyk",1,t)},yellow:function(t){return this.setChannel("cmyk",2,t)},black:function(t){return this.setChannel("cmyk",3,t)},hexString:function(){return a.hexString(this.values.rgb)},rgbString:function(){return a.rgbString(this.values.rgb,this.values.alpha)},rgbaString:function(){return a.rgbaString(this.values.rgb,this.values.alpha)},percentString:function(){return a.percentString(this.values.rgb,this.values.alpha)},hslString:function(){return a.hslString(this.values.hsl,this.values.alpha)},hslaString:function(){return a.hslaString(this.values.hsl,this.values.alpha)},hwbString:function(){return a.hwbString(this.values.hwb,this.values.alpha)},keyword:function(){return a.keyword(this.values.rgb,this.values.alpha)},rgbNumber:function(){var t=this.values.rgb;return t[0]<<16|t[1]<<8|t[2]},luminosity:function(){for(var t=this.values.rgb,e=[],n=0;n<t.length;n++){var i=t[n]/255;e[n]=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;e<3;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){var e=this.values.hsl;return e[2]+=e[2]*t,this.setValues("hsl",e),this},darken:function(t){var e=this.values.hsl;return e[2]-=e[2]*t,this.setValues("hsl",e),this},saturate:function(t){var e=this.values.hsl;return e[1]+=e[1]*t,this.setValues("hsl",e),this},desaturate:function(t){var e=this.values.hsl;return e[1]-=e[1]*t,this.setValues("hsl",e),this},whiten:function(t){var e=this.values.hwb;return e[1]+=e[1]*t,this.setValues("hwb",e),this},blacken:function(t){var e=this.values.hwb;return e[2]+=e[2]*t,this.setValues("hwb",e),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){var e=this.values.alpha;return this.setValues("alpha",e-e*t),this},opaquer:function(t){var e=this.values.alpha;return this.setValues("alpha",e+e*t),this},rotate:function(t){var e=this.values.hsl,n=(e[0]+t)%360;return e[0]=n<0?360+n:n,this.setValues("hsl",e),this},mix:function(t,e){var n=this,i=t,a=void 0===e?.5:e,o=2*a-1,r=n.alpha()-i.alpha(),l=((o*r==-1?o:(o+r)/(1+o*r))+1)/2,s=1-l;return this.rgb(l*n.red()+s*i.red(),l*n.green()+s*i.green(),l*n.blue()+s*i.blue()).alpha(n.alpha()*a+i.alpha()*(1-a))},toJSON:function(){return this.rgb()},clone:function(){var t,e,n=new o,i=this.values,a=n.values;for(var r in i)i.hasOwnProperty(r)&&(t=i[r],"[object Array]"===(e={}.toString.call(t))?a[r]=t.slice(0):"[object Number]"===e?a[r]=t:console.error("unexpected color value:",t));return n}},o.prototype.spaces={rgb:["red","green","blue"],hsl:["hue","saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whiteness","blackness"],cmyk:["cyan","magenta","yellow","black"]},o.prototype.maxes={rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,100],cmyk:[100,100,100,100]},o.prototype.getValues=function(t){for(var e=this.values,n={},i=0;i<t.length;i++)n[t.charAt(i)]=e[t][i];return 1!==e.alpha&&(n.a=e.alpha),n},o.prototype.setValues=function(t,e){var n,a=this.values,o=this.spaces,r=this.maxes,l=1;if(this.valid=!0,"alpha"===t)l=e;else if(e.length)a[t]=e.slice(0,t.length),l=e[t.length];else if(void 0!==e[t.charAt(0)]){for(n=0;n<t.length;n++)a[t][n]=e[t.charAt(n)];l=e.a}else if(void 0!==e[o[t][0]]){var s=o[t];for(n=0;n<t.length;n++)a[t][n]=e[s[n]];l=e.alpha}if(a.alpha=Math.max(0,Math.min(1,void 0===l?a.alpha:l)),"alpha"===t)return!1;var u;for(n=0;n<t.length;n++)u=Math.max(0,Math.min(r[t][n],a[t][n])),a[t][n]=Math.round(u);for(var d in o)d!==t&&(a[d]=i[t][d](a[t]));return!0},o.prototype.setSpace=function(t,e){var n=e[0];return void 0===n?this.getValues(t):("number"==typeof n&&(n=Array.prototype.slice.call(e)),this.setValues(t,n),this)},o.prototype.setChannel=function(t,e,n){var i=this.values[t];return void 0===n?i[e]:n===i[e]?this:(i[e]=n,this.setValues(t,i),this)},"undefined"!=typeof window&&(window.Color=o),e.exports=o},{2:2,5:5}],4:[function(t,e,n){function i(t){var e,n,i,a=t[0]/255,o=t[1]/255,r=t[2]/255,l=Math.min(a,o,r),s=Math.max(a,o,r),u=s-l;return s==l?e=0:a==s?e=(o-r)/u:o==s?e=2+(r-a)/u:r==s&&(e=4+(a-o)/u),(e=Math.min(60*e,360))<0&&(e+=360),i=(l+s)/2,n=s==l?0:i<=.5?u/(s+l):u/(2-s-l),[e,100*n,100*i]}function a(t){var e,n,i,a=t[0],o=t[1],r=t[2],l=Math.min(a,o,r),s=Math.max(a,o,r),u=s-l;return n=0==s?0:u/s*1e3/10,s==l?e=0:a==s?e=(o-r)/u:o==s?e=2+(r-a)/u:r==s&&(e=4+(a-o)/u),(e=Math.min(60*e,360))<0&&(e+=360),i=s/255*1e3/10,[e,n,i]}function o(t){var e=t[0],n=t[1],a=t[2];return[i(t)[0],100*(1/255*Math.min(e,Math.min(n,a))),100*(a=1-1/255*Math.max(e,Math.max(n,a)))]}function l(t){var e,n,i,a,o=t[0]/255,r=t[1]/255,l=t[2]/255;return a=Math.min(1-o,1-r,1-l),e=(1-o-a)/(1-a)||0,n=(1-r-a)/(1-a)||0,i=(1-l-a)/(1-a)||0,[100*e,100*n,100*i,100*a]}function s(t){return C[JSON.stringify(t)]}function u(t){var e=t[0]/255,n=t[1]/255,i=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92)),100*(.2126*e+.7152*n+.0722*i),100*(.0193*e+.1192*n+.9505*i)]}function d(t){var e,n,i,a=u(t),o=a[0],r=a[1],l=a[2];return o/=95.047,r/=100,l/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,l=l>.008856?Math.pow(l,1/3):7.787*l+16/116,e=116*r-16,n=500*(o-r),i=200*(r-l),[e,n,i]}function c(t){var e,n,i,a,o,r=t[0]/360,l=t[1]/100,s=t[2]/100;if(0==l)return o=255*s,[o,o,o];e=2*s-(n=s<.5?s*(1+l):s+l-s*l),a=[0,0,0];for(var u=0;u<3;u++)(i=r+1/3*-(u-1))<0&&i++,i>1&&i--,o=6*i<1?e+6*(n-e)*i:2*i<1?n:3*i<2?e+(n-e)*(2/3-i)*6:e,a[u]=255*o;return a}function h(t){var e=t[0]/60,n=t[1]/100,i=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),r=255*i*(1-n),l=255*i*(1-n*o),s=255*i*(1-n*(1-o)),i=255*i;switch(a){case 0:return[i,s,r];case 1:return[l,i,r];case 2:return[r,i,s];case 3:return[r,l,i];case 4:return[s,r,i];case 5:return[i,r,l]}}function f(t){var e,n,i,a,o=t[0]/360,l=t[1]/100,s=t[2]/100,u=l+s;switch(u>1&&(l/=u,s/=u),e=Math.floor(6*o),n=1-s,i=6*o-e,0!=(1&e)&&(i=1-i),a=l+i*(n-l),e){default:case 6:case 0:r=n,g=a,b=l;break;case 1:r=a,g=n,b=l;break;case 2:r=l,g=n,b=a;break;case 3:r=l,g=a,b=n;break;case 4:r=a,g=l,b=n;break;case 5:r=n,g=l,b=a}return[255*r,255*g,255*b]}function p(t){var e,n,i,a=t[0]/100,o=t[1]/100,r=t[2]/100,l=t[3]/100;return e=1-Math.min(1,a*(1-l)+l),n=1-Math.min(1,o*(1-l)+l),i=1-Math.min(1,r*(1-l)+l),[255*e,255*n,255*i]}function v(t){var e,n,i,a=t[0]/100,o=t[1]/100,r=t[2]/100;return e=3.2406*a+-1.5372*o+-.4986*r,n=-.9689*a+1.8758*o+.0415*r,i=.0557*a+-.204*o+1.057*r,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e*=12.92,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n*=12.92,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*=12.92,e=Math.min(Math.max(0,e),1),n=Math.min(Math.max(0,n),1),i=Math.min(Math.max(0,i),1),[255*e,255*n,255*i]}function m(t){var e,n,i,a=t[0],o=t[1],r=t[2];return a/=95.047,o/=100,r/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,n=500*(a-o),i=200*(o-r),[e,n,i]}function x(t){var e,n,i,a,o=t[0],r=t[1],l=t[2];return o<=8?a=(n=100*o/903.3)/100*7.787+16/116:(n=100*Math.pow((o+16)/116,3),a=Math.pow(n/100,1/3)),e=e/95.047<=.008856?e=95.047*(r/500+a-16/116)/7.787:95.047*Math.pow(r/500+a,3),i=i/108.883<=.008859?i=108.883*(a-l/200-16/116)/7.787:108.883*Math.pow(a-l/200,3),[e,n,i]}function y(t){var e,n,i,a=t[0],o=t[1],r=t[2];return e=Math.atan2(r,o),(n=360*e/2/Math.PI)<0&&(n+=360),i=Math.sqrt(o*o+r*r),[a,i,n]}function k(t){return v(x(t))}function w(t){var e,n,i,a=t[0],o=t[1];return i=t[2]/360*2*Math.PI,e=o*Math.cos(i),n=o*Math.sin(i),[a,e,n]}function M(t){return S[t]}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:o,rgb2cmyk:l,rgb2keyword:s,rgb2xyz:u,rgb2lab:d,rgb2lch:function(t){return y(d(t))},hsl2rgb:c,hsl2hsv:function(t){var e,n,i=t[0],a=t[1]/100,o=t[2]/100;return 0===o?[0,0,0]:(o*=2,a*=o<=1?o:2-o,n=(o+a)/2,e=2*a/(o+a),[i,100*e,100*n])},hsl2hwb:function(t){return o(c(t))},hsl2cmyk:function(t){return l(c(t))},hsl2keyword:function(t){return s(c(t))},hsv2rgb:h,hsv2hsl:function(t){var e,n,i=t[0],a=t[1]/100,o=t[2]/100;return n=(2-a)*o,e=a*o,e/=n<=1?n:2-n,e=e||0,n/=2,[i,100*e,100*n]},hsv2hwb:function(t){return o(h(t))},hsv2cmyk:function(t){return l(h(t))},hsv2keyword:function(t){return s(h(t))},hwb2rgb:f,hwb2hsl:function(t){return i(f(t))},hwb2hsv:function(t){return a(f(t))},hwb2cmyk:function(t){return l(f(t))},hwb2keyword:function(t){return s(f(t))},cmyk2rgb:p,cmyk2hsl:function(t){return i(p(t))},cmyk2hsv:function(t){return a(p(t))},cmyk2hwb:function(t){return o(p(t))},cmyk2keyword:function(t){return s(p(t))},keyword2rgb:M,keyword2hsl:function(t){return i(M(t))},keyword2hsv:function(t){return a(M(t))},keyword2hwb:function(t){return o(M(t))},keyword2cmyk:function(t){return l(M(t))},keyword2lab:function(t){return d(M(t))},keyword2xyz:function(t){return u(M(t))},xyz2rgb:v,xyz2lab:m,xyz2lch:function(t){return y(m(t))},lab2xyz:x,lab2rgb:k,lab2lch:y,lch2lab:w,lch2xyz:function(t){return x(w(t))},lch2rgb:function(t){return k(w(t))}};var S={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},C={};for(var _ in S)C[JSON.stringify(S[_])]=_},{}],5:[function(t,e,n){var i=t(4),a=function(){return new u};for(var o in i){a[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(o);var r=/(\w+)2(\w+)/.exec(o),l=r[1],s=r[2];(a[l]=a[l]||{})[s]=a[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var n=i[t](e);if("string"==typeof n||void 0===n)return n;for(var a=0;a<n.length;a++)n[a]=Math.round(n[a]);return n}}(o)}var u=function(){this.convs={}};u.prototype.routeSpace=function(t,e){var n=e[0];return void 0===n?this.getValues(t):("number"==typeof n&&(n=Array.prototype.slice.call(e)),this.setValues(t,n))},u.prototype.setValues=function(t,e){return this.space=t,this.convs={},this.convs[t]=e,this},u.prototype.getValues=function(t){var e=this.convs[t];if(!e){var n=this.space,i=this.convs[n];e=a[n][t](i),this.convs[t]=e}return e},["rgb","hsl","hsv","cmyk","keyword"].forEach(function(t){u.prototype[t]=function(e){return this.routeSpace(t,arguments)}}),e.exports=a},{4:4}],6:[function(t,e,n){"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],7:[function(t,e,n){var i=t(29)();i.helpers=t(45),t(27)(i),i.defaults=t(25),i.Element=t(26),i.elements=t(40),i.Interaction=t(28),i.platform=t(48),t(31)(i),t(22)(i),t(23)(i),t(24)(i),t(30)(i),t(33)(i),t(32)(i),t(35)(i),t(54)(i),t(52)(i),t(53)(i),t(55)(i),t(56)(i),t(57)(i),t(15)(i),t(16)(i),t(17)(i),t(18)(i),t(19)(i),t(20)(i),t(21)(i),t(8)(i),t(9)(i),t(10)(i),t(11)(i),t(12)(i),t(13)(i),t(14)(i);var a=[];a.push(t(49)(i),t(50)(i),t(51)(i)),i.plugins.register(a),i.platform.initialize(),e.exports=i,"undefined"!=typeof window&&(window.Chart=i),i.canvasHelpers=i.helpers.canvas},{10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,29:29,30:30,31:31,32:32,33:33,35:35,40:40,45:45,48:48,49:49,50:50,51:51,52:52,53:53,54:54,55:55,56:56,57:57,8:8,9:9}],8:[function(t,e,n){"use strict";e.exports=function(t){t.Bar=function(e,n){return n.type="bar",new t(e,n)}}},{}],9:[function(t,e,n){"use strict";e.exports=function(t){t.Bubble=function(e,n){return n.type="bubble",new t(e,n)}}},{}],10:[function(t,e,n){"use strict";e.exports=function(t){t.Doughnut=function(e,n){return n.type="doughnut",new t(e,n)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t){t.Line=function(e,n){return n.type="line",new t(e,n)}}},{}],12:[function(t,e,n){"use strict";e.exports=function(t){t.PolarArea=function(e,n){return n.type="polarArea",new t(e,n)}}},{}],13:[function(t,e,n){"use strict";e.exports=function(t){t.Radar=function(e,n){return n.type="radar",new t(e,n)}}},{}],14:[function(t,e,n){"use strict";e.exports=function(t){t.Scatter=function(e,n){return n.type="scatter",new t(e,n)}}},{}],15:[function(t,e,n){"use strict";var i=t(25),a=t(40),o=t(45);i._set("bar",{hover:{mode:"label"},scales:{xAxes:[{type:"category",categoryPercentage:.8,barPercentage:.9,offset:!0,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}}),i._set("horizontalBar",{hover:{mode:"index",axis:"y"},scales:{xAxes:[{type:"linear",position:"bottom"}],yAxes:[{position:"left",type:"category",categoryPercentage:.8,barPercentage:.9,offset:!0,gridLines:{offsetGridLines:!0}}]},elements:{rectangle:{borderSkipped:"left"}},tooltips:{callbacks:{title:function(t,e){var n="";return t.length>0&&(t[0].yLabel?n=t[0].yLabel:e.labels.length>0&&t[0].index<e.labels.length&&(n=e.labels[t[0].index])),n},label:function(t,e){return(e.datasets[t.datasetIndex].label||"")+": "+t.xLabel}},mode:"index",axis:"y"}}),e.exports=function(t){t.controllers.bar=t.DatasetController.extend({dataElementType:a.Rectangle,initialize:function(){var e,n=this;t.DatasetController.prototype.initialize.apply(n,arguments),(e=n.getMeta()).stack=n.getDataset().stack,e.bar=!0},update:function(t){var e,n,i=this,a=i.getMeta().data;for(i._ruler=i.getRuler(),e=0,n=a.length;e<n;++e)i.updateElement(a[e],e,t)},updateElement:function(t,e,n){var i=this,a=i.chart,r=i.getMeta(),l=i.getDataset(),s=t.custom||{},u=a.options.elements.rectangle;t._xScale=i.getScaleForId(r.xAxisID),t._yScale=i.getScaleForId(r.yAxisID),t._datasetIndex=i.index,t._index=e,t._model={datasetLabel:l.label,label:a.data.labels[e],borderSkipped:s.borderSkipped?s.borderSkipped:u.borderSkipped,backgroundColor:s.backgroundColor?s.backgroundColor:o.valueAtIndexOrDefault(l.backgroundColor,e,u.backgroundColor),borderColor:s.borderColor?s.borderColor:o.valueAtIndexOrDefault(l.borderColor,e,u.borderColor),borderWidth:s.borderWidth?s.borderWidth:o.valueAtIndexOrDefault(l.borderWidth,e,u.borderWidth)},i.updateElementGeometry(t,e,n),t.pivot()},updateElementGeometry:function(t,e,n){var i=this,a=t._model,o=i.getValueScale(),r=o.getBasePixel(),l=o.isHorizontal(),s=i._ruler||i.getRuler(),u=i.calculateBarValuePixels(i.index,e),d=i.calculateBarIndexPixels(i.index,e,s);a.horizontal=l,a.base=n?r:u.base,a.x=l?n?r:u.head:d.center,a.y=l?d.center:n?r:u.head,a.height=l?d.size:void 0,a.width=l?void 0:d.size},getValueScaleId:function(){return this.getMeta().yAxisID},getIndexScaleId:function(){return this.getMeta().xAxisID},getValueScale:function(){return this.getScaleForId(this.getValueScaleId())},getIndexScale:function(){return this.getScaleForId(this.getIndexScaleId())},getStackCount:function(t){var e,n,i=this,a=i.chart,o=i.getIndexScale().options.stacked,r=void 0===t?a.data.datasets.length:t+1,l=[];for(e=0;e<r;++e)(n=a.getDatasetMeta(e)).bar&&a.isDatasetVisible(e)&&(!1===o||!0===o&&-1===l.indexOf(n.stack)||void 0===o&&(void 0===n.stack||-1===l.indexOf(n.stack)))&&l.push(n.stack);return l.length},getStackIndex:function(t){return this.getStackCount(t)-1},getRuler:function(){var t,e,n=this,i=n.getIndexScale(),a=n.getStackCount(),o=n.index,r=[],l=i.isHorizontal(),s=l?i.left:i.top,u=s+(l?i.width:i.height);for(t=0,e=n.getMeta().data.length;t<e;++t)r.push(i.getPixelForValue(null,t,o));return{pixels:r,start:s,end:u,stackCount:a,scale:i}},calculateBarValuePixels:function(t,e){var n,i,a,o,r,l,s=this,u=s.chart,d=s.getMeta(),c=s.getValueScale(),h=u.data.datasets,f=c.getRightValue(h[t].data[e]),g=c.options.stacked,p=d.stack,v=0;if(g||void 0===g&&void 0!==p)for(n=0;n<t;++n)(i=u.getDatasetMeta(n)).bar&&i.stack===p&&i.controller.getValueScaleId()===c.id&&u.isDatasetVisible(n)&&(a=c.getRightValue(h[n].data[e]),(f<0&&a<0||f>=0&&a>0)&&(v+=a));return o=c.getPixelForValue(v),r=c.getPixelForValue(v+f),l=(r-o)/2,{size:l,base:o,head:r,center:r+l/2}},calculateBarIndexPixels:function(t,e,n){var i,a,r,l,s,u,d=this,c=n.scale.options,h=d.getStackIndex(t),f=n.pixels,g=f[e],p=f.length,v=n.start,m=n.end;return 1===p?(i=g>v?g-v:m-g,a=g<m?m-g:g-v):(e>0&&(i=(g-f[e-1])/2,e===p-1&&(a=i)),e<p-1&&(a=(f[e+1]-g)/2,0===e&&(i=a))),r=i*c.categoryPercentage,l=a*c.categoryPercentage,s=(r+l)/n.stackCount,u=s*c.barPercentage,u=Math.min(o.valueOrDefault(c.barThickness,u),o.valueOrDefault(c.maxBarThickness,1/0)),g-=r,g+=s*h,g+=(s-u)/2,{size:u,base:g,head:g+u,center:g+u/2}},draw:function(){var t=this,e=t.chart,n=t.getValueScale(),i=t.getMeta().data,a=t.getDataset(),r=i.length,l=0;for(o.canvas.clipArea(e.ctx,e.chartArea);l<r;++l)isNaN(n.getRightValue(a.data[l]))||i[l].draw();o.canvas.unclipArea(e.ctx)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,i=t.custom||{},a=t._model;a.backgroundColor=i.hoverBackgroundColor?i.hoverBackgroundColor:o.valueAtIndexOrDefault(e.hoverBackgroundColor,n,o.getHoverColor(a.backgroundColor)),a.borderColor=i.hoverBorderColor?i.hoverBorderColor:o.valueAtIndexOrDefault(e.hoverBorderColor,n,o.getHoverColor(a.borderColor)),a.borderWidth=i.hoverBorderWidth?i.hoverBorderWidth:o.valueAtIndexOrDefault(e.hoverBorderWidth,n,a.borderWidth)},removeHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,i=t.custom||{},a=t._model,r=this.chart.options.elements.rectangle;a.backgroundColor=i.backgroundColor?i.backgroundColor:o.valueAtIndexOrDefault(e.backgroundColor,n,r.backgroundColor),a.borderColor=i.borderColor?i.borderColor:o.valueAtIndexOrDefault(e.borderColor,n,r.borderColor),a.borderWidth=i.borderWidth?i.borderWidth:o.valueAtIndexOrDefault(e.borderWidth,n,r.borderWidth)}}),t.controllers.horizontalBar=t.controllers.bar.extend({getValueScaleId:function(){return this.getMeta().xAxisID},getIndexScaleId:function(){return this.getMeta().yAxisID}})}},{25:25,40:40,45:45}],16:[function(t,e,n){"use strict";var i=t(25),a=t(40),o=t(45);i._set("bubble",{hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-0"}],yAxes:[{type:"linear",position:"left",id:"y-axis-0"}]},tooltips:{callbacks:{title:function(){return""},label:function(t,e){var n=e.datasets[t.datasetIndex].label||"",i=e.datasets[t.datasetIndex].data[t.index];return n+": ("+t.xLabel+", "+t.yLabel+", "+i.r+")"}}}}),e.exports=function(t){t.controllers.bubble=t.DatasetController.extend({dataElementType:a.Point,update:function(t){var e=this,n=e.getMeta().data;o.each(n,function(n,i){e.updateElement(n,i,t)})},updateElement:function(t,e,n){var i=this,a=i.getMeta(),o=t.custom||{},r=i.getScaleForId(a.xAxisID),l=i.getScaleForId(a.yAxisID),s=i._resolveElementOptions(t,e),u=i.getDataset().data[e],d=i.index,c=n?r.getPixelForDecimal(.5):r.getPixelForValue("object"==typeof u?u:NaN,e,d),h=n?l.getBasePixel():l.getPixelForValue(u,e,d);t._xScale=r,t._yScale=l,t._options=s,t._datasetIndex=d,t._index=e,t._model={backgroundColor:s.backgroundColor,borderColor:s.borderColor,borderWidth:s.borderWidth,hitRadius:s.hitRadius,pointStyle:s.pointStyle,radius:n?0:s.radius,skip:o.skip||isNaN(c)||isNaN(h),x:c,y:h},t.pivot()},setHoverStyle:function(t){var e=t._model,n=t._options;e.backgroundColor=o.valueOrDefault(n.hoverBackgroundColor,o.getHoverColor(n.backgroundColor)),e.borderColor=o.valueOrDefault(n.hoverBorderColor,o.getHoverColor(n.borderColor)),e.borderWidth=o.valueOrDefault(n.hoverBorderWidth,n.borderWidth),e.radius=n.radius+n.hoverRadius},removeHoverStyle:function(t){var e=t._model,n=t._options;e.backgroundColor=n.backgroundColor,e.borderColor=n.borderColor,e.borderWidth=n.borderWidth,e.radius=n.radius},_resolveElementOptions:function(t,e){var n,i,a,r=this,l=r.chart,s=l.data.datasets[r.index],u=t.custom||{},d=l.options.elements.point,c=o.options.resolve,h=s.data[e],f={},g={chart:l,dataIndex:e,dataset:s,datasetIndex:r.index},p=["backgroundColor","borderColor","borderWidth","hoverBackgroundColor","hoverBorderColor","hoverBorderWidth","hoverRadius","hitRadius","pointStyle"];for(n=0,i=p.length;n<i;++n)f[a=p[n]]=c([u[a],s[a],d[a]],g,e);return f.radius=c([u.radius,h?h.r:void 0,s.radius,d.radius],g,e),f}})}},{25:25,40:40,45:45}],17:[function(t,e,n){"use strict";var i=t(25),a=t(40),o=t(45);i._set("doughnut",{animation:{animateRotate:!0,animateScale:!1},hover:{mode:"single"},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var n=t.data,i=n.datasets,a=n.labels;if(i.length)for(var o=0;o<i[0].data.length;++o)e.push('<li><span style="background-color:'+i[0].backgroundColor[o]+'"></span>'),a[o]&&e.push(a[o]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var e=t.data;return e.labels.length&&e.datasets.length?e.labels.map(function(n,i){var a=t.getDatasetMeta(0),r=e.datasets[0],l=a.data[i],s=l&&l.custom||{},u=o.valueAtIndexOrDefault,d=t.options.elements.arc;return{text:n,fillStyle:s.backgroundColor?s.backgroundColor:u(r.backgroundColor,i,d.backgroundColor),strokeStyle:s.borderColor?s.borderColor:u(r.borderColor,i,d.borderColor),lineWidth:s.borderWidth?s.borderWidth:u(r.borderWidth,i,d.borderWidth),hidden:isNaN(r.data[i])||a.data[i].hidden,index:i}}):[]}},onClick:function(t,e){var n,i,a,o=e.index,r=this.chart;for(n=0,i=(r.data.datasets||[]).length;n<i;++n)(a=r.getDatasetMeta(n)).data[o]&&(a.data[o].hidden=!a.data[o].hidden);r.update()}},cutoutPercentage:50,rotation:-.5*Math.PI,circumference:2*Math.PI,tooltips:{callbacks:{title:function(){return""},label:function(t,e){var n=e.labels[t.index],i=": "+e.datasets[t.datasetIndex].data[t.index];return o.isArray(n)?(n=n.slice())[0]+=i:n+=i,n}}}}),i._set("pie",o.clone(i.doughnut)),i._set("pie",{cutoutPercentage:0}),e.exports=function(t){t.controllers.doughnut=t.controllers.pie=t.DatasetController.extend({dataElementType:a.Arc,linkScales:o.noop,getRingIndex:function(t){for(var e=0,n=0;n<t;++n)this.chart.isDatasetVisible(n)&&++e;return e},update:function(t){var e=this,n=e.chart,i=n.chartArea,a=n.options,r=a.elements.arc,l=i.right-i.left-r.borderWidth,s=i.bottom-i.top-r.borderWidth,u=Math.min(l,s),d={x:0,y:0},c=e.getMeta(),h=a.cutoutPercentage,f=a.circumference;if(f<2*Math.PI){var g=a.rotation%(2*Math.PI),p=(g+=2*Math.PI*(g>=Math.PI?-1:g<-Math.PI?1:0))+f,v={x:Math.cos(g),y:Math.sin(g)},m={x:Math.cos(p),y:Math.sin(p)},b=g<=0&&p>=0||g<=2*Math.PI&&2*Math.PI<=p,x=g<=.5*Math.PI&&.5*Math.PI<=p||g<=2.5*Math.PI&&2.5*Math.PI<=p,y=g<=-Math.PI&&-Math.PI<=p||g<=Math.PI&&Math.PI<=p,k=g<=.5*-Math.PI&&.5*-Math.PI<=p||g<=1.5*Math.PI&&1.5*Math.PI<=p,w=h/100,M={x:y?-1:Math.min(v.x*(v.x<0?1:w),m.x*(m.x<0?1:w)),y:k?-1:Math.min(v.y*(v.y<0?1:w),m.y*(m.y<0?1:w))},S={x:b?1:Math.max(v.x*(v.x>0?1:w),m.x*(m.x>0?1:w)),y:x?1:Math.max(v.y*(v.y>0?1:w),m.y*(m.y>0?1:w))},C={width:.5*(S.x-M.x),height:.5*(S.y-M.y)};u=Math.min(l/C.width,s/C.height),d={x:-.5*(S.x+M.x),y:-.5*(S.y+M.y)}}n.borderWidth=e.getMaxBorderWidth(c.data),n.outerRadius=Math.max((u-n.borderWidth)/2,0),n.innerRadius=Math.max(h?n.outerRadius/100*h:0,0),n.radiusLength=(n.outerRadius-n.innerRadius)/n.getVisibleDatasetCount(),n.offsetX=d.x*n.outerRadius,n.offsetY=d.y*n.outerRadius,c.total=e.calculateTotal(),e.outerRadius=n.outerRadius-n.radiusLength*e.getRingIndex(e.index),e.innerRadius=Math.max(e.outerRadius-n.radiusLength,0),o.each(c.data,function(n,i){e.updateElement(n,i,t)})},updateElement:function(t,e,n){var i=this,a=i.chart,r=a.chartArea,l=a.options,s=l.animation,u=(r.left+r.right)/2,d=(r.top+r.bottom)/2,c=l.rotation,h=l.rotation,f=i.getDataset(),g=n&&s.animateRotate?0:t.hidden?0:i.calculateCircumference(f.data[e])*(l.circumference/(2*Math.PI)),p=n&&s.animateScale?0:i.innerRadius,v=n&&s.animateScale?0:i.outerRadius,m=o.valueAtIndexOrDefault;o.extend(t,{_datasetIndex:i.index,_index:e,_model:{x:u+a.offsetX,y:d+a.offsetY,startAngle:c,endAngle:h,circumference:g,outerRadius:v,innerRadius:p,label:m(f.label,e,a.data.labels[e])}});var b=t._model;this.removeHoverStyle(t),n&&s.animateRotate||(b.startAngle=0===e?l.rotation:i.getMeta().data[e-1]._model.endAngle,b.endAngle=b.startAngle+b.circumference),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},calculateTotal:function(){var t,e=this.getDataset(),n=this.getMeta(),i=0;return o.each(n.data,function(n,a){t=e.data[a],isNaN(t)||n.hidden||(i+=Math.abs(t))}),i},calculateCircumference:function(t){var e=this.getMeta().total;return e>0&&!isNaN(t)?2*Math.PI*(t/e):0},getMaxBorderWidth:function(t){for(var e,n,i=0,a=this.index,o=t.length,r=0;r<o;r++)e=t[r]._model?t[r]._model.borderWidth:0,i=(n=t[r]._chart?t[r]._chart.config.data.datasets[a].hoverBorderWidth:0)>(i=e>i?e:i)?n:i;return i}})}},{25:25,40:40,45:45}],18:[function(t,e,n){"use strict";var i=t(25),a=t(40),o=t(45);i._set("line",{showLines:!0,spanGaps:!1,hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}}),e.exports=function(t){function e(t,e){return o.valueOrDefault(t.showLine,e.showLines)}t.controllers.line=t.DatasetController.extend({datasetElementType:a.Line,dataElementType:a.Point,update:function(t){var n,i,a,r=this,l=r.getMeta(),s=l.dataset,u=l.data||[],d=r.chart.options,c=d.elements.line,h=r.getScaleForId(l.yAxisID),f=r.getDataset(),g=e(f,d);for(g&&(a=s.custom||{},void 0!==f.tension&&void 0===f.lineTension&&(f.lineTension=f.tension),s._scale=h,s._datasetIndex=r.index,s._children=u,s._model={spanGaps:f.spanGaps?f.spanGaps:d.spanGaps,tension:a.tension?a.tension:o.valueOrDefault(f.lineTension,c.tension),backgroundColor:a.backgroundColor?a.backgroundColor:f.backgroundColor||c.backgroundColor,borderWidth:a.borderWidth?a.borderWidth:f.borderWidth||c.borderWidth,borderColor:a.borderColor?a.borderColor:f.borderColor||c.borderColor,borderCapStyle:a.borderCapStyle?a.borderCapStyle:f.borderCapStyle||c.borderCapStyle,borderDash:a.borderDash?a.borderDash:f.borderDash||c.borderDash,borderDashOffset:a.borderDashOffset?a.borderDashOffset:f.borderDashOffset||c.borderDashOffset,borderJoinStyle:a.borderJoinStyle?a.borderJoinStyle:f.borderJoinStyle||c.borderJoinStyle,fill:a.fill?a.fill:void 0!==f.fill?f.fill:c.fill,steppedLine:a.steppedLine?a.steppedLine:o.valueOrDefault(f.steppedLine,c.stepped),cubicInterpolationMode:a.cubicInterpolationMode?a.cubicInterpolationMode:o.valueOrDefault(f.cubicInterpolationMode,c.cubicInterpolationMode)},s.pivot()),n=0,i=u.length;n<i;++n)r.updateElement(u[n],n,t);for(g&&0!==s._model.tension&&r.updateBezierControlPoints(),n=0,i=u.length;n<i;++n)u[n].pivot()},getPointBackgroundColor:function(t,e){var n=this.chart.options.elements.point.backgroundColor,i=this.getDataset(),a=t.custom||{};return a.backgroundColor?n=a.backgroundColor:i.pointBackgroundColor?n=o.valueAtIndexOrDefault(i.pointBackgroundColor,e,n):i.backgroundColor&&(n=i.backgroundColor),n},getPointBorderColor:function(t,e){var n=this.chart.options.elements.point.borderColor,i=this.getDataset(),a=t.custom||{};return a.borderColor?n=a.borderColor:i.pointBorderColor?n=o.valueAtIndexOrDefault(i.pointBorderColor,e,n):i.borderColor&&(n=i.borderColor),n},getPointBorderWidth:function(t,e){var n=this.chart.options.elements.point.borderWidth,i=this.getDataset(),a=t.custom||{};return isNaN(a.borderWidth)?!isNaN(i.pointBorderWidth)||o.isArray(i.pointBorderWidth)?n=o.valueAtIndexOrDefault(i.pointBorderWidth,e,n):isNaN(i.borderWidth)||(n=i.borderWidth):n=a.borderWidth,n},updateElement:function(t,e,n){var i,a,r=this,l=r.getMeta(),s=t.custom||{},u=r.getDataset(),d=r.index,c=u.data[e],h=r.getScaleForId(l.yAxisID),f=r.getScaleForId(l.xAxisID),g=r.chart.options.elements.point;void 0!==u.radius&&void 0===u.pointRadius&&(u.pointRadius=u.radius),void 0!==u.hitRadius&&void 0===u.pointHitRadius&&(u.pointHitRadius=u.hitRadius),i=f.getPixelForValue("object"==typeof c?c:NaN,e,d),a=n?h.getBasePixel():r.calculatePointY(c,e,d),t._xScale=f,t._yScale=h,t._datasetIndex=d,t._index=e,t._model={x:i,y:a,skip:s.skip||isNaN(i)||isNaN(a),radius:s.radius||o.valueAtIndexOrDefault(u.pointRadius,e,g.radius),pointStyle:s.pointStyle||o.valueAtIndexOrDefault(u.pointStyle,e,g.pointStyle),backgroundColor:r.getPointBackgroundColor(t,e),borderColor:r.getPointBorderColor(t,e),borderWidth:r.getPointBorderWidth(t,e),tension:l.dataset._model?l.dataset._model.tension:0,steppedLine:!!l.dataset._model&&l.dataset._model.steppedLine,hitRadius:s.hitRadius||o.valueAtIndexOrDefault(u.pointHitRadius,e,g.hitRadius)}},calculatePointY:function(t,e,n){var i,a,o,r=this,l=r.chart,s=r.getMeta(),u=r.getScaleForId(s.yAxisID),d=0,c=0;if(u.options.stacked){for(i=0;i<n;i++)if(a=l.data.datasets[i],"line"===(o=l.getDatasetMeta(i)).type&&o.yAxisID===u.id&&l.isDatasetVisible(i)){var h=Number(u.getRightValue(a.data[e]));h<0?c+=h||0:d+=h||0}var f=Number(u.getRightValue(t));return f<0?u.getPixelForValue(c+f):u.getPixelForValue(d+f)}return u.getPixelForValue(t)},updateBezierControlPoints:function(){function t(t,e,n){return Math.max(Math.min(t,n),e)}var e,n,i,a,r=this,l=r.getMeta(),s=r.chart.chartArea,u=l.data||[];if(l.dataset._model.spanGaps&&(u=u.filter(function(t){return!t._model.skip})),"monotone"===l.dataset._model.cubicInterpolationMode)o.splineCurveMonotone(u);else for(e=0,n=u.length;e<n;++e)i=u[e]._model,a=o.splineCurve(o.previousItem(u,e)._model,i,o.nextItem(u,e)._model,l.dataset._model.tension),i.controlPointPreviousX=a.previous.x,i.controlPointPreviousY=a.previous.y,i.controlPointNextX=a.next.x,i.controlPointNextY=a.next.y;if(r.chart.options.elements.line.capBezierPoints)for(e=0,n=u.length;e<n;++e)(i=u[e]._model).controlPointPreviousX=t(i.controlPointPreviousX,s.left,s.right),i.controlPointPreviousY=t(i.controlPointPreviousY,s.top,s.bottom),i.controlPointNextX=t(i.controlPointNextX,s.left,s.right),i.controlPointNextY=t(i.controlPointNextY,s.top,s.bottom)},draw:function(){var t=this,n=t.chart,i=t.getMeta(),a=i.data||[],r=n.chartArea,l=a.length,s=0;for(o.canvas.clipArea(n.ctx,r),e(t.getDataset(),n.options)&&i.dataset.draw(),o.canvas.unclipArea(n.ctx);s<l;++s)a[s].draw(r)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,i=t.custom||{},a=t._model;a.radius=i.hoverRadius||o.valueAtIndexOrDefault(e.pointHoverRadius,n,this.chart.options.elements.point.hoverRadius),a.backgroundColor=i.hoverBackgroundColor||o.valueAtIndexOrDefault(e.pointHoverBackgroundColor,n,o.getHoverColor(a.backgroundColor)),a.borderColor=i.hoverBorderColor||o.valueAtIndexOrDefault(e.pointHoverBorderColor,n,o.getHoverColor(a.borderColor)),a.borderWidth=i.hoverBorderWidth||o.valueAtIndexOrDefault(e.pointHoverBorderWidth,n,a.borderWidth)},removeHoverStyle:function(t){var e=this,n=e.chart.data.datasets[t._datasetIndex],i=t._index,a=t.custom||{},r=t._model;void 0!==n.radius&&void 0===n.pointRadius&&(n.pointRadius=n.radius),r.radius=a.radius||o.valueAtIndexOrDefault(n.pointRadius,i,e.chart.options.elements.point.radius),r.backgroundColor=e.getPointBackgroundColor(t,i),r.borderColor=e.getPointBorderColor(t,i),r.borderWidth=e.getPointBorderWidth(t,i)}})}},{25:25,40:40,45:45}],19:[function(t,e,n){"use strict";var i=t(25),a=t(40),o=t(45);i._set("polarArea",{scale:{type:"radialLinear",angleLines:{display:!1},gridLines:{circular:!0},pointLabels:{display:!1},ticks:{beginAtZero:!0}},animation:{animateRotate:!0,animateScale:!0},startAngle:-.5*Math.PI,legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var n=t.data,i=n.datasets,a=n.labels;if(i.length)for(var o=0;o<i[0].data.length;++o)e.push('<li><span style="background-color:'+i[0].backgroundColor[o]+'"></span>'),a[o]&&e.push(a[o]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var e=t.data;return e.labels.length&&e.datasets.length?e.labels.map(function(n,i){var a=t.getDatasetMeta(0),r=e.datasets[0],l=a.data[i].custom||{},s=o.valueAtIndexOrDefault,u=t.options.elements.arc;return{text:n,fillStyle:l.backgroundColor?l.backgroundColor:s(r.backgroundColor,i,u.backgroundColor),strokeStyle:l.borderColor?l.borderColor:s(r.borderColor,i,u.borderColor),lineWidth:l.borderWidth?l.borderWidth:s(r.borderWidth,i,u.borderWidth),hidden:isNaN(r.data[i])||a.data[i].hidden,index:i}}):[]}},onClick:function(t,e){var n,i,a,o=e.index,r=this.chart;for(n=0,i=(r.data.datasets||[]).length;n<i;++n)(a=r.getDatasetMeta(n)).data[o].hidden=!a.data[o].hidden;r.update()}},tooltips:{callbacks:{title:function(){return""},label:function(t,e){return e.labels[t.index]+": "+t.yLabel}}}}),e.exports=function(t){t.controllers.polarArea=t.DatasetController.extend({dataElementType:a.Arc,linkScales:o.noop,update:function(t){var e=this,n=e.chart,i=n.chartArea,a=e.getMeta(),r=n.options,l=r.elements.arc,s=Math.min(i.right-i.left,i.bottom-i.top);n.outerRadius=Math.max((s-l.borderWidth/2)/2,0),n.innerRadius=Math.max(r.cutoutPercentage?n.outerRadius/100*r.cutoutPercentage:1,0),n.radiusLength=(n.outerRadius-n.innerRadius)/n.getVisibleDatasetCount(),e.outerRadius=n.outerRadius-n.radiusLength*e.index,e.innerRadius=e.outerRadius-n.radiusLength,a.count=e.countVisibleElements(),o.each(a.data,function(n,i){e.updateElement(n,i,t)})},updateElement:function(t,e,n){for(var i=this,a=i.chart,r=i.getDataset(),l=a.options,s=l.animation,u=a.scale,d=a.data.labels,c=i.calculateCircumference(r.data[e]),h=u.xCenter,f=u.yCenter,g=0,p=i.getMeta(),v=0;v<e;++v)isNaN(r.data[v])||p.data[v].hidden||++g;var m=l.startAngle,b=t.hidden?0:u.getDistanceFromCenterForValue(r.data[e]),x=m+c*g,y=x+(t.hidden?0:c),k=s.animateScale?0:u.getDistanceFromCenterForValue(r.data[e]);o.extend(t,{_datasetIndex:i.index,_index:e,_scale:u,_model:{x:h,y:f,innerRadius:0,outerRadius:n?k:b,startAngle:n&&s.animateRotate?m:x,endAngle:n&&s.animateRotate?m:y,label:o.valueAtIndexOrDefault(d,e,d[e])}}),i.removeHoverStyle(t),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},countVisibleElements:function(){var t=this.getDataset(),e=this.getMeta(),n=0;return o.each(e.data,function(e,i){isNaN(t.data[i])||e.hidden||n++}),n},calculateCircumference:function(t){var e=this.getMeta().count;return e>0&&!isNaN(t)?2*Math.PI/e:0}})}},{25:25,40:40,45:45}],20:[function(t,e,n){"use strict";var i=t(25),a=t(40),o=t(45);i._set("radar",{scale:{type:"radialLinear"},elements:{line:{tension:0}}}),e.exports=function(t){t.controllers.radar=t.DatasetController.extend({datasetElementType:a.Line,dataElementType:a.Point,linkScales:o.noop,update:function(t){var e=this,n=e.getMeta(),i=n.dataset,a=n.data,r=i.custom||{},l=e.getDataset(),s=e.chart.options.elements.line,u=e.chart.scale;void 0!==l.tension&&void 0===l.lineTension&&(l.lineTension=l.tension),o.extend(n.dataset,{_datasetIndex:e.index,_scale:u,_children:a,_loop:!0,_model:{tension:r.tension?r.tension:o.valueOrDefault(l.lineTension,s.tension),backgroundColor:r.backgroundColor?r.backgroundColor:l.backgroundColor||s.backgroundColor,borderWidth:r.borderWidth?r.borderWidth:l.borderWidth||s.borderWidth,borderColor:r.borderColor?r.borderColor:l.borderColor||s.borderColor,fill:r.fill?r.fill:void 0!==l.fill?l.fill:s.fill,borderCapStyle:r.borderCapStyle?r.borderCapStyle:l.borderCapStyle||s.borderCapStyle,borderDash:r.borderDash?r.borderDash:l.borderDash||s.borderDash,borderDashOffset:r.borderDashOffset?r.borderDashOffset:l.borderDashOffset||s.borderDashOffset,borderJoinStyle:r.borderJoinStyle?r.borderJoinStyle:l.borderJoinStyle||s.borderJoinStyle}}),n.dataset.pivot(),o.each(a,function(n,i){e.updateElement(n,i,t)},e),e.updateBezierControlPoints()},updateElement:function(t,e,n){var i=this,a=t.custom||{},r=i.getDataset(),l=i.chart.scale,s=i.chart.options.elements.point,u=l.getPointPositionForValue(e,r.data[e]);void 0!==r.radius&&void 0===r.pointRadius&&(r.pointRadius=r.radius),void 0!==r.hitRadius&&void 0===r.pointHitRadius&&(r.pointHitRadius=r.hitRadius),o.extend(t,{_datasetIndex:i.index,_index:e,_scale:l,_model:{x:n?l.xCenter:u.x,y:n?l.yCenter:u.y,tension:a.tension?a.tension:o.valueOrDefault(r.lineTension,i.chart.options.elements.line.tension),radius:a.radius?a.radius:o.valueAtIndexOrDefault(r.pointRadius,e,s.radius),backgroundColor:a.backgroundColor?a.backgroundColor:o.valueAtIndexOrDefault(r.pointBackgroundColor,e,s.backgroundColor),borderColor:a.borderColor?a.borderColor:o.valueAtIndexOrDefault(r.pointBorderColor,e,s.borderColor),borderWidth:a.borderWidth?a.borderWidth:o.valueAtIndexOrDefault(r.pointBorderWidth,e,s.borderWidth),pointStyle:a.pointStyle?a.pointStyle:o.valueAtIndexOrDefault(r.pointStyle,e,s.pointStyle),hitRadius:a.hitRadius?a.hitRadius:o.valueAtIndexOrDefault(r.pointHitRadius,e,s.hitRadius)}}),t._model.skip=a.skip?a.skip:isNaN(t._model.x)||isNaN(t._model.y)},updateBezierControlPoints:function(){var t=this.chart.chartArea,e=this.getMeta();o.each(e.data,function(n,i){var a=n._model,r=o.splineCurve(o.previousItem(e.data,i,!0)._model,a,o.nextItem(e.data,i,!0)._model,a.tension);a.controlPointPreviousX=Math.max(Math.min(r.previous.x,t.right),t.left),a.controlPointPreviousY=Math.max(Math.min(r.previous.y,t.bottom),t.top),a.controlPointNextX=Math.max(Math.min(r.next.x,t.right),t.left),a.controlPointNextY=Math.max(Math.min(r.next.y,t.bottom),t.top),n.pivot()})},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t.custom||{},i=t._index,a=t._model;a.radius=n.hoverRadius?n.hoverRadius:o.valueAtIndexOrDefault(e.pointHoverRadius,i,this.chart.options.elements.point.hoverRadius),a.backgroundColor=n.hoverBackgroundColor?n.hoverBackgroundColor:o.valueAtIndexOrDefault(e.pointHoverBackgroundColor,i,o.getHoverColor(a.backgroundColor)),a.borderColor=n.hoverBorderColor?n.hoverBorderColor:o.valueAtIndexOrDefault(e.pointHoverBorderColor,i,o.getHoverColor(a.borderColor)),a.borderWidth=n.hoverBorderWidth?n.hoverBorderWidth:o.valueAtIndexOrDefault(e.pointHoverBorderWidth,i,a.borderWidth)},removeHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t.custom||{},i=t._index,a=t._model,r=this.chart.options.elements.point;a.radius=n.radius?n.radius:o.valueAtIndexOrDefault(e.pointRadius,i,r.radius),a.backgroundColor=n.backgroundColor?n.backgroundColor:o.valueAtIndexOrDefault(e.pointBackgroundColor,i,r.backgroundColor),a.borderColor=n.borderColor?n.borderColor:o.valueAtIndexOrDefault(e.pointBorderColor,i,r.borderColor),a.borderWidth=n.borderWidth?n.borderWidth:o.valueAtIndexOrDefault(e.pointBorderWidth,i,r.borderWidth)}})}},{25:25,40:40,45:45}],21:[function(t,e,n){"use strict";t(25)._set("scatter",{hover:{mode:"single"},scales:{xAxes:[{id:"x-axis-1",type:"linear",position:"bottom"}],yAxes:[{id:"y-axis-1",type:"linear",position:"left"}]},showLines:!1,tooltips:{callbacks:{title:function(){return""},label:function(t){return"("+t.xLabel+", "+t.yLabel+")"}}}}),e.exports=function(t){t.controllers.scatter=t.controllers.line}},{25:25}],22:[function(t,e,n){"use strict";var i=t(25),a=t(26),o=t(45);i._set("global",{animation:{duration:1e3,easing:"easeOutQuart",onProgress:o.noop,onComplete:o.noop}}),e.exports=function(t){t.Animation=a.extend({chart:null,currentStep:0,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),t.animationService={frameDuration:17,animations:[],dropFrames:0,request:null,addAnimation:function(t,e,n,i){var a,o,r=this.animations;for(e.chart=t,i||(t.animating=!0),a=0,o=r.length;a<o;++a)if(r[a].chart===t)return void(r[a]=e);r.push(e),1===r.length&&this.requestAnimationFrame()},cancelAnimation:function(t){var e=o.findIndex(this.animations,function(e){return e.chart===t});-1!==e&&(this.animations.splice(e,1),t.animating=!1)},requestAnimationFrame:function(){var t=this;null===t.request&&(t.request=o.requestAnimFrame.call(window,function(){t.request=null,t.startDigest()}))},startDigest:function(){var t=this,e=Date.now(),n=0;t.dropFrames>1&&(n=Math.floor(t.dropFrames),t.dropFrames=t.dropFrames%1),t.advance(1+n);var i=Date.now();t.dropFrames+=(i-e)/t.frameDuration,t.animations.length>0&&t.requestAnimationFrame()},advance:function(t){for(var e,n,i=this.animations,a=0;a<i.length;)n=(e=i[a]).chart,e.currentStep=(e.currentStep||0)+t,e.currentStep=Math.min(e.currentStep,e.numSteps),o.callback(e.render,[n,e],n),o.callback(e.onAnimationProgress,[e],n),e.currentStep>=e.numSteps?(o.callback(e.onAnimationComplete,[e],n),n.animating=!1,i.splice(a,1)):++a}},Object.defineProperty(t.Animation.prototype,"animationObject",{get:function(){return this}}),Object.defineProperty(t.Animation.prototype,"chartInstance",{get:function(){return this.chart},set:function(t){this.chart=t}})}},{25:25,26:26,45:45}],23:[function(t,e,n){"use strict";var i=t(25),a=t(45),o=t(28),r=t(48);e.exports=function(t){function e(t){var e=(t=t||{}).data=t.data||{};return e.datasets=e.datasets||[],e.labels=e.labels||[],t.options=a.configMerge(i.global,i[t.type],t.options||{}),t}function n(t){var e=t.options;e.scale?t.scale.options=e.scale:e.scales&&e.scales.xAxes.concat(e.scales.yAxes).forEach(function(e){t.scales[e.id].options=e}),t.tooltip._options=e.tooltips}function l(t){return"top"===t||"bottom"===t}var s=t.plugins;t.types={},t.instances={},t.controllers={},a.extend(t.prototype,{construct:function(n,i){var o=this;i=e(i);var l=r.acquireContext(n,i),s=l&&l.canvas,u=s&&s.height,d=s&&s.width;o.id=a.uid(),o.ctx=l,o.canvas=s,o.config=i,o.width=d,o.height=u,o.aspectRatio=u?d/u:null,o.options=i.options,o._bufferedRender=!1,o.chart=o,o.controller=o,t.instances[o.id]=o,Object.defineProperty(o,"data",{get:function(){return o.config.data},set:function(t){o.config.data=t}}),l&&s?(o.initialize(),o.update()):console.error("Failed to create chart: can't acquire context from the given item")},initialize:function(){var t=this;return s.notify(t,"beforeInit"),a.retinaScale(t,t.options.devicePixelRatio),t.bindEvents(),t.options.responsive&&t.resize(!0),t.ensureScalesHaveIDs(),t.buildScales(),t.initToolTip(),s.notify(t,"afterInit"),t},clear:function(){return a.canvas.clear(this),this},stop:function(){return t.animationService.cancelAnimation(this),this},resize:function(t){var e=this,n=e.options,i=e.canvas,o=n.maintainAspectRatio&&e.aspectRatio||null,r=Math.max(0,Math.floor(a.getMaximumWidth(i))),l=Math.max(0,Math.floor(o?r/o:a.getMaximumHeight(i)));if((e.width!==r||e.height!==l)&&(i.width=e.width=r,i.height=e.height=l,i.style.width=r+"px",i.style.height=l+"px",a.retinaScale(e,n.devicePixelRatio),!t)){var u={width:r,height:l};s.notify(e,"resize",[u]),e.options.onResize&&e.options.onResize(e,u),e.stop(),e.update(e.options.responsiveAnimationDuration)}},ensureScalesHaveIDs:function(){var t=this.options,e=t.scales||{},n=t.scale;a.each(e.xAxes,function(t,e){t.id=t.id||"x-axis-"+e}),a.each(e.yAxes,function(t,e){t.id=t.id||"y-axis-"+e}),n&&(n.id=n.id||"scale")},buildScales:function(){var e=this,n=e.options,i=e.scales={},o=[];n.scales&&(o=o.concat((n.scales.xAxes||[]).map(function(t){return{options:t,dtype:"category",dposition:"bottom"}}),(n.scales.yAxes||[]).map(function(t){return{options:t,dtype:"linear",dposition:"left"}}))),n.scale&&o.push({options:n.scale,dtype:"radialLinear",isDefault:!0,dposition:"chartArea"}),a.each(o,function(n){var o=n.options,r=a.valueOrDefault(o.type,n.dtype),s=t.scaleService.getScaleConstructor(r);if(s){l(o.position)!==l(n.dposition)&&(o.position=n.dposition);var u=new s({id:o.id,options:o,ctx:e.ctx,chart:e});i[u.id]=u,u.mergeTicksOptions(),n.isDefault&&(e.scale=u)}}),t.scaleService.addScalesToLayout(this)},buildOrUpdateControllers:function(){var e=this,n=[],i=[];return a.each(e.data.datasets,function(a,o){var r=e.getDatasetMeta(o),l=a.type||e.config.type;if(r.type&&r.type!==l&&(e.destroyDatasetMeta(o),r=e.getDatasetMeta(o)),r.type=l,n.push(r.type),r.controller)r.controller.updateIndex(o);else{var s=t.controllers[r.type];if(void 0===s)throw new Error('"'+r.type+'" is not a chart type.');r.controller=new s(e,o),i.push(r.controller)}},e),i},resetElements:function(){var t=this;a.each(t.data.datasets,function(e,n){t.getDatasetMeta(n).controller.reset()},t)},reset:function(){this.resetElements(),this.tooltip.initialize()},update:function(t){var e=this;if(t&&"object"==typeof t||(t={duration:t,lazy:arguments[1]}),n(e),!1!==s.notify(e,"beforeUpdate")){e.tooltip._data=e.data;var i=e.buildOrUpdateControllers();a.each(e.data.datasets,function(t,n){e.getDatasetMeta(n).controller.buildOrUpdateElements()},e),e.updateLayout(),a.each(i,function(t){t.reset()}),e.updateDatasets(),e.tooltip.initialize(),e.lastActive=[],s.notify(e,"afterUpdate"),e._bufferedRender?e._bufferedRequest={duration:t.duration,easing:t.easing,lazy:t.lazy}:e.render(t)}},updateLayout:function(){var e=this;!1!==s.notify(e,"beforeLayout")&&(t.layoutService.update(this,this.width,this.height),s.notify(e,"afterScaleUpdate"),s.notify(e,"afterLayout"))},updateDatasets:function(){var t=this;if(!1!==s.notify(t,"beforeDatasetsUpdate")){for(var e=0,n=t.data.datasets.length;e<n;++e)t.updateDataset(e);s.notify(t,"afterDatasetsUpdate")}},updateDataset:function(t){var e=this,n=e.getDatasetMeta(t),i={meta:n,index:t};!1!==s.notify(e,"beforeDatasetUpdate",[i])&&(n.controller.update(),s.notify(e,"afterDatasetUpdate",[i]))},render:function(e){var n=this;e&&"object"==typeof e||(e={duration:e,lazy:arguments[1]});var i=e.duration,o=e.lazy;if(!1!==s.notify(n,"beforeRender")){var r=n.options.animation,l=function(t){s.notify(n,"afterRender"),a.callback(r&&r.onComplete,[t],n)};if(r&&(void 0!==i&&0!==i||void 0===i&&0!==r.duration)){var u=new t.Animation({numSteps:(i||r.duration)/16.66,easing:e.easing||r.easing,render:function(t,e){var n=a.easing.effects[e.easing],i=e.currentStep,o=i/e.numSteps;t.draw(n(o),o,i)},onAnimationProgress:r.onProgress,onAnimationComplete:l});t.animationService.addAnimation(n,u,i,o)}else n.draw(),l(new t.Animation({numSteps:0,chart:n}));return n}},draw:function(t){var e=this;e.clear(),a.isNullOrUndef(t)&&(t=1),e.transition(t),!1!==s.notify(e,"beforeDraw",[t])&&(a.each(e.boxes,function(t){t.draw(e.chartArea)},e),e.scale&&e.scale.draw(),e.drawDatasets(t),e._drawTooltip(t),s.notify(e,"afterDraw",[t]))},transition:function(t){for(var e=this,n=0,i=(e.data.datasets||[]).length;n<i;++n)e.isDatasetVisible(n)&&e.getDatasetMeta(n).controller.transition(t);e.tooltip.transition(t)},drawDatasets:function(t){var e=this;if(!1!==s.notify(e,"beforeDatasetsDraw",[t])){for(var n=(e.data.datasets||[]).length-1;n>=0;--n)e.isDatasetVisible(n)&&e.drawDataset(n,t);s.notify(e,"afterDatasetsDraw",[t])}},drawDataset:function(t,e){var n=this,i=n.getDatasetMeta(t),a={meta:i,index:t,easingValue:e};!1!==s.notify(n,"beforeDatasetDraw",[a])&&(i.controller.draw(e),s.notify(n,"afterDatasetDraw",[a]))},_drawTooltip:function(t){var e=this,n=e.tooltip,i={tooltip:n,easingValue:t};!1!==s.notify(e,"beforeTooltipDraw",[i])&&(n.draw(),s.notify(e,"afterTooltipDraw",[i]))},getElementAtEvent:function(t){return o.modes.single(this,t)},getElementsAtEvent:function(t){return o.modes.label(this,t,{intersect:!0})},getElementsAtXAxis:function(t){return o.modes["x-axis"](this,t,{intersect:!0})},getElementsAtEventForMode:function(t,e,n){var i=o.modes[e];return"function"==typeof i?i(this,t,n):[]},getDatasetAtEvent:function(t){return o.modes.dataset(this,t,{intersect:!0})},getDatasetMeta:function(t){var e=this,n=e.data.datasets[t];n._meta||(n._meta={});var i=n._meta[e.id];return i||(i=n._meta[e.id]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null}),i},getVisibleDatasetCount:function(){for(var t=0,e=0,n=this.data.datasets.length;e<n;++e)this.isDatasetVisible(e)&&t++;return t},isDatasetVisible:function(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden},generateLegend:function(){return this.options.legendCallback(this)},destroyDatasetMeta:function(t){var e=this.id,n=this.data.datasets[t],i=n._meta&&n._meta[e];i&&(i.controller.destroy(),delete n._meta[e])},destroy:function(){var e,n,i=this,o=i.canvas;for(i.stop(),e=0,n=i.data.datasets.length;e<n;++e)i.destroyDatasetMeta(e);o&&(i.unbindEvents(),a.canvas.clear(i),r.releaseContext(i.ctx),i.canvas=null,i.ctx=null),s.notify(i,"destroy"),delete t.instances[i.id]},toBase64Image:function(){return this.canvas.toDataURL.apply(this.canvas,arguments)},initToolTip:function(){var e=this;e.tooltip=new t.Tooltip({_chart:e,_chartInstance:e,_data:e.data,_options:e.options.tooltips},e)},bindEvents:function(){var t=this,e=t._listeners={},n=function(){t.eventHandler.apply(t,arguments)};a.each(t.options.events,function(i){r.addEventListener(t,i,n),e[i]=n}),t.options.responsive&&(n=function(){t.resize()},r.addEventListener(t,"resize",n),e.resize=n)},unbindEvents:function(){var t=this,e=t._listeners;e&&(delete t._listeners,a.each(e,function(e,n){r.removeEventListener(t,n,e)}))},updateHoverStyle:function(t,e,n){var i,a,o,r=n?"setHoverStyle":"removeHoverStyle";for(a=0,o=t.length;a<o;++a)(i=t[a])&&this.getDatasetMeta(i._datasetIndex).controller[r](i)},eventHandler:function(t){var e=this,n=e.tooltip;if(!1!==s.notify(e,"beforeEvent",[t])){e._bufferedRender=!0,e._bufferedRequest=null;var i=e.handleEvent(t);i|=n&&n.handleEvent(t),s.notify(e,"afterEvent",[t]);var a=e._bufferedRequest;return a?e.render(a):i&&!e.animating&&(e.stop(),e.render(e.options.hover.animationDuration,!0)),e._bufferedRender=!1,e._bufferedRequest=null,e}},handleEvent:function(t){var e=this,n=e.options||{},i=n.hover,o=!1;return e.lastActive=e.lastActive||[],"mouseout"===t.type?e.active=[]:e.active=e.getElementsAtEventForMode(t,i.mode,i),a.callback(n.onHover||n.hover.onHover,[t.native,e.active],e),"mouseup"!==t.type&&"click"!==t.type||n.onClick&&n.onClick.call(e,t.native,e.active),e.lastActive.length&&e.updateHoverStyle(e.lastActive,i.mode,!1),e.active.length&&i.mode&&e.updateHoverStyle(e.active,i.mode,!0),o=!a.arrayEquals(e.active,e.lastActive),e.lastActive=e.active,o}}),t.Controller=t}},{25:25,28:28,45:45,48:48}],24:[function(t,e,n){"use strict";var i=t(45);e.exports=function(t){function e(t,e){t._chartjs?t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),a.forEach(function(e){var n="onData"+e.charAt(0).toUpperCase()+e.slice(1),a=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:function(){var e=Array.prototype.slice.call(arguments),o=a.apply(this,e);return i.each(t._chartjs.listeners,function(t){"function"==typeof t[n]&&t[n].apply(t,e)}),o}})}))}function n(t,e){var n=t._chartjs;if(n){var i=n.listeners,o=i.indexOf(e);-1!==o&&i.splice(o,1),i.length>0||(a.forEach(function(e){delete t[e]}),delete t._chartjs)}}var a=["push","pop","shift","splice","unshift"];t.DatasetController=function(t,e){this.initialize(t,e)},i.extend(t.DatasetController.prototype,{datasetElementType:null,dataElementType:null,initialize:function(t,e){var n=this;n.chart=t,n.index=e,n.linkScales(),n.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){var t=this,e=t.getMeta(),n=t.getDataset();null===e.xAxisID&&(e.xAxisID=n.xAxisID||t.chart.options.scales.xAxes[0].id),null===e.yAxisID&&(e.yAxisID=n.yAxisID||t.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getMeta:function(){return this.chart.getDatasetMeta(this.index)},getScaleForId:function(t){return this.chart.scales[t]},reset:function(){this.update(!0)},destroy:function(){this._data&&n(this._data,this)},createMetaDataset:function(){var t=this,e=t.datasetElementType;return e&&new e({_chart:t.chart,_datasetIndex:t.index})},createMetaData:function(t){var e=this,n=e.dataElementType;return n&&new n({_chart:e.chart,_datasetIndex:e.index,_index:t})},addElements:function(){var t,e,n=this,i=n.getMeta(),a=n.getDataset().data||[],o=i.data;for(t=0,e=a.length;t<e;++t)o[t]=o[t]||n.createMetaData(t);i.dataset=i.dataset||n.createMetaDataset()},addElementAndReset:function(t){var e=this.createMetaData(t);this.getMeta().data.splice(t,0,e),this.updateElement(e,t,!0)},buildOrUpdateElements:function(){var t=this,i=t.getDataset(),a=i.data||(i.data=[]);t._data!==a&&(t._data&&n(t._data,t),e(a,t),t._data=a),t.resyncElements()},update:i.noop,transition:function(t){for(var e=this.getMeta(),n=e.data||[],i=n.length,a=0;a<i;++a)n[a].transition(t);e.dataset&&e.dataset.transition(t)},draw:function(){var t=this.getMeta(),e=t.data||[],n=e.length,i=0;for(t.dataset&&t.dataset.draw();i<n;++i)e[i].draw()},removeHoverStyle:function(t,e){var n=this.chart.data.datasets[t._datasetIndex],a=t._index,o=t.custom||{},r=i.valueAtIndexOrDefault,l=t._model;l.backgroundColor=o.backgroundColor?o.backgroundColor:r(n.backgroundColor,a,e.backgroundColor),l.borderColor=o.borderColor?o.borderColor:r(n.borderColor,a,e.borderColor),l.borderWidth=o.borderWidth?o.borderWidth:r(n.borderWidth,a,e.borderWidth)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],n=t._index,a=t.custom||{},o=i.valueAtIndexOrDefault,r=i.getHoverColor,l=t._model;l.backgroundColor=a.hoverBackgroundColor?a.hoverBackgroundColor:o(e.hoverBackgroundColor,n,r(l.backgroundColor)),l.borderColor=a.hoverBorderColor?a.hoverBorderColor:o(e.hoverBorderColor,n,r(l.borderColor)),l.borderWidth=a.hoverBorderWidth?a.hoverBorderWidth:o(e.hoverBorderWidth,n,l.borderWidth)},resyncElements:function(){var t=this,e=t.getMeta(),n=t.getDataset().data,i=e.data.length,a=n.length;a<i?e.data.splice(a,i-a):a>i&&t.insertElements(i,a-i)},insertElements:function(t,e){for(var n=0;n<e;++n)this.addElementAndReset(t+n)},onDataPush:function(){this.insertElements(this.getDataset().data.length-1,arguments.length)},onDataPop:function(){this.getMeta().data.pop()},onDataShift:function(){this.getMeta().data.shift()},onDataSplice:function(t,e){this.getMeta().data.splice(t,e),this.insertElements(t,arguments.length-2)},onDataUnshift:function(){this.insertElements(0,arguments.length)}}),t.DatasetController.extend=i.inherits}},{45:45}],25:[function(t,e,n){"use strict";var i=t(45);e.exports={_set:function(t,e){return i.merge(this[t]||(this[t]={}),e)}}},{45:45}],26:[function(t,e,n){"use strict";function i(t,e,n,i){var o,r,l,s,u,d,c,h,f,g=Object.keys(n);for(o=0,r=g.length;o<r;++o)if(l=g[o],d=n[l],e.hasOwnProperty(l)||(e[l]=d),(s=e[l])!==d&&"_"!==l[0]){if(t.hasOwnProperty(l)||(t[l]=s),u=t[l],(c=typeof d)===typeof u)if("string"===c){if((h=a(u)).valid&&(f=a(d)).valid){e[l]=f.mix(h,i).rgbString();continue}}else if("number"===c&&isFinite(u)&&isFinite(d)){e[l]=u+(d-u)*i;continue}e[l]=d}}var a=t(3),o=t(45),r=function(t){o.extend(this,t),this.initialize.apply(this,arguments)};o.extend(r.prototype,{initialize:function(){this.hidden=!1},pivot:function(){var t=this;return t._view||(t._view=o.clone(t._model)),t._start={},t},transition:function(t){var e=this,n=e._model,a=e._start,o=e._view;return n&&1!==t?(o||(o=e._view={}),a||(a=e._start={}),i(a,o,n,t),e):(e._view=n,e._start=null,e)},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return o.isNumber(this._model.x)&&o.isNumber(this._model.y)}}),r.extend=o.inherits,e.exports=r},{3:3,45:45}],27:[function(t,e,n){"use strict";var i=t(3),a=t(25),o=t(45);e.exports=function(t){function e(t,e,n){var i;return"string"==typeof t?(i=parseInt(t,10),-1!==t.indexOf("%")&&(i=i/100*e.parentNode[n])):i=t,i}function n(t){return void 0!==t&&null!==t&&"none"!==t}function r(t,i,a){var o=document.defaultView,r=t.parentNode,l=o.getComputedStyle(t)[i],s=o.getComputedStyle(r)[i],u=n(l),d=n(s),c=Number.POSITIVE_INFINITY;return u||d?Math.min(u?e(l,t,a):c,d?e(s,r,a):c):"none"}o.configMerge=function(){return o.merge(o.clone(arguments[0]),[].slice.call(arguments,1),{merger:function(e,n,i,a){var r=n[e]||{},l=i[e];"scales"===e?n[e]=o.scaleMerge(r,l):"scale"===e?n[e]=o.merge(r,[t.scaleService.getScaleDefaults(l.type),l]):o._merger(e,n,i,a)}})},o.scaleMerge=function(){return o.merge(o.clone(arguments[0]),[].slice.call(arguments,1),{merger:function(e,n,i,a){if("xAxes"===e||"yAxes"===e){var r,l,s,u=i[e].length;for(n[e]||(n[e]=[]),r=0;r<u;++r)s=i[e][r],l=o.valueOrDefault(s.type,"xAxes"===e?"category":"linear"),r>=n[e].length&&n[e].push({}),!n[e][r].type||s.type&&s.type!==n[e][r].type?o.merge(n[e][r],[t.scaleService.getScaleDefaults(l),s]):o.merge(n[e][r],s)}else o._merger(e,n,i,a)}})},o.where=function(t,e){if(o.isArray(t)&&Array.prototype.filter)return t.filter(e);var n=[];return o.each(t,function(t){e(t)&&n.push(t)}),n},o.findIndex=Array.prototype.findIndex?function(t,e,n){return t.findIndex(e,n)}:function(t,e,n){n=void 0===n?t:n;for(var i=0,a=t.length;i<a;++i)if(e.call(n,t[i],i,t))return i;return-1},o.findNextWhere=function(t,e,n){o.isNullOrUndef(n)&&(n=-1);for(var i=n+1;i<t.length;i++){var a=t[i];if(e(a))return a}},o.findPreviousWhere=function(t,e,n){o.isNullOrUndef(n)&&(n=t.length);for(var i=n-1;i>=0;i--){var a=t[i];if(e(a))return a}},o.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},o.almostEquals=function(t,e,n){return Math.abs(t-e)<n},o.almostWhole=function(t,e){var n=Math.round(t);return n-e<t&&n+e>t},o.max=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.max(t,e)},Number.NEGATIVE_INFINITY)},o.min=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.min(t,e)},Number.POSITIVE_INFINITY)},o.sign=Math.sign?function(t){return Math.sign(t)}:function(t){return 0==(t=+t)||isNaN(t)?t:t>0?1:-1},o.log10=Math.log10?function(t){return Math.log10(t)}:function(t){return Math.log(t)/Math.LN10},o.toRadians=function(t){return t*(Math.PI/180)},o.toDegrees=function(t){return t*(180/Math.PI)},o.getAngleFromPoint=function(t,e){var n=e.x-t.x,i=e.y-t.y,a=Math.sqrt(n*n+i*i),o=Math.atan2(i,n);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:a}},o.distanceBetweenPoints=function(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},o.aliasPixel=function(t){return t%2==0?0:.5},o.splineCurve=function(t,e,n,i){var a=t.skip?e:t,o=e,r=n.skip?e:n,l=Math.sqrt(Math.pow(o.x-a.x,2)+Math.pow(o.y-a.y,2)),s=Math.sqrt(Math.pow(r.x-o.x,2)+Math.pow(r.y-o.y,2)),u=l/(l+s),d=s/(l+s),c=i*(u=isNaN(u)?0:u),h=i*(d=isNaN(d)?0:d);return{previous:{x:o.x-c*(r.x-a.x),y:o.y-c*(r.y-a.y)},next:{x:o.x+h*(r.x-a.x),y:o.y+h*(r.y-a.y)}}},o.EPSILON=Number.EPSILON||1e-14,o.splineCurveMonotone=function(t){var e,n,i,a,r=(t||[]).map(function(t){return{model:t._model,deltaK:0,mK:0}}),l=r.length;for(e=0;e<l;++e)if(!(i=r[e]).model.skip){if(n=e>0?r[e-1]:null,(a=e<l-1?r[e+1]:null)&&!a.model.skip){var s=a.model.x-i.model.x;i.deltaK=0!==s?(a.model.y-i.model.y)/s:0}!n||n.model.skip?i.mK=i.deltaK:!a||a.model.skip?i.mK=n.deltaK:this.sign(n.deltaK)!==this.sign(i.deltaK)?i.mK=0:i.mK=(n.deltaK+i.deltaK)/2}var u,d,c,h;for(e=0;e<l-1;++e)i=r[e],a=r[e+1],i.model.skip||a.model.skip||(o.almostEquals(i.deltaK,0,this.EPSILON)?i.mK=a.mK=0:(u=i.mK/i.deltaK,d=a.mK/i.deltaK,(h=Math.pow(u,2)+Math.pow(d,2))<=9||(c=3/Math.sqrt(h),i.mK=u*c*i.deltaK,a.mK=d*c*i.deltaK)));var f;for(e=0;e<l;++e)(i=r[e]).model.skip||(n=e>0?r[e-1]:null,a=e<l-1?r[e+1]:null,n&&!n.model.skip&&(f=(i.model.x-n.model.x)/3,i.model.controlPointPreviousX=i.model.x-f,i.model.controlPointPreviousY=i.model.y-f*i.mK),a&&!a.model.skip&&(f=(a.model.x-i.model.x)/3,i.model.controlPointNextX=i.model.x+f,i.model.controlPointNextY=i.model.y+f*i.mK))},o.nextItem=function(t,e,n){return n?e>=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},o.previousItem=function(t,e,n){return n?e<=0?t[t.length-1]:t[e-1]:e<=0?t[0]:t[e-1]},o.niceNum=function(t,e){var n=Math.floor(o.log10(t)),i=t/Math.pow(10,n);return(e?i<1.5?1:i<3?2:i<7?5:10:i<=1?1:i<=2?2:i<=5?5:10)*Math.pow(10,n)},o.requestAnimFrame="undefined"==typeof window?function(t){t()}:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)},o.getRelativePosition=function(t,e){var n,i,a=t.originalEvent||t,r=t.currentTarget||t.srcElement,l=r.getBoundingClientRect(),s=a.touches;s&&s.length>0?(n=s[0].clientX,i=s[0].clientY):(n=a.clientX,i=a.clientY);var u=parseFloat(o.getStyle(r,"padding-left")),d=parseFloat(o.getStyle(r,"padding-top")),c=parseFloat(o.getStyle(r,"padding-right")),h=parseFloat(o.getStyle(r,"padding-bottom")),f=l.right-l.left-u-c,g=l.bottom-l.top-d-h;return n=Math.round((n-l.left-u)/f*r.width/e.currentDevicePixelRatio),i=Math.round((i-l.top-d)/g*r.height/e.currentDevicePixelRatio),{x:n,y:i}},o.getConstraintWidth=function(t){return r(t,"max-width","clientWidth")},o.getConstraintHeight=function(t){return r(t,"max-height","clientHeight")},o.getMaximumWidth=function(t){var e=t.parentNode;if(!e)return t.clientWidth;var n=parseInt(o.getStyle(e,"padding-left"),10),i=parseInt(o.getStyle(e,"padding-right"),10),a=e.clientWidth-n-i,r=o.getConstraintWidth(t);return isNaN(r)?a:Math.min(a,r)},o.getMaximumHeight=function(t){var e=t.parentNode;if(!e)return t.clientHeight;var n=parseInt(o.getStyle(e,"padding-top"),10),i=parseInt(o.getStyle(e,"padding-bottom"),10),a=e.clientHeight-n-i,r=o.getConstraintHeight(t);return isNaN(r)?a:Math.min(a,r)},o.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},o.retinaScale=function(t,e){var n=t.currentDevicePixelRatio=e||window.devicePixelRatio||1;if(1!==n){var i=t.canvas,a=t.height,o=t.width;i.height=a*n,i.width=o*n,t.ctx.scale(n,n),i.style.height=a+"px",i.style.width=o+"px"}},o.fontString=function(t,e,n){return e+" "+t+"px "+n},o.longestText=function(t,e,n,i){var a=(i=i||{}).data=i.data||{},r=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(a=i.data={},r=i.garbageCollect=[],i.font=e),t.font=e;var l=0;o.each(n,function(e){void 0!==e&&null!==e&&!0!==o.isArray(e)?l=o.measureText(t,a,r,l,e):o.isArray(e)&&o.each(e,function(e){void 0===e||null===e||o.isArray(e)||(l=o.measureText(t,a,r,l,e))})});var s=r.length/2;if(s>n.length){for(var u=0;u<s;u++)delete a[r[u]];r.splice(0,s)}return l},o.measureText=function(t,e,n,i,a){var o=e[a];return o||(o=e[a]=t.measureText(a).width,n.push(a)),o>i&&(i=o),i},o.numberOfLabelLines=function(t){var e=1;return o.each(t,function(t){o.isArray(t)&&t.length>e&&(e=t.length)}),e},o.color=i?function(t){return t instanceof CanvasGradient&&(t=a.global.defaultColor),i(t)}:function(t){return console.error("Color.js not found!"),t},o.getHoverColor=function(t){return t instanceof CanvasPattern?t:o.color(t).saturate(.5).darken(.1).rgbString()}}},{25:25,3:3,45:45}],28:[function(t,e,n){"use strict";function i(t,e){return t.native?{x:t.x,y:t.y}:u.getRelativePosition(t,e)}function a(t,e){var n,i,a,o,r;for(i=0,o=t.data.datasets.length;i<o;++i)if(t.isDatasetVisible(i))for(a=0,r=(n=t.getDatasetMeta(i)).data.length;a<r;++a){var l=n.data[a];l._view.skip||e(l)}}function o(t,e){var n=[];return a(t,function(t){t.inRange(e.x,e.y)&&n.push(t)}),n}function r(t,e,n,i){var o=Number.POSITIVE_INFINITY,r=[];return a(t,function(t){if(!n||t.inRange(e.x,e.y)){var a=t.getCenterPoint(),l=i(e,a);l<o?(r=[t],o=l):l===o&&r.push(t)}}),r}function l(t){var e=-1!==t.indexOf("x"),n=-1!==t.indexOf("y");return function(t,i){var a=e?Math.abs(t.x-i.x):0,o=n?Math.abs(t.y-i.y):0;return Math.sqrt(Math.pow(a,2)+Math.pow(o,2))}}function s(t,e,n){var a=i(e,t);n.axis=n.axis||"x";var s=l(n.axis),u=n.intersect?o(t,a):r(t,a,!1,s),d=[];return u.length?(t.data.datasets.forEach(function(e,n){if(t.isDatasetVisible(n)){var i=t.getDatasetMeta(n).data[u[0]._index];i&&!i._view.skip&&d.push(i)}}),d):[]}var u=t(45);e.exports={modes:{single:function(t,e){var n=i(e,t),o=[];return a(t,function(t){if(t.inRange(n.x,n.y))return o.push(t),o}),o.slice(0,1)},label:s,index:s,dataset:function(t,e,n){var a=i(e,t);n.axis=n.axis||"xy";var s=l(n.axis),u=n.intersect?o(t,a):r(t,a,!1,s);return u.length>0&&(u=t.getDatasetMeta(u[0]._datasetIndex).data),u},"x-axis":function(t,e){return s(t,e,{intersect:!1})},point:function(t,e){return o(t,i(e,t))},nearest:function(t,e,n){var a=i(e,t);n.axis=n.axis||"xy";var o=l(n.axis),s=r(t,a,n.intersect,o);return s.length>1&&s.sort(function(t,e){var n=t.getArea()-e.getArea();return 0===n&&(n=t._datasetIndex-e._datasetIndex),n}),s.slice(0,1)},x:function(t,e,n){var o=i(e,t),r=[],l=!1;return a(t,function(t){t.inXRange(o.x)&&r.push(t),t.inRange(o.x,o.y)&&(l=!0)}),n.intersect&&!l&&(r=[]),r},y:function(t,e,n){var o=i(e,t),r=[],l=!1;return a(t,function(t){t.inYRange(o.y)&&r.push(t),t.inRange(o.x,o.y)&&(l=!0)}),n.intersect&&!l&&(r=[]),r}}}},{45:45}],29:[function(t,e,n){"use strict";t(25)._set("global",{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:null,mode:"nearest",intersect:!0,animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",defaultFontColor:"#666",defaultFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",defaultFontSize:12,defaultFontStyle:"normal",showLines:!0,elements:{},layout:{padding:{top:0,right:0,bottom:0,left:0}}}),e.exports=function(){var t=function(t,e){return this.construct(t,e),this};return t.Chart=t,t}},{25:25}],30:[function(t,e,n){"use strict";var i=t(45);e.exports=function(t){function e(t,e){return i.where(t,function(t){return t.position===e})}function n(t,e){t.forEach(function(t,e){return t._tmpIndex_=e,t}),t.sort(function(t,n){var i=e?n:t,a=e?t:n;return i.weight===a.weight?i._tmpIndex_-a._tmpIndex_:i.weight-a.weight}),t.forEach(function(t){delete t._tmpIndex_})}t.layoutService={defaults:{},addBox:function(t,e){t.boxes||(t.boxes=[]),e.fullWidth=e.fullWidth||!1,e.position=e.position||"top",e.weight=e.weight||0,t.boxes.push(e)},removeBox:function(t,e){var n=t.boxes?t.boxes.indexOf(e):-1;-1!==n&&t.boxes.splice(n,1)},configure:function(t,e,n){for(var i,a=["fullWidth","position","weight"],o=a.length,r=0;r<o;++r)i=a[r],n.hasOwnProperty(i)&&(e[i]=n[i])},update:function(t,a,o){function r(t){var e=i.findNextWhere(_,function(e){return e.box===t});if(e)if(t.isHorizontal()){var n={left:Math.max(T,D),right:Math.max(F,I),top:0,bottom:0};t.update(t.fullWidth?x:S,y/2,n)}else t.update(e.minSize.width,C)}function l(t){t.isHorizontal()?(t.left=t.fullWidth?d:T,t.right=t.fullWidth?a-c:T+S,t.top=V,t.bottom=V+t.height,V=t.bottom):(t.left=N,t.right=N+t.width,t.top=O,t.bottom=O+C,N=t.right)}if(t){var s=t.options.layout||{},u=i.options.toPadding(s.padding),d=u.left,c=u.right,h=u.top,f=u.bottom,g=e(t.boxes,"left"),p=e(t.boxes,"right"),v=e(t.boxes,"top"),m=e(t.boxes,"bottom"),b=e(t.boxes,"chartArea");n(g,!0),n(p,!1),n(v,!0),n(m,!1);var x=a-d-c,y=o-h-f,k=y/2,w=(a-x/2)/(g.length+p.length),M=(o-k)/(v.length+m.length),S=x,C=y,_=[];i.each(g.concat(p,v,m),function(t){var e,n=t.isHorizontal();n?(e=t.update(t.fullWidth?x:S,M),C-=e.height):(e=t.update(w,k),S-=e.width),_.push({horizontal:n,minSize:e,box:t})});var D=0,I=0,P=0,A=0;i.each(v.concat(m),function(t){if(t.getPadding){var e=t.getPadding();D=Math.max(D,e.left),I=Math.max(I,e.right)}}),i.each(g.concat(p),function(t){if(t.getPadding){var e=t.getPadding();P=Math.max(P,e.top),A=Math.max(A,e.bottom)}});var T=d,F=c,O=h,R=f;i.each(g.concat(p),r),i.each(g,function(t){T+=t.width}),i.each(p,function(t){F+=t.width}),i.each(v.concat(m),r),i.each(v,function(t){O+=t.height}),i.each(m,function(t){R+=t.height}),i.each(g.concat(p),function(t){var e=i.findNextWhere(_,function(e){return e.box===t}),n={left:0,right:0,top:O,bottom:R};e&&t.update(e.minSize.width,C,n)}),T=d,F=c,O=h,R=f,i.each(g,function(t){T+=t.width}),i.each(p,function(t){F+=t.width}),i.each(v,function(t){O+=t.height}),i.each(m,function(t){R+=t.height});var L=Math.max(D-T,0);T+=L,F+=Math.max(I-F,0);var z=Math.max(P-O,0);O+=z,R+=Math.max(A-R,0);var B=o-O-R,W=a-T-F;W===S&&B===C||(i.each(g,function(t){t.height=B}),i.each(p,function(t){t.height=B}),i.each(v,function(t){t.fullWidth||(t.width=W)}),i.each(m,function(t){t.fullWidth||(t.width=W)}),C=B,S=W);var N=d+L,V=h+z;i.each(g.concat(v),l),N+=S,V+=C,i.each(p,l),i.each(m,l),t.chartArea={left:T,top:O,right:T+S,bottom:O+C},i.each(b,function(e){e.left=t.chartArea.left,e.top=t.chartArea.top,e.right=t.chartArea.right,e.bottom=t.chartArea.bottom,e.update(S,C)})}}}}},{45:45}],31:[function(t,e,n){"use strict";var i=t(25),a=t(26),o=t(45);i._set("global",{plugins:{}}),e.exports=function(t){t.plugins={_plugins:[],_cacheId:0,register:function(t){var e=this._plugins;[].concat(t).forEach(function(t){-1===e.indexOf(t)&&e.push(t)}),this._cacheId++},unregister:function(t){var e=this._plugins;[].concat(t).forEach(function(t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}),this._cacheId++},clear:function(){this._plugins=[],this._cacheId++},count:function(){return this._plugins.length},getAll:function(){return this._plugins},notify:function(t,e,n){var i,a,o,r,l,s=this.descriptors(t),u=s.length;for(i=0;i<u;++i)if(a=s[i],o=a.plugin,"function"==typeof(l=o[e])&&((r=[t].concat(n||[])).push(a.options),!1===l.apply(o,r)))return!1;return!0},descriptors:function(t){var e=t._plugins||(t._plugins={});if(e.id===this._cacheId)return e.descriptors;var n=[],a=[],r=t&&t.config||{},l=r.options&&r.options.plugins||{};return this._plugins.concat(r.plugins||[]).forEach(function(t){if(-1===n.indexOf(t)){var e=t.id,r=l[e];!1!==r&&(!0===r&&(r=o.clone(i.global.plugins[e])),n.push(t),a.push({plugin:t,options:r||{}}))}}),e.descriptors=a,e.id=this._cacheId,a}},t.pluginService=t.plugins,t.PluginBase=a.extend({})}},{25:25,26:26,45:45}],32:[function(t,e,n){"use strict";function i(t){var e,n,i=[];for(e=0,n=t.length;e<n;++e)i.push(t[e].label);return i}function a(t,e,n){var i=t.getPixelForTick(e);return n&&(i-=0===e?(t.getPixelForTick(1)-i)/2:(i-t.getPixelForTick(e-1))/2),i}var o=t(25),r=t(26),l=t(45),s=t(34);o._set("scale",{display:!0,position:"left",offset:!1,gridLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawBorder:!0,drawOnChartArea:!0,drawTicks:!0,tickMarkLength:10,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",zeroLineBorderDash:[],zeroLineBorderDashOffset:0,offsetGridLines:!1,borderDash:[],borderDashOffset:0},scaleLabel:{display:!1,labelString:"",lineHeight:1.2,padding:{top:4,bottom:4}},ticks:{beginAtZero:!1,minRotation:0,maxRotation:50,mirror:!1,padding:0,reverse:!1,display:!0,autoSkip:!0,autoSkipPadding:0,labelOffset:0,callback:s.formatters.values,minor:{},major:{}}}),e.exports=function(t){function e(t,e,n){return l.isArray(e)?l.longestText(t,n,e):t.measureText(e).width}function n(t){var e=l.valueOrDefault,n=o.global,i=e(t.fontSize,n.defaultFontSize),a=e(t.fontStyle,n.defaultFontStyle),r=e(t.fontFamily,n.defaultFontFamily);return{size:i,style:a,family:r,font:l.fontString(i,a,r)}}function s(t){return l.options.toLineHeight(l.valueOrDefault(t.lineHeight,1.2),l.valueOrDefault(t.fontSize,o.global.defaultFontSize))}t.Scale=r.extend({getPadding:function(){var t=this;return{left:t.paddingLeft||0,top:t.paddingTop||0,right:t.paddingRight||0,bottom:t.paddingBottom||0}},getTicks:function(){return this._ticks},mergeTicksOptions:function(){var t=this.options.ticks;!1===t.minor&&(t.minor={display:!1}),!1===t.major&&(t.major={display:!1});for(var e in t)"major"!==e&&"minor"!==e&&(void 0===t.minor[e]&&(t.minor[e]=t[e]),void 0===t.major[e]&&(t.major[e]=t[e]))},beforeUpdate:function(){l.callback(this.options.beforeUpdate,[this])},update:function(t,e,n){var i,a,o,r,s,u,d=this;for(d.beforeUpdate(),d.maxWidth=t,d.maxHeight=e,d.margins=l.extend({left:0,right:0,top:0,bottom:0},n),d.longestTextCache=d.longestTextCache||{},d.beforeSetDimensions(),d.setDimensions(),d.afterSetDimensions(),d.beforeDataLimits(),d.determineDataLimits(),d.afterDataLimits(),d.beforeBuildTicks(),s=d.buildTicks()||[],d.afterBuildTicks(),d.beforeTickToLabelConversion(),o=d.convertTicksToLabels(s)||d.ticks,d.afterTickToLabelConversion(),d.ticks=o,i=0,a=o.length;i<a;++i)r=o[i],(u=s[i])?u.label=r:s.push(u={label:r,major:!1});return d._ticks=s,d.beforeCalculateTickRotation(),d.calculateTickRotation(),d.afterCalculateTickRotation(),d.beforeFit(),d.fit(),d.afterFit(),d.afterUpdate(),d.minSize},afterUpdate:function(){l.callback(this.options.afterUpdate,[this])},beforeSetDimensions:function(){l.callback(this.options.beforeSetDimensions,[this])},setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0},afterSetDimensions:function(){l.callback(this.options.afterSetDimensions,[this])},beforeDataLimits:function(){l.callback(this.options.beforeDataLimits,[this])},determineDataLimits:l.noop,afterDataLimits:function(){l.callback(this.options.afterDataLimits,[this])},beforeBuildTicks:function(){l.callback(this.options.beforeBuildTicks,[this])},buildTicks:l.noop,afterBuildTicks:function(){l.callback(this.options.afterBuildTicks,[this])},beforeTickToLabelConversion:function(){l.callback(this.options.beforeTickToLabelConversion,[this])},convertTicksToLabels:function(){var t=this,e=t.options.ticks;t.ticks=t.ticks.map(e.userCallback||e.callback,this)},afterTickToLabelConversion:function(){l.callback(this.options.afterTickToLabelConversion,[this])},beforeCalculateTickRotation:function(){l.callback(this.options.beforeCalculateTickRotation,[this])},calculateTickRotation:function(){var t=this,e=t.ctx,a=t.options.ticks,o=i(t._ticks),r=n(a);e.font=r.font;var s=a.minRotation||0;if(o.length&&t.options.display&&t.isHorizontal())for(var u,d=l.longestText(e,r.font,o,t.longestTextCache),c=d,h=t.getPixelForTick(1)-t.getPixelForTick(0)-6;c>h&&s<a.maxRotation;){var f=l.toRadians(s);if(u=Math.cos(f),Math.sin(f)*d>t.maxHeight){s--;break}s++,c=u*d}t.labelRotation=s},afterCalculateTickRotation:function(){l.callback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){l.callback(this.options.beforeFit,[this])},fit:function(){var t=this,a=t.minSize={width:0,height:0},o=i(t._ticks),r=t.options,u=r.ticks,d=r.scaleLabel,c=r.gridLines,h=r.display,f=t.isHorizontal(),g=n(u),p=r.gridLines.tickMarkLength;if(a.width=f?t.isFullWidth()?t.maxWidth-t.margins.left-t.margins.right:t.maxWidth:h&&c.drawTicks?p:0,a.height=f?h&&c.drawTicks?p:0:t.maxHeight,d.display&&h){var v=s(d)+l.options.toPadding(d.padding).height;f?a.height+=v:a.width+=v}if(u.display&&h){var m=l.longestText(t.ctx,g.font,o,t.longestTextCache),b=l.numberOfLabelLines(o),x=.5*g.size,y=t.options.ticks.padding;if(f){t.longestLabelWidth=m;var k=l.toRadians(t.labelRotation),w=Math.cos(k),M=Math.sin(k)*m+g.size*b+x*(b-1)+x;a.height=Math.min(t.maxHeight,a.height+M+y),t.ctx.font=g.font;var S=e(t.ctx,o[0],g.font),C=e(t.ctx,o[o.length-1],g.font);0!==t.labelRotation?(t.paddingLeft="bottom"===r.position?w*S+3:w*x+3,t.paddingRight="bottom"===r.position?w*x+3:w*C+3):(t.paddingLeft=S/2+3,t.paddingRight=C/2+3)}else u.mirror?m=0:m+=y+x,a.width=Math.min(t.maxWidth,a.width+m),t.paddingTop=g.size/2,t.paddingBottom=g.size/2}t.handleMargins(),t.width=a.width,t.height=a.height},handleMargins:function(){var t=this;t.margins&&(t.paddingLeft=Math.max(t.paddingLeft-t.margins.left,0),t.paddingTop=Math.max(t.paddingTop-t.margins.top,0),t.paddingRight=Math.max(t.paddingRight-t.margins.right,0),t.paddingBottom=Math.max(t.paddingBottom-t.margins.bottom,0))},afterFit:function(){l.callback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(t){if(l.isNullOrUndef(t))return NaN;if("number"==typeof t&&!isFinite(t))return NaN;if(t)if(this.isHorizontal()){if(void 0!==t.x)return this.getRightValue(t.x)}else if(void 0!==t.y)return this.getRightValue(t.y);return t},getLabelForIndex:l.noop,getPixelForValue:l.noop,getValueForPixel:l.noop,getPixelForTick:function(t){var e=this,n=e.options.offset;if(e.isHorizontal()){var i=(e.width-(e.paddingLeft+e.paddingRight))/Math.max(e._ticks.length-(n?0:1),1),a=i*t+e.paddingLeft;n&&(a+=i/2);var o=e.left+Math.round(a);return o+=e.isFullWidth()?e.margins.left:0}var r=e.height-(e.paddingTop+e.paddingBottom);return e.top+t*(r/(e._ticks.length-1))},getPixelForDecimal:function(t){var e=this;if(e.isHorizontal()){var n=(e.width-(e.paddingLeft+e.paddingRight))*t+e.paddingLeft,i=e.left+Math.round(n);return i+=e.isFullWidth()?e.margins.left:0}return e.top+t*e.height},getBasePixel:function(){return this.getPixelForValue(this.getBaseValue())},getBaseValue:function(){var t=this,e=t.min,n=t.max;return t.beginAtZero?0:e<0&&n<0?n:e>0&&n>0?e:0},_autoSkip:function(t){var e,n,i,a,o=this,r=o.isHorizontal(),s=o.options.ticks.minor,u=t.length,d=l.toRadians(o.labelRotation),c=Math.cos(d),h=o.longestLabelWidth*c,f=[];for(s.maxTicksLimit&&(a=s.maxTicksLimit),r&&(e=!1,(h+s.autoSkipPadding)*u>o.width-(o.paddingLeft+o.paddingRight)&&(e=1+Math.floor((h+s.autoSkipPadding)*u/(o.width-(o.paddingLeft+o.paddingRight)))),a&&u>a&&(e=Math.max(e,Math.floor(u/a)))),n=0;n<u;n++)i=t[n],(e>1&&n%e>0||n%e==0&&n+e>=u)&&n!==u-1&&delete i.label,f.push(i);return f},draw:function(t){var e=this,i=e.options;if(i.display){var r=e.ctx,u=o.global,d=i.ticks.minor,c=i.ticks.major||d,h=i.gridLines,f=i.scaleLabel,g=0!==e.labelRotation,p=e.isHorizontal(),v=d.autoSkip?e._autoSkip(e.getTicks()):e.getTicks(),m=l.valueOrDefault(d.fontColor,u.defaultFontColor),b=n(d),x=l.valueOrDefault(c.fontColor,u.defaultFontColor),y=n(c),k=h.drawTicks?h.tickMarkLength:0,w=l.valueOrDefault(f.fontColor,u.defaultFontColor),M=n(f),S=l.options.toPadding(f.padding),C=l.toRadians(e.labelRotation),_=[],D="right"===i.position?e.left:e.right-k,I="right"===i.position?e.left+k:e.right,P="bottom"===i.position?e.top:e.bottom-k,A="bottom"===i.position?e.top+k:e.bottom;if(l.each(v,function(n,o){if(!l.isNullOrUndef(n.label)){var r,s,c,f,m=n.label;o===e.zeroLineIndex&&i.offset===h.offsetGridLines?(r=h.zeroLineWidth,s=h.zeroLineColor,c=h.zeroLineBorderDash,f=h.zeroLineBorderDashOffset):(r=l.valueAtIndexOrDefault(h.lineWidth,o),s=l.valueAtIndexOrDefault(h.color,o),c=l.valueOrDefault(h.borderDash,u.borderDash),f=l.valueOrDefault(h.borderDashOffset,u.borderDashOffset));var b,x,y,w,M,S,T,F,O,R,L="middle",z="middle",B=d.padding;if(p){var W=k+B;"bottom"===i.position?(z=g?"middle":"top",L=g?"right":"center",R=e.top+W):(z=g?"middle":"bottom",L=g?"left":"center",R=e.bottom-W);var N=a(e,o,h.offsetGridLines&&v.length>1);N<e.left&&(s="rgba(0,0,0,0)"),N+=l.aliasPixel(r),O=e.getPixelForTick(o)+d.labelOffset,b=y=M=T=N,x=P,w=A,S=t.top,F=t.bottom}else{var V,E="left"===i.position;d.mirror?(L=E?"left":"right",V=B):(L=E?"right":"left",V=k+B),O=E?e.right-V:e.left+V;var H=a(e,o,h.offsetGridLines&&v.length>1);H<e.top&&(s="rgba(0,0,0,0)"),H+=l.aliasPixel(r),R=e.getPixelForTick(o)+d.labelOffset,b=D,y=I,M=t.left,T=t.right,x=w=S=F=H}_.push({tx1:b,ty1:x,tx2:y,ty2:w,x1:M,y1:S,x2:T,y2:F,labelX:O,labelY:R,glWidth:r,glColor:s,glBorderDash:c,glBorderDashOffset:f,rotation:-1*C,label:m,major:n.major,textBaseline:z,textAlign:L})}}),l.each(_,function(t){if(h.display&&(r.save(),r.lineWidth=t.glWidth,r.strokeStyle=t.glColor,r.setLineDash&&(r.setLineDash(t.glBorderDash),r.lineDashOffset=t.glBorderDashOffset),r.beginPath(),h.drawTicks&&(r.moveTo(t.tx1,t.ty1),r.lineTo(t.tx2,t.ty2)),h.drawOnChartArea&&(r.moveTo(t.x1,t.y1),r.lineTo(t.x2,t.y2)),r.stroke(),r.restore()),d.display){r.save(),r.translate(t.labelX,t.labelY),r.rotate(t.rotation),r.font=t.major?y.font:b.font,r.fillStyle=t.major?x:m,r.textBaseline=t.textBaseline,r.textAlign=t.textAlign;var e=t.label;if(l.isArray(e))for(var n=0,i=0;n<e.length;++n)r.fillText(""+e[n],0,i),i+=1.5*b.size;else r.fillText(e,0,0);r.restore()}}),f.display){var T,F,O=0,R=s(f)/2;if(p)T=e.left+(e.right-e.left)/2,F="bottom"===i.position?e.bottom-R-S.bottom:e.top+R+S.top;else{var L="left"===i.position;T=L?e.left+R+S.top:e.right-R-S.top,F=e.top+(e.bottom-e.top)/2,O=L?-.5*Math.PI:.5*Math.PI}r.save(),r.translate(T,F),r.rotate(O),r.textAlign="center",r.textBaseline="middle",r.fillStyle=w,r.font=M.font,r.fillText(f.labelString,0,0),r.restore()}if(h.drawBorder){r.lineWidth=l.valueAtIndexOrDefault(h.lineWidth,0),r.strokeStyle=l.valueAtIndexOrDefault(h.color,0);var z=e.left,B=e.right,W=e.top,N=e.bottom,V=l.aliasPixel(r.lineWidth);p?(W=N="top"===i.position?e.bottom:e.top,W+=V,N+=V):(z=B="left"===i.position?e.right:e.left,z+=V,B+=V),r.beginPath(),r.moveTo(z,W),r.lineTo(B,N),r.stroke()}}}})}},{25:25,26:26,34:34,45:45}],33:[function(t,e,n){"use strict";var i=t(25),a=t(45);e.exports=function(t){t.scaleService={constructors:{},defaults:{},registerScaleType:function(t,e,n){this.constructors[t]=e,this.defaults[t]=a.clone(n)},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0},getScaleDefaults:function(t){return this.defaults.hasOwnProperty(t)?a.merge({},[i.scale,this.defaults[t]]):{}},updateScaleDefaults:function(t,e){var n=this;n.defaults.hasOwnProperty(t)&&(n.defaults[t]=a.extend(n.defaults[t],e))},addScalesToLayout:function(e){a.each(e.scales,function(n){n.fullWidth=n.options.fullWidth,n.position=n.options.position,n.weight=n.options.weight,t.layoutService.addBox(e,n)})}}}},{25:25,45:45}],34:[function(t,e,n){"use strict";var i=t(45);e.exports={generators:{linear:function(t,e){var n,a=[];if(t.stepSize&&t.stepSize>0)n=t.stepSize;else{var o=i.niceNum(e.max-e.min,!1);n=i.niceNum(o/(t.maxTicks-1),!0)}var r=Math.floor(e.min/n)*n,l=Math.ceil(e.max/n)*n;t.min&&t.max&&t.stepSize&&i.almostWhole((t.max-t.min)/t.stepSize,n/1e3)&&(r=t.min,l=t.max);var s=(l-r)/n;s=i.almostEquals(s,Math.round(s),n/1e3)?Math.round(s):Math.ceil(s),a.push(void 0!==t.min?t.min:r);for(var u=1;u<s;++u)a.push(r+u*n);return a.push(void 0!==t.max?t.max:l),a},logarithmic:function(t,e){var n,a,o=[],r=i.valueOrDefault,l=r(t.min,Math.pow(10,Math.floor(i.log10(e.min)))),s=Math.floor(i.log10(e.max)),u=Math.ceil(e.max/Math.pow(10,s));0===l?(n=Math.floor(i.log10(e.minNotZero)),a=Math.floor(e.minNotZero/Math.pow(10,n)),o.push(l),l=a*Math.pow(10,n)):(n=Math.floor(i.log10(l)),a=Math.floor(l/Math.pow(10,n)));do{o.push(l),10===++a&&(a=1,++n),l=a*Math.pow(10,n)}while(n<s||n===s&&a<u);var d=r(t.max,l);return o.push(d),o}},formatters:{values:function(t){return i.isArray(t)?t:""+t},linear:function(t,e,n){var a=n.length>3?n[2]-n[1]:n[1]-n[0];Math.abs(a)>1&&t!==Math.floor(t)&&(a=t-Math.floor(t));var o=i.log10(Math.abs(a)),r="";if(0!==t){var l=-1*Math.floor(o);l=Math.max(Math.min(l,20),0),r=t.toFixed(l)}else r="0";return r},logarithmic:function(t,e,n){var a=t/Math.pow(10,Math.floor(i.log10(t)));return 0===t?"0":1===a||2===a||5===a||0===e||e===n.length-1?t.toExponential():""}}}},{45:45}],35:[function(t,e,n){"use strict";var i=t(25),a=t(26),o=t(45);i._set("global",{tooltips:{enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFontStyle:"bold",titleSpacing:2,titleMarginBottom:6,titleFontColor:"#fff",titleAlign:"left",bodySpacing:2,bodyFontColor:"#fff",bodyAlign:"left",footerFontStyle:"bold",footerSpacing:2,footerMarginTop:6,footerFontColor:"#fff",footerAlign:"left",yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,callbacks:{beforeTitle:o.noop,title:function(t,e){var n="",i=e.labels,a=i?i.length:0;if(t.length>0){var o=t[0];o.xLabel?n=o.xLabel:a>0&&o.index<a&&(n=i[o.index])}return n},afterTitle:o.noop,beforeBody:o.noop,beforeLabel:o.noop,label:function(t,e){var n=e.datasets[t.datasetIndex].label||"";return n&&(n+=": "),n+=t.yLabel},labelColor:function(t,e){var n=e.getDatasetMeta(t.datasetIndex).data[t.index]._view;return{borderColor:n.borderColor,backgroundColor:n.backgroundColor}},labelTextColor:function(){return this._options.bodyFontColor},afterLabel:o.noop,afterBody:o.noop,beforeFooter:o.noop,footer:o.noop,afterFooter:o.noop}}}),e.exports=function(t){function e(t,e){var n=o.color(t);return n.alpha(e*n.alpha()).rgbaString()}function n(t,e){return e&&(o.isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function r(t){var e=t._xScale,n=t._yScale||t._scale,i=t._index,a=t._datasetIndex;return{xLabel:e?e.getLabelForIndex(i,a):"",yLabel:n?n.getLabelForIndex(i,a):"",index:i,datasetIndex:a,x:t._model.x,y:t._model.y}}function l(t){var e=i.global,n=o.valueOrDefault;return{xPadding:t.xPadding,yPadding:t.yPadding,xAlign:t.xAlign,yAlign:t.yAlign,bodyFontColor:t.bodyFontColor,_bodyFontFamily:n(t.bodyFontFamily,e.defaultFontFamily),_bodyFontStyle:n(t.bodyFontStyle,e.defaultFontStyle),_bodyAlign:t.bodyAlign,bodyFontSize:n(t.bodyFontSize,e.defaultFontSize),bodySpacing:t.bodySpacing,titleFontColor:t.titleFontColor,_titleFontFamily:n(t.titleFontFamily,e.defaultFontFamily),_titleFontStyle:n(t.titleFontStyle,e.defaultFontStyle),titleFontSize:n(t.titleFontSize,e.defaultFontSize),_titleAlign:t.titleAlign,titleSpacing:t.titleSpacing,titleMarginBottom:t.titleMarginBottom,footerFontColor:t.footerFontColor,_footerFontFamily:n(t.footerFontFamily,e.defaultFontFamily),_footerFontStyle:n(t.footerFontStyle,e.defaultFontStyle),footerFontSize:n(t.footerFontSize,e.defaultFontSize),_footerAlign:t.footerAlign,footerSpacing:t.footerSpacing,footerMarginTop:t.footerMarginTop,caretSize:t.caretSize,cornerRadius:t.cornerRadius,backgroundColor:t.backgroundColor,opacity:0,legendColorBackground:t.multiKeyBackground,displayColors:t.displayColors,borderColor:t.borderColor,borderWidth:t.borderWidth}}function s(t,e){var n=t._chart.ctx,i=2*e.yPadding,a=0,r=e.body,l=r.reduce(function(t,e){return t+e.before.length+e.lines.length+e.after.length},0);l+=e.beforeBody.length+e.afterBody.length;var s=e.title.length,u=e.footer.length,d=e.titleFontSize,c=e.bodyFontSize,h=e.footerFontSize;i+=s*d,i+=s?(s-1)*e.titleSpacing:0,i+=s?e.titleMarginBottom:0,i+=l*c,i+=l?(l-1)*e.bodySpacing:0,i+=u?e.footerMarginTop:0,i+=u*h,i+=u?(u-1)*e.footerSpacing:0;var f=0,g=function(t){a=Math.max(a,n.measureText(t).width+f)};return n.font=o.fontString(d,e._titleFontStyle,e._titleFontFamily),o.each(e.title,g),n.font=o.fontString(c,e._bodyFontStyle,e._bodyFontFamily),o.each(e.beforeBody.concat(e.afterBody),g),f=e.displayColors?c+2:0,o.each(r,function(t){o.each(t.before,g),o.each(t.lines,g),o.each(t.after,g)}),f=0,n.font=o.fontString(h,e._footerFontStyle,e._footerFontFamily),o.each(e.footer,g),a+=2*e.xPadding,{width:a,height:i}}function u(t,e){var n=t._model,i=t._chart,a=t._chart.chartArea,o="center",r="center";n.y<e.height?r="top":n.y>i.height-e.height&&(r="bottom");var l,s,u,d,c,h=(a.left+a.right)/2,f=(a.top+a.bottom)/2;"center"===r?(l=function(t){return t<=h},s=function(t){return t>h}):(l=function(t){return t<=e.width/2},s=function(t){return t>=i.width-e.width/2}),u=function(t){return t+e.width>i.width},d=function(t){return t-e.width<0},c=function(t){return t<=f?"top":"bottom"},l(n.x)?(o="left",u(n.x)&&(o="center",r=c(n.y))):s(n.x)&&(o="right",d(n.x)&&(o="center",r=c(n.y)));var g=t._options;return{xAlign:g.xAlign?g.xAlign:o,yAlign:g.yAlign?g.yAlign:r}}function d(t,e,n){var i=t.x,a=t.y,o=t.caretSize,r=t.caretPadding,l=t.cornerRadius,s=n.xAlign,u=n.yAlign,d=o+r,c=l+r;return"right"===s?i-=e.width:"center"===s&&(i-=e.width/2),"top"===u?a+=d:a-="bottom"===u?e.height+d:e.height/2,"center"===u?"left"===s?i+=d:"right"===s&&(i-=d):"left"===s?i-=c:"right"===s&&(i+=c),{x:i,y:a}}t.Tooltip=a.extend({initialize:function(){this._model=l(this._options),this._lastActive=[]},getTitle:function(){var t=this,e=t._options.callbacks,i=e.beforeTitle.apply(t,arguments),a=e.title.apply(t,arguments),o=e.afterTitle.apply(t,arguments),r=[];return r=n(r,i),r=n(r,a),r=n(r,o)},getBeforeBody:function(){var t=this._options.callbacks.beforeBody.apply(this,arguments);return o.isArray(t)?t:void 0!==t?[t]:[]},getBody:function(t,e){var i=this,a=i._options.callbacks,r=[];return o.each(t,function(t){var o={before:[],lines:[],after:[]};n(o.before,a.beforeLabel.call(i,t,e)),n(o.lines,a.label.call(i,t,e)),n(o.after,a.afterLabel.call(i,t,e)),r.push(o)}),r},getAfterBody:function(){var t=this._options.callbacks.afterBody.apply(this,arguments);return o.isArray(t)?t:void 0!==t?[t]:[]},getFooter:function(){var t=this,e=t._options.callbacks,i=e.beforeFooter.apply(t,arguments),a=e.footer.apply(t,arguments),o=e.afterFooter.apply(t,arguments),r=[];return r=n(r,i),r=n(r,a),r=n(r,o)},update:function(e){var n,i,a=this,c=a._options,h=a._model,f=a._model=l(c),g=a._active,p=a._data,v={xAlign:h.xAlign,yAlign:h.yAlign},m={x:h.x,y:h.y},b={width:h.width,height:h.height},x={x:h.caretX,y:h.caretY};if(g.length){f.opacity=1;var y=[],k=[];x=t.Tooltip.positioners[c.position].call(a,g,a._eventPosition);var w=[];for(n=0,i=g.length;n<i;++n)w.push(r(g[n]));c.filter&&(w=w.filter(function(t){return c.filter(t,p)})),c.itemSort&&(w=w.sort(function(t,e){return c.itemSort(t,e,p)})),o.each(w,function(t){y.push(c.callbacks.labelColor.call(a,t,a._chart)),k.push(c.callbacks.labelTextColor.call(a,t,a._chart))}),f.title=a.getTitle(w,p),f.beforeBody=a.getBeforeBody(w,p),f.body=a.getBody(w,p),f.afterBody=a.getAfterBody(w,p),f.footer=a.getFooter(w,p),f.x=Math.round(x.x),f.y=Math.round(x.y),f.caretPadding=c.caretPadding,f.labelColors=y,f.labelTextColors=k,f.dataPoints=w,m=d(f,b=s(this,f),v=u(this,b))}else f.opacity=0;return f.xAlign=v.xAlign,f.yAlign=v.yAlign,f.x=m.x,f.y=m.y,f.width=b.width,f.height=b.height,f.caretX=x.x,f.caretY=x.y,a._model=f,e&&c.custom&&c.custom.call(a,f),a},drawCaret:function(t,e){var n=this._chart.ctx,i=this._view,a=this.getCaretPosition(t,e,i);n.lineTo(a.x1,a.y1),n.lineTo(a.x2,a.y2),n.lineTo(a.x3,a.y3)},getCaretPosition:function(t,e,n){var i,a,o,r,l,s,u=n.caretSize,d=n.cornerRadius,c=n.xAlign,h=n.yAlign,f=t.x,g=t.y,p=e.width,v=e.height;if("center"===h)l=g+v/2,"left"===c?(a=(i=f)-u,o=i,r=l+u,s=l-u):(a=(i=f+p)+u,o=i,r=l-u,s=l+u);else if("left"===c?(i=(a=f+d+u)-u,o=a+u):"right"===c?(i=(a=f+p-d-u)-u,o=a+u):(i=(a=f+p/2)-u,o=a+u),"top"===h)l=(r=g)-u,s=r;else{l=(r=g+v)+u,s=r;var m=o;o=i,i=m}return{x1:i,x2:a,x3:o,y1:r,y2:l,y3:s}},drawTitle:function(t,n,i,a){var r=n.title;if(r.length){i.textAlign=n._titleAlign,i.textBaseline="top";var l=n.titleFontSize,s=n.titleSpacing;i.fillStyle=e(n.titleFontColor,a),i.font=o.fontString(l,n._titleFontStyle,n._titleFontFamily);var u,d;for(u=0,d=r.length;u<d;++u)i.fillText(r[u],t.x,t.y),t.y+=l+s,u+1===r.length&&(t.y+=n.titleMarginBottom-s)}},drawBody:function(t,n,i,a){var r=n.bodyFontSize,l=n.bodySpacing,s=n.body;i.textAlign=n._bodyAlign,i.textBaseline="top",i.font=o.fontString(r,n._bodyFontStyle,n._bodyFontFamily);var u=0,d=function(e){i.fillText(e,t.x+u,t.y),t.y+=r+l};i.fillStyle=e(n.bodyFontColor,a),o.each(n.beforeBody,d);var c=n.displayColors;u=c?r+2:0,o.each(s,function(l,s){var u=e(n.labelTextColors[s],a);i.fillStyle=u,o.each(l.before,d),o.each(l.lines,function(o){c&&(i.fillStyle=e(n.legendColorBackground,a),i.fillRect(t.x,t.y,r,r),i.lineWidth=1,i.strokeStyle=e(n.labelColors[s].borderColor,a),i.strokeRect(t.x,t.y,r,r),i.fillStyle=e(n.labelColors[s].backgroundColor,a),i.fillRect(t.x+1,t.y+1,r-2,r-2),i.fillStyle=u),d(o)}),o.each(l.after,d)}),u=0,o.each(n.afterBody,d),t.y-=l},drawFooter:function(t,n,i,a){var r=n.footer;r.length&&(t.y+=n.footerMarginTop,i.textAlign=n._footerAlign,i.textBaseline="top",i.fillStyle=e(n.footerFontColor,a),i.font=o.fontString(n.footerFontSize,n._footerFontStyle,n._footerFontFamily),o.each(r,function(e){i.fillText(e,t.x,t.y),t.y+=n.footerFontSize+n.footerSpacing}))},drawBackground:function(t,n,i,a,o){i.fillStyle=e(n.backgroundColor,o),i.strokeStyle=e(n.borderColor,o),i.lineWidth=n.borderWidth;var r=n.xAlign,l=n.yAlign,s=t.x,u=t.y,d=a.width,c=a.height,h=n.cornerRadius;i.beginPath(),i.moveTo(s+h,u),"top"===l&&this.drawCaret(t,a),i.lineTo(s+d-h,u),i.quadraticCurveTo(s+d,u,s+d,u+h),"center"===l&&"right"===r&&this.drawCaret(t,a),i.lineTo(s+d,u+c-h),i.quadraticCurveTo(s+d,u+c,s+d-h,u+c),"bottom"===l&&this.drawCaret(t,a),i.lineTo(s+h,u+c),i.quadraticCurveTo(s,u+c,s,u+c-h),"center"===l&&"left"===r&&this.drawCaret(t,a),i.lineTo(s,u+h),i.quadraticCurveTo(s,u,s+h,u),i.closePath(),i.fill(),n.borderWidth>0&&i.stroke()},draw:function(){var t=this._chart.ctx,e=this._view;if(0!==e.opacity){var n={width:e.width,height:e.height},i={x:e.x,y:e.y},a=Math.abs(e.opacity<.001)?0:e.opacity,o=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;this._options.enabled&&o&&(this.drawBackground(i,e,t,n,a),i.x+=e.xPadding,i.y+=e.yPadding,this.drawTitle(i,e,t,a),this.drawBody(i,e,t,a),this.drawFooter(i,e,t,a))}},handleEvent:function(t){var e=this,n=e._options,i=!1;if(e._lastActive=e._lastActive||[],"mouseout"===t.type?e._active=[]:e._active=e._chart.getElementsAtEventForMode(t,n.mode,n),!(i=!o.arrayEquals(e._active,e._lastActive)))return!1;if(e._lastActive=e._active,n.enabled||n.custom){e._eventPosition={x:t.x,y:t.y};var a=e._model;e.update(!0),e.pivot(),i|=a.x!==e._model.x||a.y!==e._model.y}return i}}),t.Tooltip.positioners={average:function(t){if(!t.length)return!1;var e,n,i=0,a=0,o=0;for(e=0,n=t.length;e<n;++e){var r=t[e];if(r&&r.hasValue()){var l=r.tooltipPosition();i+=l.x,a+=l.y,++o}}return{x:Math.round(i/o),y:Math.round(a/o)}},nearest:function(t,e){var n,i,a,r=e.x,l=e.y,s=Number.POSITIVE_INFINITY;for(n=0,i=t.length;n<i;++n){var u=t[n];if(u&&u.hasValue()){var d=u.getCenterPoint(),c=o.distanceBetweenPoints(e,d);c<s&&(s=c,a=u)}}if(a){var h=a.tooltipPosition();r=h.x,l=h.y}return{x:r,y:l}}}}},{25:25,26:26,45:45}],36:[function(t,e,n){"use strict";var i=t(25),a=t(26),o=t(45);i._set("global",{elements:{arc:{backgroundColor:i.global.defaultColor,borderColor:"#fff",borderWidth:2}}}),e.exports=a.extend({inLabelRange:function(t){var e=this._view;return!!e&&Math.pow(t-e.x,2)<Math.pow(e.radius+e.hoverRadius,2)},inRange:function(t,e){var n=this._view;if(n){for(var i=o.getAngleFromPoint(n,{x:t,y:e}),a=i.angle,r=i.distance,l=n.startAngle,s=n.endAngle;s<l;)s+=2*Math.PI;for(;a>s;)a-=2*Math.PI;for(;a<l;)a+=2*Math.PI;var u=a>=l&&a<=s,d=r>=n.innerRadius&&r<=n.outerRadius;return u&&d}return!1},getCenterPoint:function(){var t=this._view,e=(t.startAngle+t.endAngle)/2,n=(t.innerRadius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},getArea:function(){var t=this._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,n=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},draw:function(){var t=this._chart.ctx,e=this._view,n=e.startAngle,i=e.endAngle;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,n,i),t.arc(e.x,e.y,e.innerRadius,i,n,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})},{25:25,26:26,45:45}],37:[function(t,e,n){"use strict";var i=t(25),a=t(26),o=t(45),r=i.global;i._set("global",{elements:{line:{tension:.4,backgroundColor:r.defaultColor,borderWidth:3,borderColor:r.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0}}}),e.exports=a.extend({draw:function(){var t,e,n,i,a=this,l=a._view,s=a._chart.ctx,u=l.spanGaps,d=a._children.slice(),c=r.elements.line,h=-1;for(a._loop&&d.length&&d.push(d[0]),s.save(),s.lineCap=l.borderCapStyle||c.borderCapStyle,s.setLineDash&&s.setLineDash(l.borderDash||c.borderDash),s.lineDashOffset=l.borderDashOffset||c.borderDashOffset,s.lineJoin=l.borderJoinStyle||c.borderJoinStyle,s.lineWidth=l.borderWidth||c.borderWidth,s.strokeStyle=l.borderColor||r.defaultColor,s.beginPath(),h=-1,t=0;t<d.length;++t)e=d[t],n=o.previousItem(d,t),i=e._view,0===t?i.skip||(s.moveTo(i.x,i.y),h=t):(n=-1===h?n:d[h],i.skip||(h!==t-1&&!u||-1===h?s.moveTo(i.x,i.y):o.canvas.lineTo(s,n._view,e._view),h=t));s.stroke(),s.restore()}})},{25:25,26:26,45:45}],38:[function(t,e,n){"use strict";function i(t){var e=this._view;return!!e&&Math.pow(t-e.x,2)<Math.pow(e.radius+e.hitRadius,2)}var a=t(25),o=t(26),r=t(45),l=a.global.defaultColor;a._set("global",{elements:{point:{radius:3,pointStyle:"circle",backgroundColor:l,borderColor:l,borderWidth:1,hitRadius:1,hoverRadius:4,hoverBorderWidth:1}}}),e.exports=o.extend({inRange:function(t,e){var n=this._view;return!!n&&Math.pow(t-n.x,2)+Math.pow(e-n.y,2)<Math.pow(n.hitRadius+n.radius,2)},inLabelRange:i,inXRange:i,inYRange:function(t){var e=this._view;return!!e&&Math.pow(t-e.y,2)<Math.pow(e.radius+e.hitRadius,2)},getCenterPoint:function(){var t=this._view;return{x:t.x,y:t.y}},getArea:function(){return Math.PI*Math.pow(this._view.radius,2)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y,padding:t.radius+t.borderWidth}},draw:function(t){var e=this._view,n=this._model,i=this._chart.ctx,o=e.pointStyle,s=e.radius,u=e.x,d=e.y,c=r.color,h=0;e.skip||(i.strokeStyle=e.borderColor||l,i.lineWidth=r.valueOrDefault(e.borderWidth,a.global.elements.point.borderWidth),i.fillStyle=e.backgroundColor||l,void 0!==t&&(n.x<t.left||1.01*t.right<n.x||n.y<t.top||1.01*t.bottom<n.y)&&(n.x<t.left?h=(u-n.x)/(t.left-n.x):1.01*t.right<n.x?h=(n.x-u)/(n.x-t.right):n.y<t.top?h=(d-n.y)/(t.top-n.y):1.01*t.bottom<n.y&&(h=(n.y-d)/(n.y-t.bottom)),h=Math.round(100*h)/100,i.strokeStyle=c(i.strokeStyle).alpha(h).rgbString(),i.fillStyle=c(i.fillStyle).alpha(h).rgbString()),r.canvas.drawPoint(i,o,s,u,d))}})},{25:25,26:26,45:45}],39:[function(t,e,n){"use strict";function i(t){return void 0!==t._view.width}function a(t){var e,n,a,o,r=t._view;if(i(t)){var l=r.width/2;e=r.x-l,n=r.x+l,a=Math.min(r.y,r.base),o=Math.max(r.y,r.base)}else{var s=r.height/2;e=Math.min(r.x,r.base),n=Math.max(r.x,r.base),a=r.y-s,o=r.y+s}return{left:e,top:a,right:n,bottom:o}}var o=t(25),r=t(26);o._set("global",{elements:{rectangle:{backgroundColor:o.global.defaultColor,borderColor:o.global.defaultColor,borderSkipped:"bottom",borderWidth:0}}}),e.exports=r.extend({draw:function(){function t(t){return m[(b+t)%4]}var e,n,i,a,o,r,l,s=this._chart.ctx,u=this._view,d=u.borderWidth;if(u.horizontal?(e=u.base,n=u.x,i=u.y-u.height/2,a=u.y+u.height/2,o=n>e?1:-1,r=1,l=u.borderSkipped||"left"):(e=u.x-u.width/2,n=u.x+u.width/2,i=u.y,o=1,r=(a=u.base)>i?1:-1,l=u.borderSkipped||"bottom"),d){var c=Math.min(Math.abs(e-n),Math.abs(i-a)),h=(d=d>c?c:d)/2,f=e+("left"!==l?h*o:0),g=n+("right"!==l?-h*o:0),p=i+("top"!==l?h*r:0),v=a+("bottom"!==l?-h*r:0);f!==g&&(i=p,a=v),p!==v&&(e=f,n=g)}s.beginPath(),s.fillStyle=u.backgroundColor,s.strokeStyle=u.borderColor,s.lineWidth=d;var m=[[e,a],[e,i],[n,i],[n,a]],b=["bottom","left","top","right"].indexOf(l,0);-1===b&&(b=0);var x=t(0);s.moveTo(x[0],x[1]);for(var y=1;y<4;y++)x=t(y),s.lineTo(x[0],x[1]);s.fill(),d&&s.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var n=!1;if(this._view){var i=a(this);n=t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}return n},inLabelRange:function(t,e){var n=this;if(!n._view)return!1;var o=a(n);return i(n)?t>=o.left&&t<=o.right:e>=o.top&&e<=o.bottom},inXRange:function(t){var e=a(this);return t>=e.left&&t<=e.right},inYRange:function(t){var e=a(this);return t>=e.top&&t<=e.bottom},getCenterPoint:function(){var t,e,n=this._view;return i(this)?(t=n.x,e=(n.y+n.base)/2):(t=(n.x+n.base)/2,e=n.y),{x:t,y:e}},getArea:function(){var t=this._view;return t.width*Math.abs(t.y-t.base)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})},{25:25,26:26}],40:[function(t,e,n){"use strict";e.exports={},e.exports.Arc=t(36),e.exports.Line=t(37),e.exports.Point=t(38),e.exports.Rectangle=t(39)},{36:36,37:37,38:38,39:39}],41:[function(t,e,n){"use strict";var i=t(42),n=e.exports={clear:function(t){t.ctx.clearRect(0,0,t.width,t.height)},roundedRect:function(t,e,n,i,a,o){if(o){var r=Math.min(o,i/2),l=Math.min(o,a/2);t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+l),t.lineTo(e+i,n+a-l),t.quadraticCurveTo(e+i,n+a,e+i-r,n+a),t.lineTo(e+r,n+a),t.quadraticCurveTo(e,n+a,e,n+a-l),t.lineTo(e,n+l),t.quadraticCurveTo(e,n,e+r,n)}else t.rect(e,n,i,a)},drawPoint:function(t,e,n,i,a){var o,r,l,s,u,d;if(!e||"object"!=typeof e||"[object HTMLImageElement]"!==(o=e.toString())&&"[object HTMLCanvasElement]"!==o){if(!(isNaN(n)||n<=0)){switch(e){default:t.beginPath(),t.arc(i,a,n,0,2*Math.PI),t.closePath(),t.fill();break;case"triangle":t.beginPath(),u=(r=3*n/Math.sqrt(3))*Math.sqrt(3)/2,t.moveTo(i-r/2,a+u/3),t.lineTo(i+r/2,a+u/3),t.lineTo(i,a-2*u/3),t.closePath(),t.fill();break;case"rect":d=1/Math.SQRT2*n,t.beginPath(),t.fillRect(i-d,a-d,2*d,2*d),t.strokeRect(i-d,a-d,2*d,2*d);break;case"rectRounded":var c=n/Math.SQRT2,h=i-c,f=a-c,g=Math.SQRT2*n;t.beginPath(),this.roundedRect(t,h,f,g,g,n/2),t.closePath(),t.fill();break;case"rectRot":d=1/Math.SQRT2*n,t.beginPath(),t.moveTo(i-d,a),t.lineTo(i,a+d),t.lineTo(i+d,a),t.lineTo(i,a-d),t.closePath(),t.fill();break;case"cross":t.beginPath(),t.moveTo(i,a+n),t.lineTo(i,a-n),t.moveTo(i-n,a),t.lineTo(i+n,a),t.closePath();break;case"crossRot":t.beginPath(),l=Math.cos(Math.PI/4)*n,s=Math.sin(Math.PI/4)*n,t.moveTo(i-l,a-s),t.lineTo(i+l,a+s),t.moveTo(i-l,a+s),t.lineTo(i+l,a-s),t.closePath();break;case"star":t.beginPath(),t.moveTo(i,a+n),t.lineTo(i,a-n),t.moveTo(i-n,a),t.lineTo(i+n,a),l=Math.cos(Math.PI/4)*n,s=Math.sin(Math.PI/4)*n,t.moveTo(i-l,a-s),t.lineTo(i+l,a+s),t.moveTo(i-l,a+s),t.lineTo(i+l,a-s),t.closePath();break;case"line":t.beginPath(),t.moveTo(i-n,a),t.lineTo(i+n,a),t.closePath();break;case"dash":t.beginPath(),t.moveTo(i,a),t.lineTo(i+n,a),t.closePath()}t.stroke()}}else t.drawImage(e,i-e.width/2,a-e.height/2,e.width,e.height)},clipArea:function(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()},unclipArea:function(t){t.restore()},lineTo:function(t,e,n,i){if(n.steppedLine)return"after"===n.steppedLine&&!i||"after"!==n.steppedLine&&i?t.lineTo(e.x,n.y):t.lineTo(n.x,e.y),void t.lineTo(n.x,n.y);n.tension?t.bezierCurveTo(i?e.controlPointPreviousX:e.controlPointNextX,i?e.controlPointPreviousY:e.controlPointNextY,i?n.controlPointNextX:n.controlPointPreviousX,i?n.controlPointNextY:n.controlPointPreviousY,n.x,n.y):t.lineTo(n.x,n.y)}};i.clear=n.clear,i.drawRoundedRectangle=function(t){t.beginPath(),n.roundedRect.apply(n,arguments),t.closePath()}},{42:42}],42:[function(t,e,n){"use strict";var i={noop:function(){},uid:function(){var t=0;return function(){return t++}}(),isNullOrUndef:function(t){return null===t||void 0===t},isArray:Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)},valueOrDefault:function(t,e){return void 0===t?e:t},valueAtIndexOrDefault:function(t,e,n){return i.valueOrDefault(i.isArray(t)?t[e]:t,n)},callback:function(t,e,n){if(t&&"function"==typeof t.call)return t.apply(n,e)},each:function(t,e,n,a){var o,r,l;if(i.isArray(t))if(r=t.length,a)for(o=r-1;o>=0;o--)e.call(n,t[o],o);else for(o=0;o<r;o++)e.call(n,t[o],o);else if(i.isObject(t))for(r=(l=Object.keys(t)).length,o=0;o<r;o++)e.call(n,t[l[o]],l[o])},arrayEquals:function(t,e){var n,a,o,r;if(!t||!e||t.length!==e.length)return!1;for(n=0,a=t.length;n<a;++n)if(o=t[n],r=e[n],o instanceof Array&&r instanceof Array){if(!i.arrayEquals(o,r))return!1}else if(o!==r)return!1;return!0},clone:function(t){if(i.isArray(t))return t.map(i.clone);if(i.isObject(t)){for(var e={},n=Object.keys(t),a=n.length,o=0;o<a;++o)e[n[o]]=i.clone(t[n[o]]);return e}return t},_merger:function(t,e,n,a){var o=e[t],r=n[t];i.isObject(o)&&i.isObject(r)?i.merge(o,r,a):e[t]=i.clone(r)},_mergerIf:function(t,e,n){var a=e[t],o=n[t];i.isObject(a)&&i.isObject(o)?i.mergeIf(a,o):e.hasOwnProperty(t)||(e[t]=i.clone(o))},merge:function(t,e,n){var a,o,r,l,s,u=i.isArray(e)?e:[e],d=u.length;if(!i.isObject(t))return t;for(a=(n=n||{}).merger||i._merger,o=0;o<d;++o)if(e=u[o],i.isObject(e))for(s=0,l=(r=Object.keys(e)).length;s<l;++s)a(r[s],t,e,n);return t},mergeIf:function(t,e){return i.merge(t,e,{merger:i._mergerIf})},extend:function(t){for(var e=1,n=arguments.length;e<n;++e)i.each(arguments[e],function(e,n){t[n]=e});return t},inherits:function(t){var e=this,n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=n};return a.prototype=e.prototype,n.prototype=new a,n.extend=i.inherits,t&&i.extend(n.prototype,t),n.__super__=e.prototype,n}};e.exports=i,i.callCallback=i.callback,i.indexOf=function(t,e,n){return Array.prototype.indexOf.call(t,e,n)},i.getValueOrDefault=i.valueOrDefault,i.getValueAtIndexOrDefault=i.valueAtIndexOrDefault},{}],43:[function(t,e,n){"use strict";var i=t(42),a={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return(t-=1)*t*t+1},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-((t-=1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return(t-=1)*t*t*t*t+1},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return 1-Math.cos(t*(Math.PI/2))},easeOutSine:function(t){return Math.sin(t*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:1-Math.pow(2,-10*t)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t))},easeInCirc:function(t){return t>=1?t:-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-(t-=1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e=1.70158,n=0,i=1;return 0===t?0:1===t?1:(n||(n=.3),i<1?(i=1,e=n/4):e=n/(2*Math.PI)*Math.asin(1/i),-i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n))},easeOutElastic:function(t){var e=1.70158,n=0,i=1;return 0===t?0:1===t?1:(n||(n=.3),i<1?(i=1,e=n/4):e=n/(2*Math.PI)*Math.asin(1/i),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},easeInOutElastic:function(t){var e=1.70158,n=0,i=1;return 0===t?0:2==(t/=.5)?1:(n||(n=.45),i<1?(i=1,e=n/4):e=n/(2*Math.PI)*Math.asin(1/i),t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},easeInBack:function(t){var e=1.70158;return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:function(t){return 1-a.easeOutBounce(1-t)},easeOutBounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInOutBounce:function(t){return t<.5?.5*a.easeInBounce(2*t):.5*a.easeOutBounce(2*t-1)+.5}};e.exports={effects:a},i.easingEffects=a},{42:42}],44:[function(t,e,n){"use strict";var i=t(42);e.exports={toLineHeight:function(t,e){var n=(""+t).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);if(!n||"normal"===n[1])return 1.2*e;switch(t=+n[2],n[3]){case"px":return t;case"%":t/=100}return e*t},toPadding:function(t){var e,n,a,o;return i.isObject(t)?(e=+t.top||0,n=+t.right||0,a=+t.bottom||0,o=+t.left||0):e=n=a=o=+t||0,{top:e,right:n,bottom:a,left:o,height:e+a,width:o+n}},resolve:function(t,e,n){var a,o,r;for(a=0,o=t.length;a<o;++a)if(void 0!==(r=t[a])&&(void 0!==e&&"function"==typeof r&&(r=r(e)),void 0!==n&&i.isArray(r)&&(r=r[n]),void 0!==r))return r}}},{42:42}],45:[function(t,e,n){"use strict";e.exports=t(42),e.exports.easing=t(43),e.exports.canvas=t(41),e.exports.options=t(44)},{41:41,42:42,43:43,44:44}],46:[function(t,e,n){e.exports={acquireContext:function(t){return t&&t.canvas&&(t=t.canvas),t&&t.getContext("2d")||null}}},{}],47:[function(t,e,n){"use strict";function i(t,e){var n=v.getStyle(t,e),i=n&&n.match(/^(\d+)(\.\d+)?px$/);return i?Number(i[1]):void 0}function a(t,e){var n=t.style,a=t.getAttribute("height"),o=t.getAttribute("width");if(t[m]={initial:{height:a,width:o,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",null===o||""===o){var r=i(t,"width");void 0!==r&&(t.width=r)}if(null===a||""===a)if(""===t.style.height)t.height=t.width/(e.options.aspectRatio||2);else{var l=i(t,"height");void 0!==r&&(t.height=l)}return t}function o(t,e,n){t.addEventListener(e,n,M)}function r(t,e,n){t.removeEventListener(e,n,M)}function l(t,e,n,i,a){return{type:t,chart:e,native:a||null,x:void 0!==n?n:null,y:void 0!==i?i:null}}function s(t,e){var n=w[t.type]||t.type,i=v.getRelativePosition(t,e);return l(n,e,i.x,i.y,t)}function u(t,e){var n=!1,i=[];return function(){i=Array.prototype.slice.call(arguments),e=e||this,n||(n=!0,v.requestAnimFrame.call(window,function(){n=!1,t.apply(e,i)}))}}function d(t){var e=document.createElement("div"),n=b+"size-monitor",i="position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1;";e.style.cssText=i,e.className=n,e.innerHTML='<div class="'+n+'-expand" style="'+i+'"><div style="position:absolute;width:1000000px;height:1000000px;left:0;top:0"></div></div><div class="'+n+'-shrink" style="'+i+'"><div style="position:absolute;width:200%;height:200%;left:0; top:0"></div></div>';var a=e.childNodes[0],r=e.childNodes[1];e._reset=function(){a.scrollLeft=1e6,a.scrollTop=1e6,r.scrollLeft=1e6,r.scrollTop=1e6};var l=function(){e._reset(),t()};return o(a,"scroll",l.bind(a,"expand")),o(r,"scroll",l.bind(r,"shrink")),e}function c(t,e){var n=t[m]||(t[m]={}),i=n.renderProxy=function(t){t.animationName===y&&e()};v.each(k,function(e){o(t,e,i)}),n.reflow=!!t.offsetParent,t.classList.add(x)}function h(t){var e=t[m]||{},n=e.renderProxy;n&&(v.each(k,function(e){r(t,e,n)}),delete e.renderProxy),t.classList.remove(x)}function f(t,e,n){var i=t[m]||(t[m]={}),a=i.resizer=d(u(function(){if(i.resizer)return e(l("resize",n))}));c(t,function(){if(i.resizer){var e=t.parentNode;e&&e!==a.parentNode&&e.insertBefore(a,e.firstChild),a._reset()}})}function g(t){var e=t[m]||{},n=e.resizer;delete e.resizer,h(t),n&&n.parentNode&&n.parentNode.removeChild(n)}function p(t,e){var n=t._style||document.createElement("style");t._style||(t._style=n,e="/* Chart.js */\n"+e,n.setAttribute("type","text/css"),document.getElementsByTagName("head")[0].appendChild(n)),n.appendChild(document.createTextNode(e))}var v=t(45),m="$chartjs",b="chartjs-",x=b+"render-monitor",y=b+"render-animation",k=["animationstart","webkitAnimationStart"],w={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},M=!!function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("e",null,e)}catch(t){}return t}()&&{passive:!0};e.exports={_enabled:"undefined"!=typeof window&&"undefined"!=typeof document,initialize:function(){var t="from{opacity:0.99}to{opacity:1}";p(this,"@-webkit-keyframes "+y+"{"+t+"}@keyframes "+y+"{"+t+"}."+x+"{-webkit-animation:"+y+" 0.001s;animation:"+y+" 0.001s;}")},acquireContext:function(t,e){"string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas);var n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(a(t,e),n):null},releaseContext:function(t){var e=t.canvas;if(e[m]){var n=e[m].initial;["height","width"].forEach(function(t){var i=n[t];v.isNullOrUndef(i)?e.removeAttribute(t):e.setAttribute(t,i)}),v.each(n.style||{},function(t,n){e.style[n]=t}),e.width=e.width,delete e[m]}},addEventListener:function(t,e,n){var i=t.canvas;if("resize"!==e){var a=n[m]||(n[m]={});o(i,e,(a.proxies||(a.proxies={}))[t.id+"_"+e]=function(e){n(s(e,t))})}else f(i,n,t)},removeEventListener:function(t,e,n){var i=t.canvas;if("resize"!==e){var a=((n[m]||{}).proxies||{})[t.id+"_"+e];a&&r(i,e,a)}else g(i)}},v.addEvent=o,v.removeEvent=r},{45:45}],48:[function(t,e,n){"use strict";var i=t(45),a=t(46),o=t(47),r=o._enabled?o:a;e.exports=i.extend({initialize:function(){},acquireContext:function(){},releaseContext:function(){},addEventListener:function(){},removeEventListener:function(){}},r)},{45:45,46:46,47:47}],49:[function(t,e,n){"use strict";var i=t(25),a=t(40),o=t(45);i._set("global",{plugins:{filler:{propagate:!0}}}),e.exports=function(){function t(t,e,n){var i,a=t._model||{},o=a.fill;if(void 0===o&&(o=!!a.backgroundColor),!1===o||null===o)return!1;if(!0===o)return"origin";if(i=parseFloat(o,10),isFinite(i)&&Math.floor(i)===i)return"-"!==o[0]&&"+"!==o[0]||(i=e+i),!(i===e||i<0||i>=n)&&i;switch(o){case"bottom":return"start";case"top":return"end";case"zero":return"origin";case"origin":case"start":case"end":return o;default:return!1}}function e(t){var e,n=t.el._model||{},i=t.el._scale||{},a=t.fill,o=null;if(isFinite(a))return null;if("start"===a?o=void 0===n.scaleBottom?i.bottom:n.scaleBottom:"end"===a?o=void 0===n.scaleTop?i.top:n.scaleTop:void 0!==n.scaleZero?o=n.scaleZero:i.getBasePosition?o=i.getBasePosition():i.getBasePixel&&(o=i.getBasePixel()),void 0!==o&&null!==o){if(void 0!==o.x&&void 0!==o.y)return o;if("number"==typeof o&&isFinite(o))return e=i.isHorizontal(),{x:e?o:null,y:e?null:o}}return null}function n(t,e,n){var i,a=t[e].fill,o=[e];if(!n)return a;for(;!1!==a&&-1===o.indexOf(a);){if(!isFinite(a))return a;if(!(i=t[a]))return!1;if(i.visible)return a;o.push(a),a=i.fill}return!1}function r(t){var e=t.fill,n="dataset";return!1===e?null:(isFinite(e)||(n="boundary"),d[n](t))}function l(t){return t&&!t.skip}function s(t,e,n,i,a){var r;if(i&&a){for(t.moveTo(e[0].x,e[0].y),r=1;r<i;++r)o.canvas.lineTo(t,e[r-1],e[r]);for(t.lineTo(n[a-1].x,n[a-1].y),r=a-1;r>0;--r)o.canvas.lineTo(t,n[r],n[r-1],!0)}}function u(t,e,n,i,a,o){var r,u,d,c,h,f,g,p=e.length,v=i.spanGaps,m=[],b=[],x=0,y=0;for(t.beginPath(),r=0,u=p+!!o;r<u;++r)h=n(c=e[d=r%p]._view,d,i),f=l(c),g=l(h),f&&g?(x=m.push(c),y=b.push(h)):x&&y&&(v?(f&&m.push(c),g&&b.push(h)):(s(t,m,b,x,y),x=y=0,m=[],b=[]));s(t,m,b,x,y),t.closePath(),t.fillStyle=a,t.fill()}var d={dataset:function(t){var e=t.fill,n=t.chart,i=n.getDatasetMeta(e),a=i&&n.isDatasetVisible(e)&&i.dataset._children||[],o=a.length||0;return o?function(t,e){return e<o&&a[e]._view||null}:null},boundary:function(t){var e=t.boundary,n=e?e.x:null,i=e?e.y:null;return function(t){return{x:null===n?t.x:n,y:null===i?t.y:i}}}};return{id:"filler",afterDatasetsUpdate:function(i,o){var l,s,u,d,c=(i.data.datasets||[]).length,h=o.propagate,f=[];for(s=0;s<c;++s)d=null,(u=(l=i.getDatasetMeta(s)).dataset)&&u._model&&u instanceof a.Line&&(d={visible:i.isDatasetVisible(s),fill:t(u,s,c),chart:i,el:u}),l.$filler=d,f.push(d);for(s=0;s<c;++s)(d=f[s])&&(d.fill=n(f,s,h),d.boundary=e(d),d.mapper=r(d))},beforeDatasetDraw:function(t,e){var n=e.meta.$filler;if(n){var a=t.ctx,r=n.el,l=r._view,s=r._children||[],d=n.mapper,c=l.backgroundColor||i.global.defaultColor;d&&c&&s.length&&(o.canvas.clipArea(a,t.chartArea),u(a,s,d,l,c,r._loop),o.canvas.unclipArea(a))}}}}},{25:25,40:40,45:45}],50:[function(t,e,n){"use strict";var i=t(25),a=t(26),o=t(45);i._set("global",{legend:{display:!0,position:"top",fullWidth:!0,reverse:!1,weight:1e3,onClick:function(t,e){var n=e.datasetIndex,i=this.chart,a=i.getDatasetMeta(n);a.hidden=null===a.hidden?!i.data.datasets[n].hidden:null,i.update()},onHover:null,labels:{boxWidth:40,padding:10,generateLabels:function(t){var e=t.data;return o.isArray(e.datasets)?e.datasets.map(function(e,n){return{text:e.label,fillStyle:o.isArray(e.backgroundColor)?e.backgroundColor[0]:e.backgroundColor,hidden:!t.isDatasetVisible(n),lineCap:e.borderCapStyle,lineDash:e.borderDash,lineDashOffset:e.borderDashOffset,lineJoin:e.borderJoinStyle,lineWidth:e.borderWidth,strokeStyle:e.borderColor,pointStyle:e.pointStyle,datasetIndex:n}},this):[]}}},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');for(var n=0;n<t.data.datasets.length;n++)e.push('<li><span style="background-color:'+t.data.datasets[n].backgroundColor+'"></span>'),t.data.datasets[n].label&&e.push(t.data.datasets[n].label),e.push("</li>");return e.push("</ul>"),e.join("")}}),e.exports=function(t){function e(t,e){return t.usePointStyle?e*Math.SQRT2:t.boxWidth}function n(e,n){var i=new t.Legend({ctx:e.ctx,options:n,chart:e});r.configure(e,i,n),r.addBox(e,i),e.legend=i}var r=t.layoutService,l=o.noop;return t.Legend=a.extend({initialize:function(t){o.extend(this,t),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:l,update:function(t,e,n){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=n,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:l,beforeSetDimensions:l,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:l,beforeBuildLabels:l,buildLabels:function(){var t=this,e=t.options.labels||{},n=o.callback(e.generateLabels,[t.chart],t)||[];e.filter&&(n=n.filter(function(n){return e.filter(n,t.chart.data)})),t.options.reverse&&n.reverse(),t.legendItems=n},afterBuildLabels:l,beforeFit:l,fit:function(){var t=this,n=t.options,a=n.labels,r=n.display,l=t.ctx,s=i.global,u=o.valueOrDefault,d=u(a.fontSize,s.defaultFontSize),c=u(a.fontStyle,s.defaultFontStyle),h=u(a.fontFamily,s.defaultFontFamily),f=o.fontString(d,c,h),g=t.legendHitBoxes=[],p=t.minSize,v=t.isHorizontal();if(v?(p.width=t.maxWidth,p.height=r?10:0):(p.width=r?10:0,p.height=t.maxHeight),r)if(l.font=f,v){var m=t.lineWidths=[0],b=t.legendItems.length?d+a.padding:0;l.textAlign="left",l.textBaseline="top",o.each(t.legendItems,function(n,i){var o=e(a,d)+d/2+l.measureText(n.text).width;m[m.length-1]+o+a.padding>=t.width&&(b+=d+a.padding,m[m.length]=t.left),g[i]={left:0,top:0,width:o,height:d},m[m.length-1]+=o+a.padding}),p.height+=b}else{var x=a.padding,y=t.columnWidths=[],k=a.padding,w=0,M=0,S=d+x;o.each(t.legendItems,function(t,n){var i=e(a,d)+d/2+l.measureText(t.text).width;M+S>p.height&&(k+=w+a.padding,y.push(w),w=0,M=0),w=Math.max(w,i),M+=S,g[n]={left:0,top:0,width:i,height:d}}),k+=w,y.push(w),p.width+=k}t.width=p.width,t.height=p.height},afterFit:l,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var t=this,n=t.options,a=n.labels,r=i.global,l=r.elements.line,s=t.width,u=t.lineWidths;if(n.display){var d,c=t.ctx,h=o.valueOrDefault,f=h(a.fontColor,r.defaultFontColor),g=h(a.fontSize,r.defaultFontSize),p=h(a.fontStyle,r.defaultFontStyle),v=h(a.fontFamily,r.defaultFontFamily),m=o.fontString(g,p,v);c.textAlign="left",c.textBaseline="middle",c.lineWidth=.5,c.strokeStyle=f,c.fillStyle=f,c.font=m;var b=e(a,g),x=t.legendHitBoxes,y=function(t,e,i){if(!(isNaN(b)||b<=0)){c.save(),c.fillStyle=h(i.fillStyle,r.defaultColor),c.lineCap=h(i.lineCap,l.borderCapStyle),c.lineDashOffset=h(i.lineDashOffset,l.borderDashOffset),c.lineJoin=h(i.lineJoin,l.borderJoinStyle),c.lineWidth=h(i.lineWidth,l.borderWidth),c.strokeStyle=h(i.strokeStyle,r.defaultColor);var a=0===h(i.lineWidth,l.borderWidth);if(c.setLineDash&&c.setLineDash(h(i.lineDash,l.borderDash)),n.labels&&n.labels.usePointStyle){var s=g*Math.SQRT2/2,u=s/Math.SQRT2,d=t+u,f=e+u;o.canvas.drawPoint(c,i.pointStyle,s,d,f)}else a||c.strokeRect(t,e,b,g),c.fillRect(t,e,b,g);c.restore()}},k=function(t,e,n,i){var a=g/2,o=b+a+t,r=e+a;c.fillText(n.text,o,r),n.hidden&&(c.beginPath(),c.lineWidth=2,c.moveTo(o,r),c.lineTo(o+i,r),c.stroke())},w=t.isHorizontal();d=w?{x:t.left+(s-u[0])/2,y:t.top+a.padding,line:0}:{x:t.left+a.padding,y:t.top+a.padding,line:0};var M=g+a.padding;o.each(t.legendItems,function(e,n){var i=c.measureText(e.text).width,o=b+g/2+i,r=d.x,l=d.y;w?r+o>=s&&(l=d.y+=M,d.line++,r=d.x=t.left+(s-u[d.line])/2):l+M>t.bottom&&(r=d.x=r+t.columnWidths[d.line]+a.padding,l=d.y=t.top+a.padding,d.line++),y(r,l,e),x[n].left=r,x[n].top=l,k(r,l,e,i),w?d.x+=o+a.padding:d.y+=M})}},handleEvent:function(t){var e=this,n=e.options,i="mouseup"===t.type?"click":t.type,a=!1;if("mousemove"===i){if(!n.onHover)return}else{if("click"!==i)return;if(!n.onClick)return}var o=t.x,r=t.y;if(o>=e.left&&o<=e.right&&r>=e.top&&r<=e.bottom)for(var l=e.legendHitBoxes,s=0;s<l.length;++s){var u=l[s];if(o>=u.left&&o<=u.left+u.width&&r>=u.top&&r<=u.top+u.height){if("click"===i){n.onClick.call(e,t.native,e.legendItems[s]),a=!0;break}if("mousemove"===i){n.onHover.call(e,t.native,e.legendItems[s]),a=!0;break}}}return a}}),{id:"legend",beforeInit:function(t){var e=t.options.legend;e&&n(t,e)},beforeUpdate:function(t){var e=t.options.legend,a=t.legend;e?(o.mergeIf(e,i.global.legend),a?(r.configure(t,a,e),a.options=e):n(t,e)):a&&(r.removeBox(t,a),delete t.legend)},afterEvent:function(t,e){var n=t.legend;n&&n.handleEvent(e)}}}},{25:25,26:26,45:45}],51:[function(t,e,n){"use strict";var i=t(25),a=t(26),o=t(45);i._set("global",{title:{display:!1,fontStyle:"bold",fullWidth:!0,lineHeight:1.2,padding:10,position:"top",text:"",weight:2e3}}),e.exports=function(t){function e(e,i){var a=new t.Title({ctx:e.ctx,options:i,chart:e});n.configure(e,a,i),n.addBox(e,a),e.titleBlock=a}var n=t.layoutService,r=o.noop;return t.Title=a.extend({initialize:function(t){var e=this;o.extend(e,t),e.legendHitBoxes=[]},beforeUpdate:r,update:function(t,e,n){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=n,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:r,beforeSetDimensions:r,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:r,beforeBuildLabels:r,buildLabels:r,afterBuildLabels:r,beforeFit:r,fit:function(){var t=this,e=o.valueOrDefault,n=t.options,a=n.display,r=e(n.fontSize,i.global.defaultFontSize),l=t.minSize,s=o.isArray(n.text)?n.text.length:1,u=o.options.toLineHeight(n.lineHeight,r),d=a?s*u+2*n.padding:0;t.isHorizontal()?(l.width=t.maxWidth,l.height=d):(l.width=d,l.height=t.maxHeight),t.width=l.width,t.height=l.height},afterFit:r,isHorizontal:function(){var t=this.options.position;return"top"===t||"bottom"===t},draw:function(){var t=this,e=t.ctx,n=o.valueOrDefault,a=t.options,r=i.global;if(a.display){var l,s,u,d=n(a.fontSize,r.defaultFontSize),c=n(a.fontStyle,r.defaultFontStyle),h=n(a.fontFamily,r.defaultFontFamily),f=o.fontString(d,c,h),g=o.options.toLineHeight(a.lineHeight,d),p=g/2+a.padding,v=0,m=t.top,b=t.left,x=t.bottom,y=t.right;e.fillStyle=n(a.fontColor,r.defaultFontColor),e.font=f,t.isHorizontal()?(s=b+(y-b)/2,u=m+p,l=y-b):(s="left"===a.position?b+p:y-p,u=m+(x-m)/2,l=x-m,v=Math.PI*("left"===a.position?-.5:.5)),e.save(),e.translate(s,u),e.rotate(v),e.textAlign="center",e.textBaseline="middle";var k=a.text;if(o.isArray(k))for(var w=0,M=0;M<k.length;++M)e.fillText(k[M],0,w,l),w+=g;else e.fillText(k,0,0,l);e.restore()}}}),{id:"title",beforeInit:function(t){var n=t.options.title;n&&e(t,n)},beforeUpdate:function(a){var r=a.options.title,l=a.titleBlock;r?(o.mergeIf(r,i.global.title),l?(n.configure(a,l,r),l.options=r):e(a,r)):l&&(t.layoutService.removeBox(a,l),delete a.titleBlock)}}}},{25:25,26:26,45:45}],52:[function(t,e,n){"use strict";e.exports=function(t){var e=t.Scale.extend({getLabels:function(){var t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels},determineDataLimits:function(){var t=this,e=t.getLabels();t.minIndex=0,t.maxIndex=e.length-1;var n;void 0!==t.options.ticks.min&&(n=e.indexOf(t.options.ticks.min),t.minIndex=-1!==n?n:t.minIndex),void 0!==t.options.ticks.max&&(n=e.indexOf(t.options.ticks.max),t.maxIndex=-1!==n?n:t.maxIndex),t.min=e[t.minIndex],t.max=e[t.maxIndex]},buildTicks:function(){var t=this,e=t.getLabels();t.ticks=0===t.minIndex&&t.maxIndex===e.length-1?e:e.slice(t.minIndex,t.maxIndex+1)},getLabelForIndex:function(t,e){var n=this,i=n.chart.data,a=n.isHorizontal();return i.yLabels&&!a?n.getRightValue(i.datasets[e].data[t]):n.ticks[t-n.minIndex]},getPixelForValue:function(t,e){var n,i=this,a=i.options.offset,o=Math.max(i.maxIndex+1-i.minIndex-(a?0:1),1);if(void 0!==t&&null!==t&&(n=i.isHorizontal()?t.x:t.y),void 0!==n||void 0!==t&&isNaN(e)){var r=i.getLabels();t=n||t;var l=r.indexOf(t);e=-1!==l?l:e}if(i.isHorizontal()){var s=i.width/o,u=s*(e-i.minIndex);return a&&(u+=s/2),i.left+Math.round(u)}var d=i.height/o,c=d*(e-i.minIndex);return a&&(c+=d/2),i.top+Math.round(c)},getPixelForTick:function(t){return this.getPixelForValue(this.ticks[t],t+this.minIndex,null)},getValueForPixel:function(t){var e=this,n=e.options.offset,i=Math.max(e._ticks.length-(n?0:1),1),a=e.isHorizontal(),o=(a?e.width:e.height)/i;return t-=a?e.left:e.top,n&&(t-=o/2),(t<=0?0:Math.round(t/o))+e.minIndex},getBasePixel:function(){return this.bottom}});t.scaleService.registerScaleType("category",e,{position:"bottom"})}},{}],53:[function(t,e,n){"use strict";var i=t(25),a=t(45),o=t(34);e.exports=function(t){var e={position:"left",ticks:{callback:o.formatters.linear}},n=t.LinearScaleBase.extend({determineDataLimits:function(){function t(t){return r?t.xAxisID===e.id:t.yAxisID===e.id}var e=this,n=e.options,i=e.chart,o=i.data.datasets,r=e.isHorizontal();e.min=null,e.max=null;var l=n.stacked;if(void 0===l&&a.each(o,function(e,n){if(!l){var a=i.getDatasetMeta(n);i.isDatasetVisible(n)&&t(a)&&void 0!==a.stack&&(l=!0)}}),n.stacked||l){var s={};a.each(o,function(o,r){var l=i.getDatasetMeta(r),u=[l.type,void 0===n.stacked&&void 0===l.stack?r:"",l.stack].join(".");void 0===s[u]&&(s[u]={positiveValues:[],negativeValues:[]});var d=s[u].positiveValues,c=s[u].negativeValues;i.isDatasetVisible(r)&&t(l)&&a.each(o.data,function(t,i){var a=+e.getRightValue(t);isNaN(a)||l.data[i].hidden||(d[i]=d[i]||0,c[i]=c[i]||0,n.relativePoints?d[i]=100:a<0?c[i]+=a:d[i]+=a)})}),a.each(s,function(t){var n=t.positiveValues.concat(t.negativeValues),i=a.min(n),o=a.max(n);e.min=null===e.min?i:Math.min(e.min,i),e.max=null===e.max?o:Math.max(e.max,o)})}else a.each(o,function(n,o){var r=i.getDatasetMeta(o);i.isDatasetVisible(o)&&t(r)&&a.each(n.data,function(t,n){var i=+e.getRightValue(t);isNaN(i)||r.data[n].hidden||(null===e.min?e.min=i:i<e.min&&(e.min=i),null===e.max?e.max=i:i>e.max&&(e.max=i))})});e.min=isFinite(e.min)&&!isNaN(e.min)?e.min:0,e.max=isFinite(e.max)&&!isNaN(e.max)?e.max:1,this.handleTickRangeOptions()},getTickLimit:function(){var t,e=this,n=e.options.ticks;if(e.isHorizontal())t=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(e.width/50));else{var o=a.valueOrDefault(n.fontSize,i.global.defaultFontSize);t=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(e.height/(2*o)))}return t},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t){var e,n=this,i=n.start,a=+n.getRightValue(t),o=n.end-i;return n.isHorizontal()?(e=n.left+n.width/o*(a-i),Math.round(e)):(e=n.bottom-n.height/o*(a-i),Math.round(e))},getValueForPixel:function(t){var e=this,n=e.isHorizontal(),i=n?e.width:e.height,a=(n?t-e.left:e.bottom-t)/i;return e.start+(e.end-e.start)*a},getPixelForTick:function(t){return this.getPixelForValue(this.ticksAsNumbers[t])}});t.scaleService.registerScaleType("linear",n,e)}},{25:25,34:34,45:45}],54:[function(t,e,n){"use strict";var i=t(45),a=t(34);e.exports=function(t){var e=i.noop;t.LinearScaleBase=t.Scale.extend({getRightValue:function(e){return"string"==typeof e?+e:t.Scale.prototype.getRightValue.call(this,e)},handleTickRangeOptions:function(){var t=this,e=t.options.ticks;if(e.beginAtZero){var n=i.sign(t.min),a=i.sign(t.max);n<0&&a<0?t.max=0:n>0&&a>0&&(t.min=0)}var o=void 0!==e.min||void 0!==e.suggestedMin,r=void 0!==e.max||void 0!==e.suggestedMax;void 0!==e.min?t.min=e.min:void 0!==e.suggestedMin&&(null===t.min?t.min=e.suggestedMin:t.min=Math.min(t.min,e.suggestedMin)),void 0!==e.max?t.max=e.max:void 0!==e.suggestedMax&&(null===t.max?t.max=e.suggestedMax:t.max=Math.max(t.max,e.suggestedMax)),o!==r&&t.min>=t.max&&(o?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)},getTickLimit:e,handleDirectionalChanges:e,buildTicks:function(){var t=this,e=t.options.ticks,n=t.getTickLimit(),o={maxTicks:n=Math.max(2,n),min:e.min,max:e.max,stepSize:i.valueOrDefault(e.fixedStepSize,e.stepSize)},r=t.ticks=a.generators.linear(o,t);t.handleDirectionalChanges(),t.max=i.max(r),t.min=i.min(r),e.reverse?(r.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max)},convertTicksToLabels:function(){var e=this;e.ticksAsNumbers=e.ticks.slice(),e.zeroLineIndex=e.ticks.indexOf(0),t.Scale.prototype.convertTicksToLabels.call(e)}})}},{34:34,45:45}],55:[function(t,e,n){"use strict";var i=t(45),a=t(34);e.exports=function(t){var e={position:"left",ticks:{callback:a.formatters.logarithmic}},n=t.Scale.extend({determineDataLimits:function(){function t(t){return s?t.xAxisID===e.id:t.yAxisID===e.id}var e=this,n=e.options,a=n.ticks,o=e.chart,r=o.data.datasets,l=i.valueOrDefault,s=e.isHorizontal();e.min=null,e.max=null,e.minNotZero=null;var u=n.stacked;if(void 0===u&&i.each(r,function(e,n){if(!u){var i=o.getDatasetMeta(n);o.isDatasetVisible(n)&&t(i)&&void 0!==i.stack&&(u=!0)}}),n.stacked||u){var d={};i.each(r,function(a,r){var l=o.getDatasetMeta(r),s=[l.type,void 0===n.stacked&&void 0===l.stack?r:"",l.stack].join(".");o.isDatasetVisible(r)&&t(l)&&(void 0===d[s]&&(d[s]=[]),i.each(a.data,function(t,i){var a=d[s],o=+e.getRightValue(t);isNaN(o)||l.data[i].hidden||(a[i]=a[i]||0,n.relativePoints?a[i]=100:a[i]+=o)}))}),i.each(d,function(t){var n=i.min(t),a=i.max(t);e.min=null===e.min?n:Math.min(e.min,n),e.max=null===e.max?a:Math.max(e.max,a)})}else i.each(r,function(n,a){var r=o.getDatasetMeta(a);o.isDatasetVisible(a)&&t(r)&&i.each(n.data,function(t,n){var i=+e.getRightValue(t);isNaN(i)||r.data[n].hidden||(null===e.min?e.min=i:i<e.min&&(e.min=i),null===e.max?e.max=i:i>e.max&&(e.max=i),0!==i&&(null===e.minNotZero||i<e.minNotZero)&&(e.minNotZero=i))})});e.min=l(a.min,e.min),e.max=l(a.max,e.max),e.min===e.max&&(0!==e.min&&null!==e.min?(e.min=Math.pow(10,Math.floor(i.log10(e.min))-1),e.max=Math.pow(10,Math.floor(i.log10(e.max))+1)):(e.min=1,e.max=10))},buildTicks:function(){var t=this,e=t.options.ticks,n={min:e.min,max:e.max},o=t.ticks=a.generators.logarithmic(n,t);t.isHorizontal()||o.reverse(),t.max=i.max(o),t.min=i.min(o),e.reverse?(o.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max)},convertTicksToLabels:function(){this.tickValues=this.ticks.slice(),t.Scale.prototype.convertTicksToLabels.call(this)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForTick:function(t){return this.getPixelForValue(this.tickValues[t])},getPixelForValue:function(t){var e,n,a,o=this,r=o.start,l=+o.getRightValue(t),s=o.options.ticks;return o.isHorizontal()?(a=i.log10(o.end)-i.log10(r),0===l?n=o.left:(e=o.width,n=o.left+e/a*(i.log10(l)-i.log10(r)))):(e=o.height,0!==r||s.reverse?0===o.end&&s.reverse?(a=i.log10(o.start)-i.log10(o.minNotZero),n=l===o.end?o.top:l===o.minNotZero?o.top+.02*e:o.top+.02*e+.98*e/a*(i.log10(l)-i.log10(o.minNotZero))):0===l?n=s.reverse?o.top:o.bottom:(a=i.log10(o.end)-i.log10(r),e=o.height,n=o.bottom-e/a*(i.log10(l)-i.log10(r))):(a=i.log10(o.end)-i.log10(o.minNotZero),n=l===r?o.bottom:l===o.minNotZero?o.bottom-.02*e:o.bottom-.02*e-.98*e/a*(i.log10(l)-i.log10(o.minNotZero)))),n},getValueForPixel:function(t){var e,n,a=this,o=i.log10(a.end)-i.log10(a.start);return a.isHorizontal()?(n=a.width,e=a.start*Math.pow(10,(t-a.left)*o/n)):(n=a.height,e=Math.pow(10,(a.bottom-t)*o/n)/a.start),e}});t.scaleService.registerScaleType("logarithmic",n,e)}},{34:34,45:45}],56:[function(t,e,n){"use strict";var i=t(25),a=t(45),o=t(34);e.exports=function(t){function e(t){var e=t.options;return e.angleLines.display||e.pointLabels.display?t.chart.data.labels.length:0}function n(t){var e=t.options.pointLabels,n=a.valueOrDefault(e.fontSize,v.defaultFontSize),i=a.valueOrDefault(e.fontStyle,v.defaultFontStyle),o=a.valueOrDefault(e.fontFamily,v.defaultFontFamily);return{size:n,style:i,family:o,font:a.fontString(n,i,o)}}function r(t,e,n){return a.isArray(n)?{w:a.longestText(t,t.font,n),h:n.length*e+1.5*(n.length-1)*e}:{w:t.measureText(n).width,h:e}}function l(t,e,n,i,a){return t===i||t===a?{start:e-n/2,end:e+n/2}:t<i||t>a?{start:e-n-5,end:e}:{start:e,end:e+n+5}}function s(t){var i,o,s,u=n(t),d=Math.min(t.height/2,t.width/2),c={r:t.width,l:0,t:t.height,b:0},h={};t.ctx.font=u.font,t._pointLabelSizes=[];var f=e(t);for(i=0;i<f;i++){s=t.getPointPosition(i,d),o=r(t.ctx,u.size,t.pointLabels[i]||""),t._pointLabelSizes[i]=o;var g=t.getIndexAngle(i),p=a.toDegrees(g)%360,v=l(p,s.x,o.w,0,180),m=l(p,s.y,o.h,90,270);v.start<c.l&&(c.l=v.start,h.l=g),v.end>c.r&&(c.r=v.end,h.r=g),m.start<c.t&&(c.t=m.start,h.t=g),m.end>c.b&&(c.b=m.end,h.b=g)}t.setReductions(d,c,h)}function u(t){var e=Math.min(t.height/2,t.width/2);t.drawingArea=Math.round(e),t.setCenterPoint(0,0,0,0)}function d(t){return 0===t||180===t?"center":t<180?"left":"right"}function c(t,e,n,i){if(a.isArray(e))for(var o=n.y,r=1.5*i,l=0;l<e.length;++l)t.fillText(e[l],n.x,o),o+=r;else t.fillText(e,n.x,n.y)}function h(t,e,n){90===t||270===t?n.y-=e.h/2:(t>270||t<90)&&(n.y-=e.h)}function f(t){var i=t.ctx,o=a.valueOrDefault,r=t.options,l=r.angleLines,s=r.pointLabels;i.lineWidth=l.lineWidth,i.strokeStyle=l.color;var u=t.getDistanceFromCenterForValue(r.ticks.reverse?t.min:t.max),f=n(t);i.textBaseline="top";for(var g=e(t)-1;g>=0;g--){if(l.display){var p=t.getPointPosition(g,u);i.beginPath(),i.moveTo(t.xCenter,t.yCenter),i.lineTo(p.x,p.y),i.stroke(),i.closePath()}if(s.display){var m=t.getPointPosition(g,u+5),b=o(s.fontColor,v.defaultFontColor);i.font=f.font,i.fillStyle=b;var x=t.getIndexAngle(g),y=a.toDegrees(x);i.textAlign=d(y),h(y,t._pointLabelSizes[g],m),c(i,t.pointLabels[g]||"",m,f.size)}}}function g(t,n,i,o){var r=t.ctx;if(r.strokeStyle=a.valueAtIndexOrDefault(n.color,o-1),r.lineWidth=a.valueAtIndexOrDefault(n.lineWidth,o-1),t.options.gridLines.circular)r.beginPath(),r.arc(t.xCenter,t.yCenter,i,0,2*Math.PI),r.closePath(),r.stroke();else{var l=e(t);if(0===l)return;r.beginPath();var s=t.getPointPosition(0,i);r.moveTo(s.x,s.y);for(var u=1;u<l;u++)s=t.getPointPosition(u,i),r.lineTo(s.x,s.y);r.closePath(),r.stroke()}}function p(t){return a.isNumber(t)?t:0}var v=i.global,m={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},gridLines:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:o.formatters.linear},pointLabels:{display:!0,fontSize:10,callback:function(t){return t}}},b=t.LinearScaleBase.extend({setDimensions:function(){var t=this,e=t.options,n=e.ticks;t.width=t.maxWidth,t.height=t.maxHeight,t.xCenter=Math.round(t.width/2),t.yCenter=Math.round(t.height/2);var i=a.min([t.height,t.width]),o=a.valueOrDefault(n.fontSize,v.defaultFontSize);t.drawingArea=e.display?i/2-(o/2+n.backdropPaddingY):i/2},determineDataLimits:function(){var t=this,e=t.chart,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;a.each(e.data.datasets,function(o,r){if(e.isDatasetVisible(r)){var l=e.getDatasetMeta(r);a.each(o.data,function(e,a){var o=+t.getRightValue(e);isNaN(o)||l.data[a].hidden||(n=Math.min(o,n),i=Math.max(o,i))})}}),t.min=n===Number.POSITIVE_INFINITY?0:n,t.max=i===Number.NEGATIVE_INFINITY?0:i,t.handleTickRangeOptions()},getTickLimit:function(){var t=this.options.ticks,e=a.valueOrDefault(t.fontSize,v.defaultFontSize);return Math.min(t.maxTicksLimit?t.maxTicksLimit:11,Math.ceil(this.drawingArea/(1.5*e)))},convertTicksToLabels:function(){var e=this;t.LinearScaleBase.prototype.convertTicksToLabels.call(e),e.pointLabels=e.chart.data.labels.map(e.options.pointLabels.callback,e)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},fit:function(){this.options.pointLabels.display?s(this):u(this)},setReductions:function(t,e,n){var i=this,a=e.l/Math.sin(n.l),o=Math.max(e.r-i.width,0)/Math.sin(n.r),r=-e.t/Math.cos(n.t),l=-Math.max(e.b-i.height,0)/Math.cos(n.b);a=p(a),o=p(o),r=p(r),l=p(l),i.drawingArea=Math.min(Math.round(t-(a+o)/2),Math.round(t-(r+l)/2)),i.setCenterPoint(a,o,r,l)},setCenterPoint:function(t,e,n,i){var a=this,o=a.width-e-a.drawingArea,r=t+a.drawingArea,l=n+a.drawingArea,s=a.height-i-a.drawingArea;a.xCenter=Math.round((r+o)/2+a.left),a.yCenter=Math.round((l+s)/2+a.top)},getIndexAngle:function(t){return t*(2*Math.PI/e(this))+(this.chart.options&&this.chart.options.startAngle?this.chart.options.startAngle:0)*Math.PI*2/360},getDistanceFromCenterForValue:function(t){var e=this;if(null===t)return 0;var n=e.drawingArea/(e.max-e.min);return e.options.ticks.reverse?(e.max-t)*n:(t-e.min)*n},getPointPosition:function(t,e){var n=this,i=n.getIndexAngle(t)-Math.PI/2;return{x:Math.round(Math.cos(i)*e)+n.xCenter,y:Math.round(Math.sin(i)*e)+n.yCenter}},getPointPositionForValue:function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))},getBasePosition:function(){var t=this,e=t.min,n=t.max;return t.getPointPositionForValue(0,t.beginAtZero?0:e<0&&n<0?n:e>0&&n>0?e:0)},draw:function(){var t=this,e=t.options,n=e.gridLines,i=e.ticks,o=a.valueOrDefault;if(e.display){var r=t.ctx,l=this.getIndexAngle(0),s=o(i.fontSize,v.defaultFontSize),u=o(i.fontStyle,v.defaultFontStyle),d=o(i.fontFamily,v.defaultFontFamily),c=a.fontString(s,u,d);a.each(t.ticks,function(e,a){if(a>0||i.reverse){var u=t.getDistanceFromCenterForValue(t.ticksAsNumbers[a]);if(n.display&&0!==a&&g(t,n,u,a),i.display){var d=o(i.fontColor,v.defaultFontColor);if(r.font=c,r.save(),r.translate(t.xCenter,t.yCenter),r.rotate(l),i.showLabelBackdrop){var h=r.measureText(e).width;r.fillStyle=i.backdropColor,r.fillRect(-h/2-i.backdropPaddingX,-u-s/2-i.backdropPaddingY,h+2*i.backdropPaddingX,s+2*i.backdropPaddingY)}r.textAlign="center",r.textBaseline="middle",r.fillStyle=d,r.fillText(e,0,-u),r.restore()}}}),(e.angleLines.display||e.pointLabels.display)&&f(t)}}});t.scaleService.registerScaleType("radialLinear",b,m)}},{25:25,34:34,45:45}],57:[function(t,e,n){"use strict";function i(t,e){return t-e}function a(t){var e,n,i,a={},o=[];for(e=0,n=t.length;e<n;++e)a[i=t[e]]||(a[i]=!0,o.push(i));return o}function o(t,e,n,i){if("linear"===i||!t.length)return[{time:e,pos:0},{time:n,pos:1}];var a,o,r,l,s,u=[],d=[e];for(a=0,o=t.length;a<o;++a)(l=t[a])>e&&l<n&&d.push(l);for(d.push(n),a=0,o=d.length;a<o;++a)s=d[a+1],r=d[a-1],l=d[a],void 0!==r&&void 0!==s&&Math.round((s+r)/2)===l||u.push({time:l,pos:a/(o-1)});return u}function r(t,e,n){for(var i,a,o,r=0,l=t.length-1;r>=0&&r<=l;){if(i=r+l>>1,a=t[i-1]||null,o=t[i],!a)return{lo:null,hi:o};if(o[e]<n)r=i+1;else{if(!(a[e]>n))return{lo:a,hi:o};l=i-1}}return{lo:o,hi:null}}function l(t,e,n,i){var a=r(t,e,n),o=a.lo?a.hi?a.lo:t[t.length-2]:t[0],l=a.lo?a.hi?a.hi:t[t.length-1]:t[1],s=l[e]-o[e],u=s?(n-o[e])/s:0,d=(l[i]-o[i])*u;return o[i]+d}function s(t,e){var n=e.parser,i=e.parser||e.format;return"function"==typeof n?n(t):"string"==typeof t&&"string"==typeof i?m(t,i):(t instanceof m||(t=m(t)),t.isValid()?t:"function"==typeof i?i(t):t)}function u(t,e){if(x.isNullOrUndef(t))return null;var n=e.options.time,i=s(e.getRightValue(t),n);return i.isValid()?(n.round&&i.startOf(n.round),i.valueOf()):null}function d(t,e,n,i){var a,o,r,l=e-t,s=w[n],u=s.size,d=s.steps;if(!d)return Math.ceil(l/((i||1)*u));for(a=0,o=d.length;a<o&&(r=d[a],!(Math.ceil(l/(u*r))<=i));++a);return r}function c(t,e,n,i){var a,o,r,l=M.length;for(a=M.indexOf(t);a<l-1;++a)if(o=w[M[a]],r=o.steps?o.steps[o.steps.length-1]:k,o.common&&Math.ceil((n-e)/(r*o.size))<=i)return M[a];return M[l-1]}function h(t,e,n,i){var a,o,r=m.duration(m(i).diff(m(n)));for(a=M.length-1;a>=M.indexOf(e);a--)if(o=M[a],w[o].common&&r.as(o)>=t.length)return o;return M[e?M.indexOf(e):0]}function f(t){for(var e=M.indexOf(t)+1,n=M.length;e<n;++e)if(w[M[e]].common)return M[e]}function g(t,e,n,i){var a,o=i.time,r=o.unit||c(o.minUnit,t,e,n),l=f(r),s=x.valueOrDefault(o.stepSize,o.unitStepSize),u="week"===r&&o.isoWeekday,h=i.ticks.major.enabled,g=w[r],p=m(t),v=m(e),b=[];for(s||(s=d(t,e,r,n)),u&&(p=p.isoWeekday(u),v=v.isoWeekday(u)),p=p.startOf(u?"day":r),(v=v.startOf(u?"day":r))<e&&v.add(1,r),a=m(p),h&&l&&!u&&!o.round&&(a.startOf(l),a.add(~~((p-a)/(g.size*s))*s,r));a<v;a.add(s,r))b.push(+a);return b.push(+a),b}function p(t,e,n,i,a){var o,r,s=0,u=0;return a.offset&&e.length&&(a.time.min||(o=e.length>1?e[1]:i,r=e[0],s=(l(t,"time",o,"pos")-l(t,"time",r,"pos"))/2),a.time.max||(o=e[e.length-1],r=e.length>1?e[e.length-2]:n,u=(l(t,"time",o,"pos")-l(t,"time",r,"pos"))/2)),{left:s,right:u}}function v(t,e){var n,i,a,o,r=[];for(n=0,i=t.length;n<i;++n)a=t[n],o=!!e&&a===+m(a).startOf(e),r.push({value:a,major:o});return r}var m=t(1);m="function"==typeof m?m:window.moment;var b=t(25),x=t(45),y=Number.MIN_SAFE_INTEGER||-9007199254740991,k=Number.MAX_SAFE_INTEGER||9007199254740991,w={millisecond:{common:!0,size:1,steps:[1,2,5,10,20,50,100,250,500]},second:{common:!0,size:1e3,steps:[1,2,5,10,30]},minute:{common:!0,size:6e4,steps:[1,2,5,10,30]},hour:{common:!0,size:36e5,steps:[1,2,3,6,12]},day:{common:!0,size:864e5,steps:[1,2,5]},week:{common:!1,size:6048e5,steps:[1,2,3,4]},month:{common:!0,size:2628e6,steps:[1,2,3]},quarter:{common:!1,size:7884e6,steps:[1,2,3,4]},year:{common:!0,size:3154e7}},M=Object.keys(w);e.exports=function(t){var e=t.Scale.extend({initialize:function(){if(!m)throw new Error("Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com");this.mergeTicksOptions(),t.Scale.prototype.initialize.call(this)},update:function(){var e=this,n=e.options;return n.time&&n.time.format&&console.warn("options.time.format is deprecated and replaced by options.time.parser."),t.Scale.prototype.update.apply(e,arguments)},getRightValue:function(e){return e&&void 0!==e.t&&(e=e.t),t.Scale.prototype.getRightValue.call(this,e)},determineDataLimits:function(){var t,e,n,o,r,l,s=this,d=s.chart,c=s.options.time,h=k,f=y,g=[],p=[],v=[];for(t=0,n=d.data.labels.length;t<n;++t)v.push(u(d.data.labels[t],s));for(t=0,n=(d.data.datasets||[]).length;t<n;++t)if(d.isDatasetVisible(t))if(r=d.data.datasets[t].data,x.isObject(r[0]))for(p[t]=[],e=0,o=r.length;e<o;++e)l=u(r[e],s),g.push(l),p[t][e]=l;else g.push.apply(g,v),p[t]=v.slice(0);else p[t]=[];v.length&&(v=a(v).sort(i),h=Math.min(h,v[0]),f=Math.max(f,v[v.length-1])),g.length&&(g=a(g).sort(i),h=Math.min(h,g[0]),f=Math.max(f,g[g.length-1])),h=u(c.min,s)||h,f=u(c.max,s)||f,h=h===k?+m().startOf("day"):h,f=f===y?+m().endOf("day")+1:f,s.min=Math.min(h,f),s.max=Math.max(h+1,f),s._horizontal=s.isHorizontal(),s._table=[],s._timestamps={data:g,datasets:p,labels:v}},buildTicks:function(){var t,e,n,i=this,a=i.min,r=i.max,l=i.options,s=l.time,d=[],c=[];switch(l.ticks.source){case"data":d=i._timestamps.data;break;case"labels":d=i._timestamps.labels;break;case"auto":default:d=g(a,r,i.getLabelCapacity(a),l)}for("ticks"===l.bounds&&d.length&&(a=d[0],r=d[d.length-1]),a=u(s.min,i)||a,r=u(s.max,i)||r,t=0,e=d.length;t<e;++t)(n=d[t])>=a&&n<=r&&c.push(n);return i.min=a,i.max=r,i._unit=s.unit||h(c,s.minUnit,i.min,i.max),i._majorUnit=f(i._unit),i._table=o(i._timestamps.data,a,r,l.distribution),i._offsets=p(i._table,c,a,r,l),v(c,i._majorUnit)},getLabelForIndex:function(t,e){var n=this,i=n.chart.data,a=n.options.time,o=i.labels&&t<i.labels.length?i.labels[t]:"",r=i.datasets[e].data[t];return x.isObject(r)&&(o=n.getRightValue(r)),a.tooltipFormat&&(o=s(o,a).format(a.tooltipFormat)),o},tickFormatFunction:function(t,e,n,i){var a=this,o=a.options,r=t.valueOf(),l=o.time.displayFormats,s=l[a._unit],u=a._majorUnit,d=l[u],c=t.clone().startOf(u).valueOf(),h=o.ticks.major,f=h.enabled&&u&&d&&r===c,g=t.format(i||(f?d:s)),p=f?h:o.ticks.minor,v=x.valueOrDefault(p.callback,p.userCallback);return v?v(g,e,n):g},convertTicksToLabels:function(t){var e,n,i=[];for(e=0,n=t.length;e<n;++e)i.push(this.tickFormatFunction(m(t[e].value),e,t));return i},getPixelForOffset:function(t){var e=this,n=e._horizontal?e.width:e.height,i=e._horizontal?e.left:e.top,a=l(e._table,"time",t,"pos");return i+n*(e._offsets.left+a)/(e._offsets.left+1+e._offsets.right)},getPixelForValue:function(t,e,n){var i=this,a=null;if(void 0!==e&&void 0!==n&&(a=i._timestamps.datasets[n][e]),null===a&&(a=u(t,i)),null!==a)return i.getPixelForOffset(a)},getPixelForTick:function(t){var e=this.getTicks();return t>=0&&t<e.length?this.getPixelForOffset(e[t].value):null},getValueForPixel:function(t){var e=this,n=e._horizontal?e.width:e.height,i=e._horizontal?e.left:e.top,a=(n?(t-i)/n:0)*(e._offsets.left+1+e._offsets.left)-e._offsets.right,o=l(e._table,"pos",a,"time");return m(o)},getLabelWidth:function(t){var e=this,n=e.options.ticks,i=e.ctx.measureText(t).width,a=x.toRadians(n.maxRotation),o=Math.cos(a),r=Math.sin(a);return i*o+x.valueOrDefault(n.fontSize,b.global.defaultFontSize)*r},getLabelCapacity:function(t){var e=this,n=e.options.time.displayFormats.millisecond,i=e.tickFormatFunction(m(t),0,[],n),a=e.getLabelWidth(i),o=e.isHorizontal()?e.width:e.height;return Math.floor(o/a)}});t.scaleService.registerScaleType("time",e,{position:"bottom",distribution:"linear",bounds:"data",time:{parser:!1,format:!1,unit:!1,round:!1,displayFormat:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm a",hour:"hA",day:"MMM D",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"}},ticks:{autoSkip:!1,source:"auto",major:{enabled:!1}}})}},{1:1,25:25,45:45}]},{},[7])(7)}); \ No newline at end of file
diff --git a/main/survey/js/ChartJS/chart_init.js b/main/survey/js/ChartJS/chart_init.js
new file mode 100644
index 0000000..3f96134
--- /dev/null
+++ b/main/survey/js/ChartJS/chart_init.js
@@ -0,0 +1,260 @@
+
+// Funkcija za graf pri kvizu
+function init_quiz_results_chart(all, correct, incorrect, correct_title, incorrect_title){
+
+ var horizontalBarChartData = {
+ datasets: [{
+ label: correct_title,
+ backgroundColor: "rgba(102, 194, 74, 0.8)",
+ borderColor: "rgba(102, 194, 74, 0.8)",
+ borderWidth: 1,
+ data: [correct]
+ }, {
+ label: incorrect_title,
+ backgroundColor: "rgba(220, 0, 0, 0.7)",
+ borderColor: "rgba(220, 0, 0, 0.7)",
+ data: [incorrect]
+ }]
+
+ };
+
+ // Define a plugin to provide data labels
+ Chart.plugins.register({
+ afterDatasetsDraw: function(chart, easing) {
+ // To only draw at the end of animation, check for easing === 1
+ var ctx = chart.ctx;
+
+ chart.data.datasets.forEach(function (dataset, i) {
+ var meta = chart.getDatasetMeta(i);
+ if (!meta.hidden) {
+ meta.data.forEach(function(element, index) {
+ // Draw the text in black, with the specified font
+ ctx.fillStyle = 'rgb(0, 0, 0)';
+
+ var fontSize = 15;
+ var fontStyle = 'bold';
+ var fontFamily = 'Arial';
+ ctx.font = Chart.helpers.fontString(fontSize, fontStyle, fontFamily);
+
+ // Just naively convert to string for now
+ var dataString = dataset.data[index].toString() + ' (' + Math.round((dataset.data[index] / all * 1000) / 10) + '%)';
+
+ // Make sure alignment settings are correct
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+
+ var padding = 0;
+ var position = element.tooltipPosition();
+
+ var x_pos = position.x / 2;
+ if(x_pos < 10)
+ x_pos = 45;
+ var y_pos = position.y - (fontSize / 2) - padding + 10;
+
+ ctx.fillText(dataString, x_pos, y_pos);
+ });
+ }
+ });
+ }
+ });
+
+ var ctx = document.getElementById("quiz_results_chart").getContext("2d");
+ window.myHorizontalBar = new Chart(ctx, {
+ type: 'horizontalBar',
+ data: horizontalBarChartData,
+ options: {
+ elements: {
+ rectangle: {
+ borderWidth: 1,
+ }
+ },
+ responsive: true,
+ maintainAspectRatio: false,
+ scales: {
+ xAxes: [{
+ ticks: {
+ //display: false,
+ padding: 5,
+ min: 0,
+ max: all,
+ stepSize: 1,
+ mirror: true
+ }
+ }]
+ },
+ legend: {
+ display: false
+ }
+ }
+ });
+}
+
+// Funkcija za poseben modul excelleration matrix
+function init_excell_matrix(x_axis, y_axis, rad){
+
+ // Radius prilagodimo ce je prevelik/premajhen
+ var radius = rad / 12.5;
+ if(radius > 80)
+ radius = 80;
+ if(radius < 8)
+ radius = 8;
+
+ // Inicializiramo graf
+ var ctx = document.getElementById("excell_matrix_chart");
+
+ // Nastavimo podatke
+ var popData = {
+ datasets: [{
+ label: ['Blagovna znamka'],
+ data: [{
+ x: x_axis,
+ y: y_axis,
+ r: radius
+ }],
+ backgroundColor: "rgba(220, 0, 0, 0.7)",
+ hoverBackgroundColor: "rgba(220, 0, 0, 0.8)",
+ }]
+ };
+
+ var myChart = new Chart(ctx, {
+ type: 'bubble',
+ data: popData,
+ options: {
+ tooltips: {
+ custom: function(tooltip) {
+ if (!tooltip) return;
+ // disable displaying the color box;
+ tooltip.displayColors = false;
+ },
+ callbacks: {
+ label: function(t, d) {
+ //var multistringText = ['Blagovna znamka:'];
+ //multistringText.push(' Excelleration: ' + x_axis);
+ var multistringText = ['Odličnost: ' + x_axis];
+ multistringText.push('Marža: ' + y_axis);
+ multistringText.push('Letni promet: ' + rad);
+
+ return multistringText;
+ /*/return 'Blagovna znamka:<br > ' + x_axis + ', ' + y_axis + ', ' + rad;*/
+ /*return d.datasets[t.datasetIndex].label +
+ ': (Day:' + t.xLabel + ', Total:' + t.rLabel + ')';*/
+ }
+ }
+ },
+ scales: {
+ yAxes: [{
+ ticks: {
+ display: false,
+ padding: 5,
+ min: 0,
+ max: 6,
+ stepSize: 0.5,
+ /*min: 0,
+ max: 6,*/
+ callback: function(value, index, values) {
+ if(value == 3)
+ return value;
+ else
+ return;
+ }
+ },
+ scaleLabel: {
+ display: true,
+ labelString: 'Odličnost blagovne znamke',
+ fontStyle: 'bold',
+ fontSize: '14',
+
+ },
+ gridLines: {
+ color: "rgba(10, 10, 10, 1)",
+ drawBorder: false
+ },
+ position: 'right'
+ }],
+ xAxes: [{
+ ticks: {
+ display: false,
+ padding: 5,
+ min: 0,
+ max: 6,
+ stepSize: 0.5,
+ /*min: 0,
+ max: 6,*/
+ callback: function(value, index, values) {
+ if(value == 3)
+ return value;
+ else
+ return;
+ }
+ },
+ scaleLabel: {
+ display: true,
+ labelString: 'Marža blagovne znamke',
+ fontStyle: 'bold',
+ fontSize: '14'
+ },
+ gridLines: {
+ color: "rgba(10, 10, 10, 1)",
+ drawBorder: false
+ },
+ position: 'top'
+ }]
+ },
+ legend: {
+ display: false
+ },
+ layout: {
+ padding: {
+ left: 20,
+ right: 40,
+ top: 30,
+ bottom: 30
+ }
+ }
+ }
+ });
+}
+
+// Funkcija za poseben modul radar chart - skavti
+function init_skavti_radar(labels, pohvale, izzivi){
+
+ // Inicializiramo graf
+ var ctx = document.getElementById("skavti_radar_chart");
+
+ // Podatki grafa
+ var data = {
+ labels: labels,
+ datasets: [{
+ data: pohvale,
+ label: "Pohvale",
+ backgroundColor: "rgba(30,136,229,0.6)"
+ },
+ {
+ data: izzivi,
+ label: "Izzivi",
+ backgroundColor: "rgba(200,0,0,0.5)"
+ }]
+ };
+
+ // Nastavitve grafa
+ var options = {
+ scale: {
+ angleLines: {
+ display: false
+ },
+ ticks: {
+ max: 10,
+ min: 0,
+ stepSize: 1
+ },
+ }
+ };
+
+ /*Chart.defaults.global.defaultFontSize = 15;*/
+
+ var radarChart = new Chart(ctx, {
+ type: 'radar',
+ data: data,
+ options: options
+ });
+}
diff --git a/main/survey/js/DragDrop/dragdrop.js b/main/survey/js/DragDrop/dragdrop.js
new file mode 100644
index 0000000..d379c7f
--- /dev/null
+++ b/main/survey/js/DragDrop/dragdrop.js
@@ -0,0 +1,1550 @@
+//var refresh = 0;
+var refresh = [];
+var skatlastOkvir = [];
+
+//************funkcija, ki skrbi za inicializacijo draggable elementov in delovanje drag and drop ob dvojnem kliku
+function Draggable(tip, spremenljivka, vre_id, ajax, anketa, site_url, usr_id, other, mobile){
+ var top_cat = -1;
+ var left_cat = -1;
+ if (mobile == 0 || mobile == 2){
+ top_cat = -6;
+ left_cat = -6;
+ }
+
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).addClass('drag_and_drop').detach().appendTo('#half_frame_dropping_'+spremenljivka) //zeleni element s kategorijami dodaj v zacetnem kontejnerju
+ .draggable({ //ureditev, da je element draggable
+ cursor: 'move',
+ //revert: true,
+ revert: function(socketObj)
+ {
+ checkBranching();
+ //if false then no socket object drop occurred, reverting happens
+ if(socketObj === false){
+ //ce je tip kategorije en odgovor in smo premaknili kategorijo odgovora od levega okvirja proti desnemu
+ if (tip == 1 && draggableOver[spremenljivka] == true){
+ $('#half2_frame_dropping_'+spremenljivka).toggleClass('frame_dropping_hover_right_single');//sprozi preklop sloga levega okvirja
+ //console.log('Yo!');
+ }
+ draggableOver[spremenljivka] = false;
+ return true;
+ }
+ else {
+ return false;
+ }
+ },
+ //stack: '#half_'+spremenljivka+' div',
+ stack: '#half2_'+spremenljivka+' div',
+ opacity: 0.9,
+ containment: '#prestavljanje_'+spremenljivka,
+ })
+ .dblclick(function() { //ob dvojnem kliku na kategorijo, to prenesi kot odgovor na ustrezno mesto
+ var vre_id = $(this).attr('value');
+ var id_parent = $(this).parent().attr('id'); //hrani id bloka v katerem se trenutno nahaja mozen odgovor
+ var other = $(this).attr('missing'); //spremenljivka, ki hrani vrednost atributa missing
+ var other_present = $('#half2_frame_dropping_'+spremenljivka).children('div').attr('missing'); //missing, ki je trenutno v desnem bloku
+ checkBranching();
+
+ if (id_parent == 'half_frame_dropping_'+spremenljivka){ //ce je trenuten odgovor v levem bloku
+ if( ( (tip == 1 && other == 0) ) || ( (tip == 2) && (other_present != 0) ) || ( (other != 0) ) ) {//ce je preneseni odgovor tipa 1 ("radio") in ni missing-a,
+ //ALI ce je preneseni odgovor tipa 2 ("checkbox") in je missing prisoten v desnem bloku ALI ce je preneseni odgovor missing
+ //sprazni blok z odgovori oz. prenesi morebitne obstojece odgovore nazaj v levi blok in zbrisi trenutni (missing) odgovor iz baze
+ if (ajax){ //zbrisi trenutne odgovore iz baze
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop2_data', {spremenljivka: spremenljivka, usr_id: usr_id, anketa: anketa}); //post-aj potrebne podatke
+ }
+ $('.ui-draggable[name="vrednost_'+spremenljivka+'"]').appendTo('#half_frame_dropping_'+spremenljivka);//prenesi skupino odgovorov v levi (zacetni) blok
+ }
+
+ $('#half2_frame_dropping_'+spremenljivka).prepend(this); //pripopaj na zacetek seznama odgovorov (desni blok) izbrani missing
+ if (ajax){ //vnesi missing odgovor v bazo
+ $.post(site_url+'/main/survey/ajax.php?a=accept_dragdrop1', {spremenljivka: spremenljivka, vre_id: vre_id, anketa: anketa, usr_id: usr_id}); //post-aj potrebne podatke
+ }
+
+ draggableOver[spremenljivka] = false;
+ draggableOnDroppable[vre_id] = true; //kategorija odgovora je v desnem okviru
+
+ } //konec if za levi blok
+ else if(id_parent == 'half2_frame_dropping_'+spremenljivka){ //ce je trenuten odgovor v desnem bloku
+
+ if(other != 0 || other == 0){
+ var vre_id = $(this).attr('value');
+ $('#half_frame_dropping_'+spremenljivka).prepend(this); //pripopaj prenesno na zacetek seznama kategorij
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).draggable( 'option', 'appendTo', '#half_frame_dropping_'+spremenljivka);
+ $('#vrednost_if_'+usr_id).remove();
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop1_data', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa}); //post-aj potrebne podatke
+ }
+ }
+
+/* if(other == 0){
+ var vre_id = $(this).attr('value');
+ $('#half_'+spremenljivka).prepend(this); //pripopaj preneseno na zacetek seznama kategorij
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).draggable( 'option', 'appendTo', '#half_'+spremenljivka);
+ $('#vrednost_if_'+usr_id).remove();
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop1_data', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa}); //post-aj potrebne podatke
+ }
+ } */
+ draggableOver[spremenljivka] == false; //nismo vec v over dogodku
+ draggableOnDroppable[vre_id] = false;
+ } //konec if za desni blok
+
+ });
+
+ //dodajanje atributov, ki so prisotni pri vseh ostalih kategorijah odgovorov
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).attr({'value':vre_id, 'name':'vrednost_'+spremenljivka, 'onclick':'checkBranching();', 'missing':other});
+
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta
+ var default_cat_height = 15;
+ var final_height = 0;
+ //var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ //console.log('Število znakov v kategoriji: '+cat_text_length);
+
+ var num_of_br = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' br').length; //hrani stevilo br oz. ročnih vnosov novih vrstic
+ //console.log('Število br v kategoriji: '+num_of_br);
+
+ var num_imgs = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').length; //hrani stevilo img v interesiranem div-u
+ //console.log('Število slik v kategoriji: '+num_imgs);
+
+ var max_cat_text_length = 30; //hrani max stevilo dolzine teksta do katerega ni potrebno samodejno dodati <br>
+
+
+ if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs == 0) ){//ce je tekst daljsi od 30 znakov, nima breakov ali slik dodaj <br>
+ //if( (cat_text_length > max_cat_text_length) ){//ce je tekst daljsi od 35 znakov dodaj <br>
+ //console.log('Tekst je daljši od '+max_cat_text_length+' znakov');
+ //var txt2 = txt1.slice(0, 3) + "bar" + txt1.slice(3);
+ //var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text();
+ var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ //console.log(txt);
+ var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt);
+ final_height = final_height + default_cat_height + 25;
+ //console.log(final_height);
+ }
+ /* else if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs != 0) ){//ce je tekst daljsi od 35 znakov, nima breakov, ima pa sliko dodaj <br>
+
+ var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ console.log(txt);
+ var n_img_start = txt.search("<img"); //var n = str.search("W3Schools"); //hrani index, kjer se začne html za sliko
+ var n_img_end = txt.indexOf(">");
+ console.log(n_img_start);
+ console.log(n_img_end);
+ //var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt);
+ //final_height = final_height + default_cat_height + 25;
+ //console.log(final_height);
+
+ } */
+
+
+ if (num_imgs != 0){ // ce imamo sliko
+
+ var img_height = 0;
+ //var max_width = $('.ranking').width();
+ var max_width = 230;
+ var img = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img');
+ var img_width = img.width();
+ //console.log("img_width: "+img_width);
+
+ var img_height = img.height();
+ //console.log("img_height: "+img_height);
+
+ if (img_width > max_width){
+ img_height = (img_height / img_width) * max_width;
+ img.css({width: max_width});
+ img.css({height: img_height});
+ //$('#vre_id_'+vre_id).css({height: height});
+ //console.log("Vecji od max width");
+ }
+
+ //ureditev mobilne različice prikazovanja slik znotraj kategorij odgovorov
+/* if (mobile == 1){ //ce je mobilnik
+ img_height = (img_height / img_width) * 100;
+ img_width = 100;
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').attr('style', 'margin: auto !important'); //dodaj atribut
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').css({'height':img_height,'width':img_width}); //ustrezno spremeni visino in sirino slike
+ } */
+ //ureditev mobilne različice prikazovanja - konec
+
+ //console.log("img_height: "+img_height);
+ if(img_height > 25){ //ce je visina slike vecja od default visine kategorije
+ final_height = final_height + img_height;
+ }
+
+
+
+ //ureditev visine variable_holder, ki je znotraj okvirja !!!!!!!!!!
+ //$('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(final_height + img_height)+'px'});
+ }
+
+ if(num_of_br != 0){
+ var br_height = num_of_br*25;
+
+ if (num_imgs == 0){
+ final_height = final_height + default_cat_height + br_height;
+ }
+ else{
+ final_height = final_height + br_height;
+ }
+
+
+ //console.log(final_height);
+ if( (img_height < 25) && (img_height != 0) ){
+ final_height = final_height + img_height;
+ }
+ }
+ if (final_height != 0){
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).css({'height':final_height}); //dodaj style atributu še novo višino za levi blok
+ }
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta - konec
+
+
+}
+//***********************************************************************
+
+//*********funkcija, ki skrbi za delovanje drag and drop funkcionalnosti
+function DragDropDelovanje(tip, spremenljivka, site_url, ajax, anketa, usr_id, num_of_cats, mobile, checkbox_limit){
+ //*****za mobilne naprave
+ var top_cat = -1;
+ var left_cat = -1;
+ var default_var_height = 290;
+ if (mobile == 0 || mobile == 2){
+ top_cat = -6;
+ left_cat = -6;
+ default_var_height = 220; //default visina celotnega vprasanja @ mobile == 0 (desktop) in mobile == 2 (tablica)
+ }
+
+ //*********************
+ //ureditev visine celotnega vprasanja, ce je ta visja od default-a*******************************************************************
+ var cat_total_height_left = 0; //hrani trenutno visino levega okvirja kategorij odgovorov
+ var cat_margin_left = 0;
+ var cat_max_height = 0; //hrani trenutno najvecjo visino trenutne kategorije
+ var cat_default_inline_text_length = 16; //default dolzina teksta v eni vrstici kategorij odgovorov
+ //var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').height(); //visina naslova vprasanja (besedila vprasanja)
+ var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').outerHeight(true); //visina naslova vprasanja (besedila vprasanja)
+ var visinaPaddingovMarginovVprasanja = $('#spremenljivka_'+spremenljivka).outerHeight(true) - $('#spremenljivka_'+spremenljivka).height();
+ var visinaPaddingovMarginovHolder = $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').outerHeight(true) - $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height();
+ var pomoznoBesediloHeight = 40; //visina besedila "Razpoložljive kategorije:"
+ //ureditev visine puscice med blokoma okvirjev
+ var variable_holder_height = $('#spremenljivka_'+spremenljivka+' .variable_holder').height(); //visina variable_holder, potrebna za visino puscice med blokoma
+
+ $('#spremenljivka_'+spremenljivka+' td.middle img').css({'top' : (naslov_height + variable_holder_height/2) + 'px'}); //visina puscice med blokoma okvirjev
+
+
+
+ if (ajax){
+ //console.log('Getting data on load');
+ $.get(site_url+'/main/survey/ajax.php?a=get_dragdrop1_data', {spremenljivka: spremenljivka, anketa: anketa}, function(data){ //get potrebnih podatkov za resevanje missing
+
+ var array_length = data.length; //hrani koliko podatkov je prisotnih v polju s podatki iz baze
+ var vre_id = []; //polje, ki hrani id-je vrednosti vseh kategorij odgovorov interesirane spremenljivke
+ //var cat_total_height = 0; //hrani trenutno visino celotnega trenutnega vprasanja
+
+ //console.log(array_length); //prikazi koliko podatkov je prisotnih v polju s podatki iz baze
+ for(var i = 0; i < array_length; i++){ //sprehodi se po vseh vrednostih polja vre_id
+ vre_id[i] = data[i]; //polje iz podatkov iz baze data[], shrani v polje vre_id[]
+
+ var cat_height = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).height(); //visina kategorije z oznako
+ var cat_height_real = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).outerHeight(true); //realna visina kategorije z oznako
+
+ //console.log('Visina '+(i + 1)+': '+cat_height_real);
+
+ if(mobile == 1){ //ko je mobilnik, uredi velikost okvirja kategorije glede na dolzino besedila
+ var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).text().length; //dolzina teksta v kategoriji odgovora
+ //console.log("Dolžina besedila v kategoriji: "+cat_text_length);
+ if(cat_text_length > (cat_default_inline_text_length)*2 ){ //ce je dolzina teksta v kategoriji daljsa 2-krat vec od default (16)
+ //console.log("Tekst je daljši!");
+ var num_of_rows = cat_text_length / cat_default_inline_text_length;
+ //console.log("num_of_rows: "+num_of_rows);
+ cat_height_real = cat_height_real + 25 * (num_of_rows - 2); //trenutno visino kategorije povecaj za 25
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).css({'height':(cat_height_real)+'px'}); //spremeni visino kategorije
+ }
+ }
+
+ cat_total_height_left = cat_total_height_left + cat_height_real; //izracun koncne realne visine levega okvirja
+
+ if (cat_max_height < cat_height){ //ce je maksimalna visina kategorije manjsa od trenutne visine kategorije
+ cat_max_height = cat_height; //naj bo vrednost max visine kategorije trenutna visina kategorije
+ }
+
+ }
+
+ var koncnaVisinaVprasanja = cat_total_height_left + naslov_height + pomoznoBesediloHeight + visinaPaddingovMarginovVprasanja + visinaPaddingovMarginovHolder*4;
+
+ commentHeight = GetCommentHeight(spremenljivka);
+
+ $('#spremenljivka_'+spremenljivka).css({'height':(koncnaVisinaVprasanja + commentHeight)+'px'});
+
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(koncnaVisinaVprasanja*0.90)+'px'}); //visina variable_holder
+
+ //*************urejanje visine levega okvirja kategorij odgovorov
+ $('#half_frame_dropping_'+spremenljivka).css({'height':(cat_total_height_left)+'px'});//visina levega okvirja
+
+ //*************urejanje visine desnega okvirja glede na visino levega okvirja, ki hrani kategorije odgovorov
+ if (tip != 1){ //ce nimamo kategorije vec odgovorov
+ $('#half2_frame_dropping_'+spremenljivka).css({'height':(cat_total_height_left)+'px'}); //visina desnega okvirja
+ }
+ else if (tip == 1){ //ce imamo kategorije en odgovor
+ $('#half2_frame_dropping_'+spremenljivka).css({'height':(cat_max_height)+'px'});//visina desnega okvirja
+ }
+
+ default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ //console.log("default_var_height konec: "+default_var_height);
+
+ //urejanje visine na kateri se nahaja gumb za ponastavljanje vprašanja
+ ResetButtonHeight(spremenljivka);
+ //urejanje visine na kateri se nahaja gumb za ponastavljanje vprašanja - konec
+
+ }, "json");
+ }
+
+
+
+
+ //***********************************************************************************************************************************
+ $('#half_frame_dropping_'+spremenljivka)
+ .droppable({
+ //hoverClass: 'frame_ranking_hover',
+ hoverClass: 'frame_dropping_hover',
+ drop: function (event, ui) {
+ checkBranching();
+ //$(this).prepend(ui.draggable); //pripopaj na zacetek seznama odgovorov (desni blok)
+ //ui.draggable.position( { of: $(this), my: 'left top', at: 'left top' } ); //pozicijoniraj levi zgornji del elementa z odgovorom na levem zgornjem delu droppable
+ //ui.draggable.offset( { of: $(this), my: 'left top', at: 'left top' } );
+
+ //$(ui.draggable).detach().css({top: -6,left: -6}).appendTo(this);
+ $(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this);
+ //$(ui.draggable).addClass('drag_and_drop').detach().appendTo(this);
+ $(ui.draggable).addClass('drag_and_drop_right');
+
+ //brisi podatke prenesenega odgovora iz baze
+ var vre_id = ui.draggable.attr('value');
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop1_data', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa}); //post-aj potrebne podatke za brisanje
+ }
+ draggableOver[spremenljivka] == false; //nismo vec v over dogodku
+ draggableOnDroppable[vre_id] = false;
+
+ },
+ out: function (event, ui) { //ob izhodu iz drop zone
+ //answer_coming[spremenljivka] = true;
+ //console.log('out');
+ $(ui.draggable).removeClass('drag_and_drop_right');
+ $(ui.draggable).addClass('drag_and_drop');
+ }
+ });
+
+ //var stevilo_zdaj = $('#half2_frame_dropping_'+spremenljivka).children('div').attr('missing');
+ //var other_present = $(this).children('div').attr('missing');
+ //console.log(stevilo_zdaj);
+
+ //if (tip == 1 && ($('#half2_frame_dropping_'+spremenljivka).children('.ranking').length != 0) ){ //ce je tip vprasanja kategorije en odgovor
+ if (tip == 1){ //ce je tip vprasanja kategorije en odgovor
+ $('#half2_frame_dropping_'+spremenljivka)
+ .droppable({
+ //hoverClass: 'frame_ranking_hover',
+ hoverClass: 'frame_dropping_hover_right_single',
+ //accept: '#half_'+spremenljivka+' div',
+ drop: function (event, ui) { //ob dropanju odgovora v desni blok
+ //console.log("Drop");
+ checkBranching();
+
+ var vre_id = ui.draggable.attr('value');
+ var other = ui.draggable.attr('missing'); //spremenljivka, ki hrani vrednost atributa missing
+ var other_present = $(this).children('div').attr('missing'); //missing, ki je trenutno v desnem bloku
+ var cat_right = $(this).children('div').css('height'); //ali je prisotna kaksna kategorija v desnem okvirju? Undefined = ne
+
+
+ //ce je preneseni odgovor tipa 1 ("radio") in ni missing-a,
+ //ALI ce je preneseni odgovor tipa 2 ("checkbox") in je missing prisoten v desnem bloku
+ //ALI ce je preneseni odgovor missing
+ //sprazni blok z odgovori oz. prenesi morebitne obstojece odgovore nazaj v levi blok
+ if( ( (tip == 1 && other == 0 && cat_right) ) || ( (tip == 2) && (other_present != 0) ) || ( (other != 0) ) ) {
+ $('.ui-draggable[name="vrednost_'+spremenljivka+'"]').appendTo('#half_frame_dropping_'+spremenljivka);//prenesi skupino odgovorov v levi (zacetni) blok
+ }
+
+ //pozicioniranje draggable na pravo mesto
+ $(ui.draggable).removeClass('drag_and_drop');//odstranimo, ker je nepotrebno na levi strani
+ $(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this); //najprej pozicioniramo na zacasni lokaciji
+ $(ui.draggable).addClass('drag_and_drop_right');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ //pozicioniranje draggable na pravo mesto - konec
+
+ if (ajax){
+ //post-aj potrebne podatke za belezenje v bazo
+ //in zbrisi trenutno hranjene podatke, ce je to potrebno
+ $.post(site_url+'/main/survey/ajax.php?a=accept_dragdrop1', {other_present: other_present, other: other, cat_right: cat_right, tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, anketa: anketa, usr_id: usr_id});
+ }
+ draggableOver[spremenljivka] = false; //zabelezi, da draggable ni vec over
+ draggableOnDroppable[vre_id] = true; //kategorija odgovora je v desnem okviru
+ },
+ over: function (event, ui) { //ob izhodu iz drop zone
+ draggableOver[spremenljivka] = true; //zabelezi, da je draggable over
+ checkBranching();
+ },
+ out: function (event, ui) { //ob izhodu iz drop zone
+ draggableOver[spremenljivka] = false; //zabelezi, da draggable ni vec over
+ $(ui.draggable).removeClass('drag_and_drop_right'); //odstranimo slog, ker drugace se draggable ne vidi, ko ga premikamo
+/* var vre_id = ui.draggable.attr('value');
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop1_data', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa}); //post-aj potrebne podatke za brisanje
+ } */
+ }
+ });
+ }
+ //else if( tip == 2 || (tip == 1 && ($('#half2_frame_dropping_'+spremenljivka).children('.ranking').length == 0) ) ) { //ce je tip vprasanja kategorije vec odgovorov in pri kategorije en odgovor ni nobenih odgovorov v desnem okvirju
+ else if( tip == 2 ) { //ce je tip vprasanja kategorije vec odgovorov in pri kategorije en odgovor ni nobenih odgovorov v desnem okvirju
+ $('#half2_frame_dropping_'+spremenljivka)
+ .droppable({
+ //hoverClass: 'frame_ranking_hover',
+ hoverClass: 'frame_dropping_hover',
+ //accept: '#half_'+spremenljivka+' div',
+ drop: function (event, ui) { //ob dropanju odgovora v desni blok
+ checkBranching();
+ //console.log("Drop");
+
+ var vre_id = ui.draggable.attr('value');
+ var other = ui.draggable.attr('missing'); //spremenljivka, ki hrani vrednost atributa missing
+ var other_present = $(this).children('div').attr('missing'); //missing, ki je trenutno v desnem bloku
+
+
+
+ if( ( (tip == 2) && (other_present != 0) ) || ( (other != 0) ) ) {
+ //ce je preneseni odgovor tipa 2 ("checkbox") in je missing prisoten v desnem bloku
+ //ALI ce je preneseni odgovor missing
+ //sprazni blok z odgovori oz. prenesi morebitne obstojece odgovore nazaj v levi blok
+ $('.ui-draggable[name="vrednost_'+spremenljivka+'"]').appendTo('#half_frame_dropping_'+spremenljivka);//prenesi skupino odgovorov v desni (zacetni) blok
+ }
+
+ var numItems = $(this).children('div').length; //trenutno stevilo elementov v desnem okvirju
+ numItems=numItems+1;
+ if(checkbox_limit!=0&&numItems>checkbox_limit){ //ce je nastavljen limit in stevilo elementov vecje od limita
+ ui.draggable.draggable('option','revert',true); //vrni preneseni in odvecni element nazaj v levi okvir
+ }else{ //drugace
+ //pozicioniranje draggable na pravo mesto
+ $(ui.draggable).removeClass('drag_and_drop'); //odstranimo, ker je nepotrebno na levi strani
+ $(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this); //najprej pozicioniramo na zacasni lokaciji
+ $(ui.draggable).addClass('drag_and_drop_right'); //dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ //pozicioniranje draggable na pravo mesto - konec
+ if (ajax){
+ //post-aj potrebne podatke za belezenje v bazo
+ //in zbrisi trenutno hranjene podatke, ce je to potrebno
+ $.post(site_url+'/main/survey/ajax.php?a=accept_dragdrop1', {other_present: other_present, other: other, tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, anketa: anketa, usr_id: usr_id}); //post-aj potrebne podatke za belezenje v bazo
+ }
+ }
+ },
+ out: function (event, ui) { //ob izhodu iz drop zone
+ $(ui.draggable).removeClass('drag_and_drop_right'); //odstranimo slog, ker drugace se draggable ne vidi, ko ga premikamo
+/* var vre_id = ui.draggable.attr('value');
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop1_data', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa}); //post-aj potrebne podatke za brisanje
+ } */
+ }
+ });
+ }
+
+ //Ureditev povrnitve odgovorov (iz desne strani) v levo
+ $('#resetDragDrop_'+spremenljivka).click(function(){
+
+ var rightFrameHasChildren = ($('#half2_frame_dropping_'+spremenljivka).has('div').length ? 'Da' : 'Ne');
+ //console.log("Imamo kaj v desnem okvirju? "+rightFrameHasChildren);
+
+ if (rightFrameHasChildren == 'Da'){
+ $('#half2_frame_dropping_'+spremenljivka).children('div').each(function(index) { //preleti vse prisotne odgovore v desnem okvirju
+ var vre_id = $(this).val();
+ //console.log(index + ": " + vre_id);
+ $('#half_frame_dropping_'+spremenljivka).prepend(this); //pripopaj prenesno na zacetek seznama kategorij
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).draggable( 'option', 'appendTo', '#half_'+spremenljivka);
+ $('#vrednost_if_'+usr_id).remove();
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop1_data', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa}); //post-aj potrebne podatke
+ }
+ draggableOver[spremenljivka] == false; //nismo vec v over dogodku
+ draggableOnDroppable[vre_id] = false;
+ });
+ //console.log("Reset answers");
+ }
+ });
+
+
+}
+//**************************************************************************************
+//************funkcija, ki skrbi za inicializacijo draggable elementov pri gridih
+function GridDraggable(tip, spremenljivka, vre_id, ajax, anketa, site_url, usr_id, other, mobile, skatle)
+{
+ //*****za mobilne naprave
+ var top_cat = -1;
+ var left_cat = -1;
+ if (mobile == 0 || mobile == 2){
+ top_cat = -6;
+ left_cat = -6;
+ top_cat_right = 30;
+ }
+ //*********************
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).addClass('drag_and_drop').detach().appendTo('#half_frame_dropping_'+spremenljivka) //zeleni element s kategorijami dodaj v zacetnem kontejnerju
+ .draggable({ //ureditev, da je element draggable
+ cursor: 'move',
+ //revert: true,
+ helper: 'original',
+ zIndex: 100,
+ revert: function(socketObj)
+ {
+ checkBranching();
+ var revert = false;
+ var cat_default_height = 37;
+ var cat_margin_left = 10 + 5*2 + 1*2;
+ //var indeks_revert_1 = last_indeks[spremenljivka];
+ var last_vre_id_revert = last_vre_id[spremenljivka];
+ var trenutna_vre_id_revert = vre_id_global[spremenljivka];
+ //console.log("trenutna_vre_id_revert: "+trenutna_vre_id_revert);
+ //var indeks_revert = indeks_global[spremenljivka];
+ var indeks_revert = last_drop[trenutna_vre_id_revert];
+ vre_id = trenutna_vre_id_revert;
+ //grd_id = last_indeks[spremenljivka];
+ grd_id = indeks_revert;
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var trenutni_okvir = $('#half2_frame_dropping_'+last_drop[trenutna_vre_id_revert]+'_'+spremenljivka);
+ var draggable = draggable_global[trenutna_vre_id_revert];
+ var skatle = skatlastOkvir[spremenljivka];
+ //console.log("Skatle za "+spremenljivka+" so:"+skatle);
+
+ //if false then no socket object drop occurred.
+ if(socketObj === false){
+ //revert the peg by returning true
+ //console.log("Reverting!")
+ revert = true;
+
+ if(tip == 6){
+ //ce odgovora ni v levem okvirju (ima indeks = 0),
+ //ce se odgovor reverta nazaj v desni okvir
+ if(indeks_revert != 0){
+ //oznacimo, da je trenutna kategorija odgovora v desnem okvirju
+ draggableOnDroppable[last_vre_id_revert][indeks_revert] = true;
+ //draggableOverDroppable[vre_id] = false;
+ draggableOverDroppable[vre_id][indeks_revert] = true;
+ //console.log('draggableOverDroppable['+vre_id+']['+indeks_revert+']: '+draggableOverDroppable[vre_id][indeks_revert]);
+ //postimajo visino
+ frame_and_question_height(trenutni_okvir, spremenljivka, num_grids_global[spremenljivka], cat_margin_left, cat_default_height, draggable);
+ //console.log("Frame and question height iz reverta");
+ }
+ var prejsnji_okvir_kat_prisotna = [];
+ var stevilo_prisotnih = prejsnji_okvir.children('div').length;
+ //console.log("stevilo_prisotnih:"+stevilo_prisotnih);
+ //var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+
+ for(var z = 1; z <= stevilo_prisotnih; z++){
+ prejsnji_okvir_kat_prisotna[z] = prejsnji_okvir.children('div :nth-child('+z+')').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju, kateri odgovori so prisotni
+ //console.log("prejsnji_okvir_kat_prisotna["+z+"]: "+prejsnji_okvir_kat_prisotna[z]);
+ //}
+ //console.log("Tukaj!");
+ //ce zadnje obiskani okvir je bil eden od desnih in smo startali iz levega
+ if(last_indeks[spremenljivka] != 0 && indeks_revert == 0){
+ //spremeni velikost zadnje obiskanega desnega okvirja
+ //console.log("Tukaj!");
+ if(prejsnji_okvir_kat_prisotna[z] === undefined){
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids_global[spremenljivka], cat_margin_left, draggable_global[trenutna_vre_id_revert]);
+ }
+ last_indeks[spremenljivka] = 0;
+ }
+ //ce prejsnji okvir ni trenutni in ne revert-amo nazaj v levi okvir
+ if ( (last_indeks[spremenljivka] != last_drop[trenutna_vre_id_revert]) && (indeks_revert != 0) ){
+ //uredi velikost okvirja
+ frame_height(spremenljivka, vre_id, grd_id, revert);
+
+ //ce ni kategorije z odgovorom v okvirju
+ if(prejsnji_okvir_kat_prisotna[z] === undefined){
+ //uredi velikost zadnje obiskanega okvirja
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids_global[spremenljivka], cat_margin_left, draggable_global[trenutna_vre_id_revert]);
+ }
+
+ //uredi velikost celotnega vprasanja
+ //console.log("Uredi velikost celotnega vprašanja");
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ //var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ var default_var_height = 1;
+ dynamic_question_height(spremenljivka, num_grids_global[spremenljivka], mobile, skatle);
+ //************************************ konec - dinamicna visina celotnega vprasanja glede na visino prenesenih desnih okvirjev
+
+ }
+ }
+
+ //ce so skatlasti okvirji
+ if(skatle){
+ //console.log("Imamo skatle ob revertu");
+ //$(draggable).addClass('drag_and_drop_box_right');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ $(draggable).addClass('drag_and_drop_box_right_after_refresh');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ var pravaVisina = calcPravaVisina(prejsnji_okvir, draggable, 0, spremenljivka, 0, 0, 1); //calcPravaVisina(okvir, draggable, indeks, spremenljivka, refresh, zapStevKategorije, revert) //visina/pozicija prenesene kategorije v desnem okvirju
+ //console.log("pravaVisina:"+pravaVisina);
+
+ //ustavi animacijo revert-a, da za tem lahko takoj pozicioniramo kategorijo odgovora na pravo mesto
+ //$(draggable).finish();
+ //$(draggable).stop();
+
+ //pozicioniraj kategorijo odgovora na pravo mesto
+ $(draggable).css({top:pravaVisina+'!important'});
+ //pozicioniraj kategorijo odgovora na pravo mesto - konec
+
+
+ }
+ }
+ return true;
+ }
+ else{
+ //socket object was returned,
+ //we can perform additional checks here if we like
+ //alert(socketObj.attr('id')); would work fine
+ //console.log(socketObj.attr('id'));
+ //return false so that the peg does not revert
+ //console.log("Success!");
+ revert = false;
+ return false;
+ }
+ },
+ stack: '#half2_'+spremenljivka+' div',
+ opacity: 0.9,
+ containment: '#spremenljivka_'+spremenljivka,
+ });
+
+
+ //dodajanje atributov, ki so prisotni pri vseh ostalih kategorijah odgovorov
+
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).attr({'reverted':false,'value':vre_id, 'name':'vrednost_'+spremenljivka, 'onclick':'checkBranching();', 'missing':other});
+
+ //ce je tabela vec odgovorov, rabimo clone
+ if(tip == 16){
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).draggable( "option", "helper", "clone" );
+ }
+
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta
+ var default_cat_height = 15;
+ var final_height = 0;
+ //var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ //console.log('Število znakov v kategoriji: '+cat_text_length);
+
+ var num_of_br = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' br').length; //hrani stevilo br oz. ročnih vnosov novih vrstic
+ //console.log('Število br v kategoriji: '+num_of_br);
+
+ var num_imgs = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').length; //hrani stevilo img v interesiranem div-u
+ //console.log('Število slik v kategoriji @grids: '+num_imgs);
+
+ var max_cat_text_length = 30; //hrani max stevilo dolzine teksta do katerega ni potrebno samodejno dodati <br>
+
+
+ if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs == 0) ){//ce je tekst daljsi od 30 znakov, nima breakov ali slik dodaj <br>
+ //if( (cat_text_length > max_cat_text_length) ){//ce je tekst daljsi od 35 znakov dodaj <br>
+ //console.log('Tekst je daljši od '+max_cat_text_length+' znakov');
+ //var txt2 = txt1.slice(0, 3) + "bar" + txt1.slice(3);
+ //var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text();
+ var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ //console.log(txt);
+ var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt);
+ final_height = final_height + default_cat_height + 25;
+ //console.log(final_height);
+ }
+ /* else if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs != 0) ){//ce je tekst daljsi od 35 znakov, nima breakov, ima pa sliko dodaj <br>
+
+ var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ console.log(txt);
+ var n_img_start = txt.search("<img"); //var n = str.search("W3Schools"); //hrani index, kjer se začne html za sliko
+ var n_img_end = txt.indexOf(">");
+ console.log(n_img_start);
+ console.log(n_img_end);
+ //var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt);
+ //final_height = final_height + default_cat_height + 25;
+ //console.log(final_height);
+
+ } */
+
+
+ if (num_imgs != 0){ // ce imamo sliko
+
+ var img_height = 0;
+ //var max_width = $('.ranking').width();
+ var max_width = 230;
+ var img = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img');
+ var img_width = img.width();
+ //console.log("img_width: "+img_width);
+
+ var img_height = img.height();
+ //console.log("img_height: "+img_height);
+
+ if (img_width > max_width){
+ img_height = (img_height / img_width) * max_width;
+ img.css({width: max_width});
+ img.css({height: img_height});
+ //$('#vre_id_'+vre_id).css({height: height});
+ //console.log("Vecji od max width");
+ }
+
+ //ureditev mobilne različice prikazovanja slik znotraj kategorij odgovorov
+/* if (mobile == 1){ //ce je mobilnik
+ img_height = (img_height / img_width) * 100;
+ img_width = 100;
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').attr('style', 'margin: auto !important'); //dodaj atribut
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').css({'height':img_height,'width':img_width}); //ustrezno spremeni visino in sirino slike
+ } */
+ //ureditev mobilne različice prikazovanja - konec
+
+ //console.log("img_height: "+img_height);
+ if(img_height > 25){ //ce je visina slike vecja od default visine kategorije
+ final_height = final_height + img_height;
+ }
+
+
+
+ //ureditev visine variable_holder, ki je znotraj okvirja !!!!!!!!!!
+ //$('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(final_height + img_height)+'px'});
+ }
+
+ if(num_of_br != 0){
+ var br_height = num_of_br*25;
+
+ if (num_imgs == 0){
+ final_height = final_height + default_cat_height + br_height;
+ }
+ else{
+ final_height = final_height + br_height;
+ }
+
+
+ //console.log(final_height);
+ if( (img_height < 25) && (img_height != 0) ){
+ final_height = final_height + img_height;
+ }
+ }
+ if (final_height != 0){
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).css({'height':final_height}); //dodaj style atributu še novo višino za levi blok
+ }
+
+}
+//***********************************************************************
+//var cat_total_height_left = 0; //hrani trenutno visino levega okvirja kategorij odgovorov
+//*********funkcija, ki skrbi za delovanje drag and drop grid funkcionalnosti
+function GridDragDropDelovanje(num_grids, indeks, tip, spremenljivka, site_url, ajax, anketa, usr_id, num_of_cats, mobile, skatle){
+ //var default_var_height_1 = [];
+ //*****za mobilne naprave
+ var top_cat = -1;
+ var left_cat = -1;
+ var default_var_height = 290; //default visina celotnega vprasanja
+ if (mobile == 0 || mobile == 2){
+ top_cat = -6;
+ left_cat = -6;
+ top_cat_right = 30;
+ var default_var_height = 220; //default visina celotnega vprasanja
+ }
+ //*********************
+ //ureditev visine celotnega vprasanja, ce je ta visja od default-a*******************************************************************
+ //var cat_margin_left = 10 + 5*2 + 1*2; //hrani rob za ureditev visine levega okvirja = margin_spodnji + padding(spredi pa zadi) + border(spredi pa zadi) + neznanka
+ var cat_max_height = 0; //hrani trenutno najvecjo visino tretnutne kategorije
+ var cat_default_height = 37;
+ //var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').height(); //visina naslova vprasanja (besedila vprasanja)
+ var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').outerHeight(true); //visina naslova vprasanja (besedila vprasanja)
+ var visinaPaddingovMarginovVprasanja = $('#spremenljivka_'+spremenljivka).outerHeight(true) - $('#spremenljivka_'+spremenljivka).height();
+ var visinaPaddingovMarginovHolder = $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').outerHeight(true) - $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height();
+ var pomoznoBesediloHeight = 40; //visina besedila "Razpoložljive kategorije:"
+ var cat_default_inline_text_length = 16; //default dolzina teksta v eni vrstici kategorij odgovorov
+
+ //ureditev visine puscice med blokoma okvirjev
+ var variable_holder_height = $('#spremenljivka_'+spremenljivka+' .variable_holder').height(); //visina variable_holder, potrebna za visino puscice med blokoma
+ $('#spremenljivka_'+spremenljivka+' td.middle img').css({'top' : (naslov_height + variable_holder_height/2) + 'px'}); //visina puscice med blokoma okvirjev
+ if (ajax){
+ //console.log('Getting data on load');
+ $.get(site_url+'/main/survey/ajax.php?a=get_dragdrop1_data', {spremenljivka: spremenljivka, anketa: anketa}, function(data){ //get potrebnih podatkov za resevanje missing
+
+ //trenutna visina celotnega vprasanja
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ //console.log("default_var_height: "+default_var_height + " indeks: "+indeks+" num of grids: "+num_grids);
+
+ if(indeks == 1){//samo enkrat pojdi skozi leve kategorije odgovorov
+ var cat_total_height_left = 0; //hrani trenutno visino levega okvirja kategorij odgovorov
+ var array_length = data.length; //hrani koliko podatkov je prisotnih v polju s podatki iz baze
+ var vre_id = []; //polje, ki hrani id-je vrednosti vseh kategorij odgovorov interesirane spremenljivke
+
+ for(var i = 0; i < array_length; i++){ //sprehodi se po vseh vrednostih polja vre_id v levem bloku
+ vre_id[i] = data[i]; //polje iz podatkov iz baze data[], shrani v polje vre_id[]
+
+ var cat_height = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).outerHeight(); //visina kategorije
+ var cat_height_real = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).outerHeight(true); //realna visina kategorije z oznako
+
+ //console.log('Visina '+(i + 1)+': '+cat_height_real);
+
+ if(mobile == 1){ //ko je mobilnik, uredi velikost okvirja kategorije glede na dolzino besedila
+ var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).text().length; //dolzina teksta v kategoriji odgovora
+
+ if(cat_text_length > (cat_default_inline_text_length)*2.5 ){ //ce je dolzina teksta v kategoriji daljsa 2-krat vec od default (16) - DATI NA 2,5 KRATNIK
+ //console.log("Tekst je daljši!");
+ //console.log("Dolžina besedila v kategoriji: "+cat_text_length);
+ var num_of_rows = cat_text_length / cat_default_inline_text_length;
+ //console.log("num_of_rows: "+num_of_rows);
+
+ cat_height = cat_height + 25 * (num_of_rows - 1); //trenutno visino kategorije povecaj za 25
+ //cat_height_real = cat_height_real + 25 * (num_of_rows - 1); //trenutno visino kategorije povecaj za 25
+ //console.log("num_of_rows final: "+ (num_of_rows - 1));
+
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).css({'height':(cat_height_real)+'px'}); //spremeni visino kategorije
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).css({'height':(cat_height)+'px'}); //spremeni visino kategorije
+ }
+ //console.log("cat_height ajax za spremenljivko:"+spremenljivka+" "+cat_height);
+ }
+
+ cat_total_height_left = cat_total_height_left + cat_height_real; //izracun koncne visine levega okvirja
+
+
+ if (cat_max_height < cat_height){ //ce je maksimalna visina kategorije manjsa od trenutne visine kategorije
+ cat_max_height = cat_height; //naj bo vrednost max visine kategorije trenutna visina kategorije
+ }
+
+
+ }
+ //*************urejanje visine levega okvirja kategorij odgovorov
+ $('#half_frame_dropping_'+spremenljivka).css({'height':(cat_total_height_left)+'px'});//visina levega okvirja
+ }
+
+ if (mobile == 0 || mobile == 2){
+ if(skatle){
+ var title_heigth_real = $('.frame_dropping_titles_box').outerHeight(true);
+ }else{
+ var title_heigth_real = $('.frame_dropping_titles').outerHeight(true);
+ }
+ }else{
+ if(skatle){
+ var title_heigth_real = $('.frame_dropping_titles_box_mobile').outerHeight(true);
+ }else{
+ var title_heigth_real = $('.frame_dropping_titles_mobile').outerHeight(true);
+ }
+
+ }
+
+ if(indeks == 1){ //samo enkrat pojdi skozi desne okvirje
+ for(var j = 1; j <= num_grids; j++){ //preglej vse desne okvirje v desnem bloku
+ //realna visina trenutnega okvirja***************************************
+ var okvir_height_real = $('#half2_frame_dropping_'+j+'_'+spremenljivka).outerHeight(true);
+ frame_total_height_right[spremenljivka] = frame_total_height_right[spremenljivka] + okvir_height_real + title_heigth_real;
+ //console.log(j+" frame_total_height_right["+spremenljivka+"]:"+frame_total_height_right[spremenljivka]);
+
+ //ureditev pravilnega pozicioniranja kategorij ob refreshu @okvir skatlaste oblike
+ //console.log("Refresh je:"+refresh);
+ if(refresh[spremenljivka] == 1 && skatle){
+ //console.log("Je refresh");
+ var desniOkvir = $('#half2_frame_dropping_'+j+'_'+spremenljivka);
+ var cat_right = desniOkvir.children('div').outerHeight(true);//belezi visino kategorije odgovora, ce je ta prisotna v trenutnem desnem okvirju
+ if(cat_right){ //ce je kaj v okvirju, uredi pravi visino za kategorijo
+ var zapStevKategorije = 1;
+ desniOkvir.children('div').each(function () {
+ var trenutnaVisinaKategorije = $(this).outerHeight(true);
+ //console.log("trenutnaVisinaKategorije:"+trenutnaVisinaKategorije);
+ //var trenutnaVisinaKategorije = 0;
+ var pravaVisina = calcPravaVisina(desniOkvir, $(this), j, spremenljivka, refresh[spremenljivka], zapStevKategorije);
+ desniOkvir.prepend($(this).css({top: pravaVisina})); //prenesi ustrezni odgovor
+ zapStevKategorije++;
+ });
+ //var pravaVisina = calcPravaVisina(desniOkvir, 0, j, spremenljivka, refresh);
+ }
+
+ }else{
+ //console.log("Ni bilo refresha");
+ }
+ //ureditev pravilnega pozicioniranja kategorij ob refreshu @okvir skatlaste oblike - konec
+ }
+ //console.log(" frame_total_height_right["+spremenljivka+"]:"+frame_total_height_right[spremenljivka]);
+ if(refresh[spremenljivka] == 1 && skatle){
+ refresh[spremenljivka] = 0;
+ }
+ }
+
+ default_var_height_1[spremenljivka] = $('#spremenljivka_'+spremenljivka).height(); //belezenje celotne zacetne visine spremenljivke
+
+ if(cat_total_height_left > frame_total_height_right[spremenljivka]){ //ce je trenutna visina levega okvirja z odgovori vecja od koncne visine desnega okvirja
+ //console.log("Levi vecji od desnega za "+spremenljivka);
+ if( (cat_total_height_left > default_var_height) ){ //ce je koncna visina levega okvirja z odgovori vecja od visine celotnega vprasanja
+ dynamic_question_height_sub(cat_total_height_left, spremenljivka, default_var_height_1[spremenljivka]); //ustrezno spremeni visino celotnega vprasanja
+ }else if(cat_total_height_left < default_var_height_1[spremenljivka]){ //ce je koncna visina levega okvirja z odgovori manjsi od visine celotnega vprasanja
+ dynamic_question_height_sub(cat_total_height_left, spremenljivka, default_var_height_1[spremenljivka]); //ustrezno spremeni visino celotnega vprasanja
+ } else{
+ dynamic_question_height_sub(cat_total_height_left, spremenljivka, default_var_height_1[spremenljivka]);//ustrezno spremeni visino celotnega vprasanja
+ }
+
+ //ce je trenutna visina levega okvirja z odgovori manjsa od koncne visine desnega okvirja
+ }else if(cat_total_height_left < frame_total_height_right[spremenljivka]){
+ //console.log("Levi manjsi od desnega za "+spremenljivka);
+
+ frame_total_height_right[spremenljivka] = frame_total_height_right[spremenljivka] + naslov_height + pomoznoBesediloHeight + visinaPaddingovMarginovVprasanja + visinaPaddingovMarginovHolder*5;
+
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(frame_total_height_right[spremenljivka]*0.9);
+
+ commentHeight = GetCommentHeight(spremenljivka);
+
+ $('#spremenljivka_'+spremenljivka).height(frame_total_height_right[spremenljivka]+commentHeight);
+ }
+
+
+
+ //urejanje visine na kateri se nahaja gumb za ponastavljanje vprašanja
+ ResetButtonHeight(spremenljivka);
+ //urejanje visine na kateri se nahaja gumb za ponastavljanje vprašanja - konec
+
+ }, "json");
+ }
+
+ //************************ konec - ureditev visine celotnega vprasanja, ce je ta visja od default-a
+
+ //console.log("Grid delovanje: "+num_grids);
+
+ $('#half_frame_dropping_'+spremenljivka)
+ .droppable({
+ //hoverClass: 'frame_dropping_hover',
+ drop: function (event, ui) {
+ checkBranching();
+
+ //$(ui.draggable).detach().css({top: -6,left: -6}).appendTo(this);
+ $(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this);
+ $(ui.draggable).addClass('drag_and_drop_right');
+
+ var vre_id = ui.draggable.attr('value');
+
+ if (ajax && tip == 6){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data_1', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa, indeks: last_indeks[spremenljivka]}); //post-aj potrebne podatke za brisanje
+ //}
+ draggableOnDroppable[vre_id][last_indeks[spremenljivka]] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ draggableOverDroppable[vre_id][last_indeks[spremenljivka]] = false;
+ //console.log('draggableOverDroppable['+vre_id+']['+last_indeks[spremenljivka]+']: '+draggableOverDroppable[vre_id][last_indeks[spremenljivka]])
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ if(prejsnji_okvir_kat_prisotna === undefined && last_indeks[spremenljivka] != 0){
+ //console.log("Levi frame last frame func");
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable); //spremeni visino zadnje obiskanega okvirja
+ }
+ dynamic_question_height(spremenljivka, num_grids, mobile, skatle);
+ last_indeks[spremenljivka] = 0;
+ last_drop[vre_id] = 0;
+ last_vre_id[spremenljivka] = 0;
+
+ }
+ from_left[vre_id] = true;
+/* var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ default_var_height_1[spremenljivka] = default_var_height; */
+ },
+ out: function (event, ui) { //ob izhodu iz drop zone
+ $(ui.draggable).removeClass('drag_and_drop_right');
+ $(ui.draggable).addClass('drag_and_drop');
+ //answer_coming[spremenljivka] = true;
+ //var vre_id = ui.draggable.attr('value');
+ //console.log("from_left["+vre_id+"]: "+from_left[vre_id]);
+ },
+ over: function (event, ui) {
+ var vre_id = ui.draggable.attr('value');
+ //potrebno pridobiti informacijo ze tukaj, ker drugace so tezave @ revert v levi okvir
+ vre_id_global[spremenljivka] = vre_id;
+ draggable_global[vre_id] = ui.draggable;
+
+ $(ui.draggable).removeClass('drag_and_drop_box_right_after_refresh');
+
+ }
+ });
+
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka)
+ .droppable({
+ //hoverClass: 'frame_ranking_hover',
+ //hoverClass: 'frame_dropping_hover',
+ tolerance: "pointer",
+ //accept: '#half_'+spremenljivka+' div',
+ drop: function (event, ui) { //ob dropanju odgovora v desni blok
+ //console.log("Drop");
+
+ checkBranching();
+
+ if(mobile == 0 || mobile == 2){
+ //$(this).toggleClass('frame_dropping_wider'); //spremeni videz trenutnega okvirja
+ }else if(mobile == 1){
+ //$(this).toggleClass('frame_dropping_wider_mobile'); //spremeni videz trenutnega okvirja
+ }
+
+
+ num_grids = num_grids_global[spremenljivka];
+ var vre_id = ui.draggable.attr('value');
+ var other = ui.draggable.attr('missing'); //spremenljivka, ki hrani vrednost atributa missing
+ var other_present = $(this).children('div').attr('missing'); //missing, ki je trenutno v desnem bloku
+ var cat_right = $(this).children('div').outerHeight(true); //ali je prisotna kaksna kategorija v trenuntem desnem okvirju? Undefined = ne
+ var vre_id_present = $(this).children('div').attr('value'); //vre_id kategorije odgovora, ki je prisotna v okvirju ob dropu
+ //var draggable_global[spremenljivka] = ui.draggable;
+ draggable_global[vre_id] = ui.draggable;
+
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ var title_heigth = 26; //visina okvricka z naslovom
+ var height_beside = 40; //visina od zacetka vprasanja do prvega okvirja (in malo po zadnjem okvirju)
+ var final_height_right_block = 0; //hrani koncno visino desnega bloka, torej vseh prisotnih okvirjev
+ final_height_right_block = final_height_right_block + height_beside; //koncni visini dodamo se "praznino" med zacetkom vprasanja in prvim okvirjem
+
+ for(var j = 1; j <= num_grids; j++){ //preglej vse okvirje
+ //notranja visina trenutnega okvirja***************************************
+ var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).outerHeight(true);
+ //*************************************************************************
+ final_height_right_block = final_height_right_block + okvir_height + title_heigth;
+ //console.log('Koncna visina desnega bloka: '+final_height_right_block);
+ }
+
+ //trenutna visina celotnega vprasanja
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ //console.log('Default: '+default_var_height);
+ //console.log('Final: '+final_height_right_block);
+ if(final_height_right_block > default_var_height){
+ $('#spremenljivka_'+spremenljivka).css({'height':final_height_right_block+'px'});
+ //da ne bo pri mobilnikih prevec skrito vprasanje
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(final_height_right_block - 100)+'px'});
+
+ }
+ //************************************ konec - dinamicna visina celotnega vprasanja glede na visino prenesenih desnih okvirjev
+
+ //ce je tabela - en odgovor
+ if(tip == 6){
+ //pozicioniranje draggable na pravo mesto
+ if (cat_right && skatle){ //ce je ze nekaj v okvirju in imamo okvirje skatlaste oblike
+ $(ui.draggable).removeClass('drag_and_drop');//odstranimo, ker je nepotrebno
+ $(ui.draggable).removeClass('drag_and_drop_box_right_after_refresh');//odstranimo, ker je nepotrebno
+ var pravaVisina = calcPravaVisina(this, ui.draggable); //visina/pozicija prenesene kategorije v desnem okvirju
+ $(ui.draggable).detach().css({top: (pravaVisina), left: left_cat}).prependTo(this); //pozicioniraj kategorijo odgovora na pravo mesto tako, da je nad prejsnjim
+ if($(this).children('div').hasClass('drag_and_drop_box_right_after_refresh')){ //ce so v okvirju kategorije, po refreshu
+ $(ui.draggable).addClass('drag_and_drop_box_right_after_refresh');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ }else{
+ $(ui.draggable).addClass('drag_and_drop_box_right_over');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ }
+ }else{
+ $(ui.draggable).removeClass('drag_and_drop');//odstranimo, ker je nepotrebno
+ $(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this); //najprej pozicioniramo na zacasni lokaciji
+ if(skatle){ //ce je okvir skatlaste oblike
+ $(ui.draggable).removeClass('drag_and_drop_box_right_after_refresh');//odstranimo, ker je nepotrebno na levi strani
+ $(ui.draggable).addClass('drag_and_drop_box_right');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ }else{
+ $(ui.draggable).addClass('drag_and_drop_right');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ }
+ }
+
+ //pozicioniranje draggable na pravo mesto - konec
+
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=accept_dragdrop_grid', {vre_id_present: vre_id_present, tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, anketa: anketa, usr_id: usr_id, indeks: indeks, cat_right: cat_right, last_vre_id: last_vre_id[spremenljivka]}); //post-aj potrebne podatke za belezenje v bazo
+ if(last_drop[vre_id] != indeks || last_drop[vre_id] != 0){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data_1', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa, indeks: last_drop[vre_id]}); //post-aj potrebne podatke za brisanje
+ }
+ }
+ }
+ else if(tip == 16 && draggableOnDroppable[vre_id][indeks] == false){ //ce je tabela - vec odgovorov in odgovora ni v trenutnem okvirju, uredi clone
+ var visina_test = ui.draggable.css('height');
+ //pozicioniranje draggable na pravo mesto**********************
+ if(cat_right && skatle){ //ce je ze nekaj v okvirju in je ta skatlaste oblike
+ var pravaVisina = calcPravaVisina(this, ui.draggable); //visina/pozicija prenesene kategorije v desnem okvirju
+
+ $(ui.draggable.clone()).detach().css({top: pravaVisina,left: left_cat, height: visina_test}).prependTo(this); //pozicioniraj kategorijo odgovora na pravo mesto in dodaj ustrezno visino
+
+ if($(this).children('div').hasClass('drag_and_drop_box_right_after_refresh')){ //ce so v okvirju kategorije, po refreshu
+ $(this).children(ui.draggable).addClass('drag_and_drop_box_right_after_refresh');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ }else{
+ $(this).children(ui.draggable).addClass('drag_and_drop_box_right_over');//dodamo slog, ki dokoncno postavi draggable na pravo lokacijo
+ }
+ }else{
+ if(skatle){ //ce je okvir skatlaste oblike
+ $(ui.draggable.clone()).detach().css({top: top_cat,left: left_cat, height: visina_test}).addClass('drag_and_drop_box_right').appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto in dodaj ustrezno visino
+ }else{
+ $(ui.draggable.clone()).detach().css({top: top_cat,left: left_cat, height: visina_test}).addClass('drag_and_drop_right').appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto in dodaj ustrezno visino
+ }
+ }
+ //pozicioniranje draggable na pravo mesto - konec**************************
+
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=accept_dragdrop_grid', {vre_id_present: vre_id_present, tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, anketa: anketa, usr_id: usr_id, indeks: indeks, cat_right: cat_right, last_vre_id: last_vre_id[spremenljivka]}); //post-aj potrebne podatke za belezenje v bazo
+ }
+ }
+
+ if(last_indeks[spremenljivka] !== undefined){
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ //console.log("last_indeks[spremenljivka][indeks]: "+last_indeks[spremenljivka][indeks]);
+ if(last_indeks[spremenljivka] == 0 || prejsnji_okvir_kat_prisotna === undefined){
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable); //spremeni visino zadnje obiskanega okvirja
+ }
+ }
+
+ last_drop[vre_id] = indeks; //zabelezi indeks okvirja zadnjega drop-a
+ draggableOnDroppable[vre_id][indeks] = true; //oznacimo, da je trenutna kategorija odgovora v okvirju
+ if(tip == 6){
+ from_left[vre_id] = false;
+ }
+ },
+ over: function (event, ui) { //ob prenosu trenutne kategorije odgovora nad okvirjem
+ //console.log("Over");
+ num_grids = num_grids_global[spremenljivka];
+ checkBranching();
+ var vre_id = ui.draggable.attr('value');
+ var vre_id_present = $(this).children('div').attr('value'); //vre_id kategorije odgovora, ki je prisotna v okvirju ob dropu
+ vre_id_global[spremenljivka] = vre_id;
+ var trenutni_okvir = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka);
+ //console.log("from_left["+vre_id+"]: "+from_left[vre_id]);
+
+ if (last_indeks[spremenljivka] == 0 && tip == 6){ //ce prenasamo kategorije odgovora iz levega okvirja
+ last_indeks[spremenljivka] = indeks; //zabelezi indeks prejsnjega okvirja
+
+ }else {
+
+ var last_vrednost_id_temp = last_vre_id[spremenljivka];
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+
+ //if(tip == 16 || tip == 6){
+ if(tip == 6){
+ var prejsnji_okvir_kat_prisotna = [];
+ var stevilo_prisotnih = prejsnji_okvir.children('div').length;
+ //console.log(stevilo_prisotnih);
+ for(var z = 1; z <= stevilo_prisotnih; z++){
+ //prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ prejsnji_okvir_kat_prisotna[z] = prejsnji_okvir.children('div :nth-child('+z+')').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju, kateri odgovori so prisotni
+ //console.log("prejsnji_okvir_kat_prisotna["+z+"]: "+prejsnji_okvir_kat_prisotna[z]);
+
+ if(last_vrednost_id_temp != 0){
+ //ce v prejsnjem okvirju ni nicesar in (v prejsnjem okvirju ni nicesar ali je identifikacija ista trenutni)
+ if( (draggableOnDroppable[last_vrednost_id_temp][indeks] == false) && ( (prejsnji_okvir_kat_prisotna === undefined) || (prejsnji_okvir_kat_prisotna == vre_id) ) ){
+ if ( (tip == 16 && draggableOnDroppable[vre_id][last_indeks[spremenljivka]] == false) || tip == 6 ){
+ //spremeni visino prejsnjega okvirja
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable);
+ //console.log("Spreminjam prejsnji okvir");
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ if(vre_id_present !== undefined){
+ //ce ni se nicesar v trenutnem okvirju, ali odgovor je na poti v okvir in je vprasanje tipa 16 (tabela - vec odgovorov) ali 6 (tabela - en odgovor)
+ if (draggableOnDroppable[vre_id_present][indeks] != true || (draggableOverDroppable[vre_id][indeks] == false && (tip == 16 || tip == 6) ) ){
+ //zabelezi, da je odgovor nad okvirjem
+ draggableOverDroppable[vre_id][indeks] = true;
+ if ((tip == 16 && draggableOnDroppable[vre_id][indeks] == false) || tip == 6){
+ //uredi visino okvirja in celotnega vprasanja
+ frame_and_question_height(trenutni_okvir, spremenljivka, num_grids, cat_margin_left, cat_default_height, ui.draggable);
+ if(from_left[vre_id] != false){
+ dynamic_question_height(spremenljivka, num_grids, mobile, skatle);
+ }
+
+ //console.log("Tukaj 1");
+ }
+ }
+ }else{
+
+ if (vre_id_present === undefined || (draggableOverDroppable[vre_id][indeks] == false && (tip == 16 || tip == 6) ) ){
+ //zabelezi, da je odgovor nad okvirjem
+ draggableOverDroppable[vre_id][indeks] = true;
+ if ( (tip == 16 && (draggableOnDroppable[vre_id][indeks] == false || last_drop[vre_id] == 0 )) || tip == 6){
+ //uredi visino okvirja in celotnega vprasanja
+ frame_and_question_height(trenutni_okvir, spremenljivka, num_grids, cat_margin_left, cat_default_height, ui.draggable);
+ if(from_left[vre_id] != false){
+ dynamic_question_height(spremenljivka, num_grids, mobile, skatle);
+ }
+ //console.log("Tukaj 2");
+ }
+ }
+ }
+
+ //spremeni videz trenutnega okvirja
+ if(draggableOverDroppable[vre_id][indeks] == true){
+ if(mobile == 0 || mobile == 2){
+ //$(this).toggleClass('frame_dropping_wider');
+ }
+ else if(mobile == 1){
+ //$(this).toggleClass('frame_dropping_wider_mobile');
+ }
+ }
+
+ last_indeks[spremenljivka] = indeks; //zabelezi indeks (trenutnega oz. bodocega) prejsnjega okvirja
+ cat_pushed[spremenljivka] = false;
+ },
+ out: function (event, ui) { //ob izhodu iz drop zone
+ //console.log("Out");
+ num_grids = num_grids_global[spremenljivka];
+ var vre_id = ui.draggable.attr('value');
+ var vre_id_present = $(this).children('div').attr('value'); //vre_id kategorije odgovora, ki je prisotna v okvirju ob dropu
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ //console.log("Out");
+ //draggableOnDroppable[vre_id] = false; //oznacimo, da smo tretnutno kategorijo odgovora odstranili iz okvirja
+
+
+ //if(draggableOverDroppable[vre_id] == true && tip == 16){
+ if(draggableOverDroppable[vre_id][indeks] == true && ( (tip == 16 && draggableOnDroppable[vre_id][last_indeks[spremenljivka]] == false) || tip == 6) ){
+ //console.log("Last frame out pri indeksu: "+last_indeks[spremenljivka]);
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable);
+ }
+ last_vre_id[spremenljivka] = vre_id;
+ last_indeks[spremenljivka] = indeks;
+ if( tip == 6 || (tip == 16 && draggableOnDroppable[vre_id][last_indeks[spremenljivka]] == false) ){
+ draggableOnDroppable[vre_id][indeks] = false; //oznacimo, da trenutne kategorije odgovora ni v okvirju
+ }
+ draggableOverDroppable[vre_id][indeks] = false;
+ draggable_global[vre_id] = ui.draggable;
+
+ //spremeni videz prejsnjega okvirja
+ if(draggableOverDroppable[vre_id][indeks] == false){
+ if(mobile == 0 || mobile == 2){
+ //prejsnji_okvir.toggleClass('frame_dropping_wider');
+ }else if(mobile == 1){
+ //prejsnji_okvir.toggleClass('frame_dropping_wider_mobile');
+ }
+ }
+
+ if(skatle){ //ce so okvirji skatlaste oblike
+ $(ui.draggable).removeClass('drag_and_drop_box_right'); //odstranimo slog, ker drugace se draggable ne vidi, ko ga premikamo
+ $(ui.draggable).removeClass('drag_and_drop_box_right_over'); //odstranimo slog, ker drugace se draggable ne vidi, ko ga premikamo
+ $(ui.draggable).removeClass('drag_and_drop_box_right_after_refresh');//drag_and_drop_box_right_after
+
+ }else{
+ $(ui.draggable).removeClass('drag_and_drop_right'); //odstranimo slog, ker drugace se draggable ne vidi, ko ga premikamo
+ }
+
+
+ }
+ });
+
+ //********************** odstranitev odgovorov iz desnih okvirjev @ tabela - vec odgovorov
+ // ce je tabela - vec odgovorov
+ if(tip == 16){ //uredi odstranjevanje kategorij odgovorov iz desnega okvirja ob kliku na njih
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka).click(function(){
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka).children().click(function(){ //ob kliku na kategorijo odgovora
+
+ var index1 = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka).children().index(this); //indeks klikanega odgovora
+ var prejsnji_okvir = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka); //
+ var vre_id = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka+' div:nth-child('+(index1 + 1)+')').attr('value');
+ var draggable = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka+' div:nth-child('+(index1 + 1)+')');
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka+' div:nth-child('+(index1 + 1)+')').detach();//odstrani odgovor iz okvirja
+
+ if (ajax){ //odstrani podatek o odgovoru iz baze
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data', {tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa, indeks: indeks}); //post-aj potrebne podatke za brisanje
+ }
+ //console.log(draggableOnDroppable[vre_id][indeks]);
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, draggable); //spremeni visino zadnje obiskanega okvirja
+ draggableOnDroppable[vre_id][indeks] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ //console.log("draggableOnDroppable["+vre_id+"]["+indeks+"]: "+draggableOnDroppable[vre_id][indeks]);
+ draggableOverDroppable[vre_id][indeks] = false;
+ from_left[vre_id] = true;
+ dynamic_question_height(spremenljivka, num_grids, mobile, skatle);
+ //console.log("vre_id: "+vre_id);
+
+ ResetButtonHeight(spremenljivka);//povrni gumb na zacetno visino
+ });
+
+ });
+
+ }
+ //********************** konec - odstranitev odgovorov iz desnih okvirjev @ tabela - vec odgovorov
+}
+//**************************************************************************************
+
+//ureja visino ovirja in kategorije vprasanja
+function frame_and_question_height(trenutni_okvir, spremenljivka, num_grids, cat_margin_left, cat_default_height, draggable){
+
+ //uredi visino okvirja in celotnega vprasanja
+ var other = draggable.attr('missing'); //spremenljivka, ki hrani vrednost atributa missing
+ var other_present = trenutni_okvir.children('div').attr('missing'); //missing, ki je trenutno v desnem bloku
+
+ //***************** glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+ var cat_height_now = draggable.outerHeight(true); //visina kategorije, trenutno prenesenega odgovora
+ var cat_right = trenutni_okvir.children('div').outerHeight(true); //visina kategorije odgovora, ce je ta prisotna v trenutnem desnem okvirju
+
+ //ce je v trenutnem desnem okvirju ze prisotna kategorija odgovora,
+ if(cat_right){
+ var whole_heigth = trenutni_okvir.height(); //trenutna visina desnega okvirja
+ var okvir_height = whole_heigth + cat_height_now; //trenutni visini okvirja dodaj se visino trenutne kategorije
+ trenutni_okvir.css({'height':(okvir_height)+'px'}); //visina trenutnega desnega okvirja
+ //console.log('Koncna visina: '+(okvir_height));
+ }else{ //drugace
+ if (cat_height_now < 15){ //ce je visina trenutne kategorije odgovova manjsa od 15
+ cat_height_now = 15; //naj bo visina okvirja 15px, prej 20px
+ }
+ trenutni_okvir.css({'height':(cat_height_now)+'px'}); //visina trenutnega desnega okvirja
+ //console.log('Koncna visina: '+(cat_height_now));
+ }
+ //************************************ konec - glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+}
+
+//funkcija za urejanje visine okvirjev
+function frame_height(spremenljivka, vre_id, grd_id, revert, refresh){
+ //console.log("frame_height");
+ //***************** glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+ //visina trenutno prenesenega odgovora*************
+ var cat_default_height = 37;
+ //var cat_height_now = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).outerHeight(true); //visina trenutne kategorije odgovora
+ if (vre_id != 0){
+ var cat_height_now = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).outerHeight(); //visina trenutne kategorije odgovora
+ }
+ //console.log("cat_height_now:"+cat_height_now);
+ //*************************************************visina trenutno prenesenega odgovora - konec
+
+
+ if (refresh == 1){ //visina trenutnih kategorij v okvirju, ce je refresh
+ //var cat_height_now
+ var visinaPrisotnihKategorij = 0;
+ //console.log("grd_id:"+grd_id);
+ $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).children('div').each(function () {
+ var trenutnaVisinaKategorije = $(this).outerHeight(true);
+ visinaPrisotnihKategorij = visinaPrisotnihKategorij + trenutnaVisinaKategorije;
+ });
+ var cat_height_now = visinaPrisotnihKategorij;
+ //console.log("cat_height_now:"+cat_height_now);
+ }
+
+ var cat_right = $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).children('div').outerHeight(true);//belezi visino kategorije odgovora, ce je ta prisotna v trenutnem desnem okvirju
+
+ //ce je v trenutnem desnem okvirju ze prisotna kategorija odgovora, trenutni visini okvirja dodaj se visino trenutne kategorije
+ //if(cat_right || revert){
+ if(cat_right || revert || refresh){
+ var whole_heigth = $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).outerHeight();
+ //console.log("whole_heigth:"+whole_heigth);
+ //cat_height_now = cat_height_now + cat_margin_left; //izracun koncne visine desnega okvirja, ce imamo ze kategorije v okvirju
+ //var okvir_height = parseInt(whole_heigth) + parseInt(cat_height_now);
+ var okvir_height = whole_heigth + cat_height_now;
+ $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).css({'height':(okvir_height)+'px'}); //visina desnega okvirja
+ //console.log('Koncna visina: '+(okvir_height));
+
+ }else{ //drugace
+ //cat_height_now = cat_height_now + cat_default_height; //izracun koncne visine desnega okvirja, ce ni kategorij v okvirju
+ if (cat_height_now < 15){ //ce je visina trenutne kategorije odgovova manjsa od 15, prej 20
+ cat_height_now = 15; //naj bo visina okvirja 15px, prej 20px
+ }
+ $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).css({'height':(cat_height_now)+'px'}); //visina trenutnega desnega okvirja
+ //console.log('Koncna visina okvirja z odgovorom: '+(cat_height_now));
+ }
+ //************************************ konec - glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+
+ //console.log("cat_height_now ["+vre_id+"]: "+cat_height_now);
+}
+//************** konec - funkcije za urejanje visine okvirjev
+
+//***************funkcija za urejanje visine zadnje obiskanega okvirja @ drag and drop
+function last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, draggable){
+ //console.log("last_frame_height");
+ //****glede na odstrajeno kategorijo odgovora, trenutni visini okvirja odstrani visino odstranjene kategorije
+
+ var trenutna_visina_okvirja = prejsnji_okvir.height();
+ var trenutna_visina_kategorije = draggable.outerHeight(true);//visina odnesene kategorije odgovora
+ koncna_visina_zapuscenega_okvirja = trenutna_visina_okvirja - trenutna_visina_kategorije;
+
+ //console.log("trenutna_visina_okvirja:"+trenutna_visina_okvirja);
+ //console.log("trenutna_visina_kategorije:"+trenutna_visina_kategorije);
+ //console.log("koncna_visina_zapuscenega_okvirja:"+koncna_visina_zapuscenega_okvirja);
+
+
+ if (koncna_visina_zapuscenega_okvirja < 15){
+ koncna_visina_zapuscenega_okvirja = 15;
+ }
+
+ prejsnji_okvir.css({'height':(koncna_visina_zapuscenega_okvirja)+'px'}); //visina trenutnega desnega okvirja
+}
+//*************** konec - funkcija za urejanje visine zadnje obiskanega okvirja
+
+//********* skrbi za koncno ureditev visine celotnega vprasanja glede na visino (levega ali desnega) bloka @ drag and drop
+function dynamic_question_height_sub(frame_height, spremenljivka){
+ //console.log("dynamic_question_height_sub za "+spremenljivka);
+
+ //var default_var_height = $('#spremenljivka_'+spremenljivka).height(); //trenutna visina celotnega vprasanja
+ var default_var_height = $('#spremenljivka_'+spremenljivka).outerHeight(true); //trenutna visina celotnega vprasanja
+
+ var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').outerHeight(true);
+ var visinaPaddingovMarginovVprasanja = $('#spremenljivka_'+spremenljivka).outerHeight(true) - $('#spremenljivka_'+spremenljivka).height();
+ var visinaPaddingovMarginovHolder = $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').outerHeight(true) - $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height();
+ var pomoznoBesediloHeight = 40; //visina besedila "Razpoložljive kategorije:", za mobilne naprave
+
+ var vmesnaVisinaOkvirja = realnaVisina(spremenljivka, frame_height);
+
+ //if( (frame_height + naslov_height) > default_var_height){ //ce je koncna visina okvirja vecja od trenutne default visine celotnega vprasanja
+ if( (vmesnaVisinaOkvirja) > default_var_height){ //ce je koncna visina okvirja vecja od trenutne default visine celotnega vprasanja
+ updateHeight(spremenljivka, frame_height);
+ //console.log("Spreminjam 1");
+ }else if((vmesnaVisinaOkvirja) < default_var_height){ //ce je koncna visina okvirja manjsa od trenutne default visine celotnega vprasanja
+ var koncnaVisinaVprasanja = $('#spremenljivka_'+spremenljivka).outerHeight(true); //trenutna visina celotnega vprasanja;
+ //console.log("koncnaVisinaVprasanja:"+koncnaVisinaVprasanja+" spremenljivka: "+spremenljivka);
+ updateHeight(spremenljivka, 0, koncnaVisinaVprasanja);
+
+ $('#spremenljivka_'+spremenljivka).height(koncnaVisinaVprasanja); //koncna visina celotnega vprasanja
+
+ //da ne bo pri mobilnikih prevec skrito vprasanje, spremeni visino variable_holder
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(koncnaVisinaVprasanja*0.85);
+ //console.log("Spreminjam 2");
+ }
+}
+
+//*********** ureja dinamicno visino celotnega vprasanja glede na visino prenesenih kategorij odgovorov iz desnih okvirjev v levega
+function dynamic_question_height(spremenljivka, num_grids, mobile, skatle){
+ //console.log("dynamic_question_height za:"+spremenljivka);
+
+/* if (mobile == 0 || mobile == 2){
+ var title_heigth = $('.frame_dropping_titles').outerHeight(true);
+ }else{
+ var title_heigth = $('.frame_dropping_titles_mobile').outerHeight(true);
+ } */
+ if (mobile == 0 || mobile == 2){
+ if(skatle){
+ var title_heigth = $('.frame_dropping_titles_box').outerHeight(true);
+ }else{
+ var title_heigth = $('.frame_dropping_titles').outerHeight(true);
+ }
+ }else{
+ if(skatle){
+ var title_heigth = $('.frame_dropping_titles_box_mobile').outerHeight(true);
+ }else{
+ var title_heigth = $('.frame_dropping_titles_mobile').outerHeight(true);
+ }
+
+ }
+
+ var final_height_right_block = 0; //hrani koncno visino desnega bloka, torej vseh prisotnih okvirjev
+ var frame_height_left = $('#half_frame_dropping_'+spremenljivka).outerHeight(true); //visina celotnega levega okvirja
+ //console.log('Koncna visina levega bloka: '+frame_height_left);
+
+ //pridobi visino desnega bloka
+ for(var j = 1; j <= num_grids; j++){ //preglej vse okvirje na desni strani
+ var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).outerHeight(true); //visina trenutnega okvirja
+ final_height_right_block = final_height_right_block + okvir_height + title_heigth; //vmesna visina desnega okvirja
+ }
+ //console.log('Koncna visina desnega bloka: '+final_height_right_block);
+ //pridobi visino desnega bloka - konec
+
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height(); //trenutna visina celotnega vprasanja
+ //console.log("default_var_height: "+default_var_height);
+
+ var vmesnaVisinaVprasanjaLevo = realnaVisina(spremenljivka, frame_height_left);
+ var vmesnaVisinaVprasanjaDesno = realnaVisina(spremenljivka, final_height_right_block);
+
+ //ce je visina celotnega vprasanja manjsa od okvirja/bloka (levi ALI desni)
+ if( (default_var_height < (vmesnaVisinaVprasanjaLevo)) || (default_var_height < (vmesnaVisinaVprasanjaDesno)) ){
+ if(frame_height_left < final_height_right_block){
+ //console.log("Levi manjsi od desnega");
+ dynamic_question_height_sub(final_height_right_block, spremenljivka); //glede na visino desnega bloka uredi velikost celotnega vprasanja
+ }else if(frame_height_left > final_height_right_block){
+ //console.log("Levi vecji od desnega");
+ dynamic_question_height_sub(frame_height_left, spremenljivka); //glede na visino levega bloka uredi velikost celotnega vprasanja
+ }
+ }else if (frame_height_left < final_height_right_block){
+ updateHeight(spremenljivka, final_height_right_block); //posodobi visino vprasanja
+ //console.log("Spreminjam A1");
+ }else if (frame_height_left > final_height_right_block){
+ updateHeight(spremenljivka, frame_height_left); //posodobi visino vprasanja
+ //console.log("Spreminjam A2");
+ }
+}
+
+//posodobi visino celotnega vprasanja in variable_holder
+function updateHeight(spremenljivka, final_height_block, visinaVprasanja){
+ //console.log("updateHeight za:"+spremenljivka);
+ if(visinaVprasanja){
+ var koncnaVisinaVprasanja = visinaVprasanja;
+ koncnaVisinaVariableHolder = koncnaVisinaVprasanja*0.85;
+ }
+ else{
+ var koncnaVisinaVprasanja = realnaVisina(spremenljivka, final_height_block);
+ koncnaVisinaVariableHolder = koncnaVisinaVprasanja*0.95;
+ }
+
+ commentHeight = GetCommentHeight(spremenljivka);
+
+ //ureditev visine celotnega vprasanja
+ $('#spremenljivka_'+spremenljivka).height(koncnaVisinaVprasanja + commentHeight);
+
+ //da ne bo pri mobilnikih prevec skrito vprasanje, spremeni visino variable_holder
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(koncnaVisinaVariableHolder);
+}
+
+//vrne realno visino vprasanja/bloka
+function realnaVisina(spremenljivka, final_height_block){
+ var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').height();
+ var visinaPaddingovMarginovVprasanja = $('#spremenljivka_'+spremenljivka).outerHeight(true) - $('#spremenljivka_'+spremenljivka).height();
+ var visinaPaddingovMarginovHolder = $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').outerHeight(true) - $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height();
+ var pomoznoBesediloHeight = 40; //visina besedila "Razpoložljive kategorije:"
+
+ var realnaVisina = final_height_block + naslov_height + pomoznoBesediloHeight + visinaPaddingovMarginovVprasanja + visinaPaddingovMarginovHolder*4;
+
+ return realnaVisina;
+}
+
+//vrne visino/pozicijo prenesene kategorije v desnem skatlastem okvirju
+function calcPravaVisina(tole, draggable, indeks, spremenljivka, refresh, zapStevKategorije, revert){
+ //console.log("refresh:"+refresh);
+
+ var visinaDesnegaOkvirja = $(tole).outerHeight();
+ //console.log("visinaDesnegaOkvirja:"+visinaDesnegaOkvirja);
+ var visinaPreneseneKategorije = 0;
+ if(draggable){
+ visinaPreneseneKategorije = $(draggable).outerHeight(true);
+ }
+
+ //console.log("visinaPreneseneKategorije:"+visinaPreneseneKategorije);
+
+ var visinaPrisotnihKategorij = 0;
+ var steviloKategorij = 0;
+ $(tole).children('div').each(function () {
+ var trenutnaVisinaKategorije = $(this).outerHeight(true);
+ visinaPrisotnihKategorij = visinaPrisotnihKategorij + trenutnaVisinaKategorije;
+ steviloKategorij++;
+ });
+ //console.log("steviloKategorij:"+steviloKategorij);
+ //console.log("visinaPrisotnihKategorij:"+visinaPrisotnihKategorij);
+ //console.log("zapStevKategorije:"+zapStevKategorije);
+
+ //ce je refresh ali revert
+ if( refresh == 1 || revert == 1){
+ if (visinaDesnegaOkvirja < visinaPrisotnihKategorij){ //ce je visina desnega okvirja manjsa od visine prisotnih kategorij
+ //console.log("visinaDesnegaOkvirja < visinaPrisotnihKategorij");
+ if(refresh == 1){
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka).css({'height':(visinaPrisotnihKategorij)+'px'}); //visina desnega okvirja
+ }
+ visinaDesnegaOkvirja = $(tole).outerHeight();
+ //console.log("visinaDesnegaOkvirja po refresh:"+visinaDesnegaOkvirja);
+ }
+
+ if(steviloKategorij > 1){
+ var pravaVisina = visinaDesnegaOkvirja - visinaPrisotnihKategorij;
+ }else{
+ var pravaVisina = visinaDesnegaOkvirja - visinaPreneseneKategorije;
+ }
+ }else{
+ var pravaVisina = visinaDesnegaOkvirja - visinaPrisotnihKategorij - visinaPreneseneKategorije;
+ }
+
+ //console.log("pravaVisina za sprem "+spremenljivka+" :"+pravaVisina);
+ //console.log("-------------------------");
+ return pravaVisina;
+}
+
+//urejanje visine na kateri se nahaja gumb za ponastavljanje vprašanja
+function ResetButtonHeight(spremenljivka){
+ $('#resetDragDrop_'+spremenljivka).position({
+ my: "left bottom",
+ at: "left bottom",
+ of: "#spremenljivka_"+spremenljivka,
+ collision: 'none'
+ });
+
+ var currentTop = $('#resetDragDrop_'+spremenljivka).css('top');
+ var commentHeight = 0;
+ if($('#spremenljivka_'+spremenljivka+' .comment').length > 0) { //ce je prisoten komentar, dodamo nekaj visine
+ commentHeight = 200;
+ }
+ var newTop = parseInt(currentTop) - 20 - commentHeight;
+ $('#resetDragDrop_'+spremenljivka).css('top', newTop+'px');
+}
+
+//funkcija, ki skrbi za preverjanje prisotnosti komentarja in vrne ustrezno dodatno visino, ki jo je potrebno dodati celotnemu vprasanju, da je komentar viden
+function GetCommentHeight(spremenljivka){
+ var commentHeight = 0;
+ if($('#spremenljivka_'+spremenljivka+' .comment').length > 0) { //ce je prisoten komentar, dodamo nekaj visine
+ commentHeight = 150;
+ }
+ return commentHeight;
+}
diff --git a/main/survey/js/DragDrop/dragdropbox.js b/main/survey/js/DragDrop/dragdropbox.js
new file mode 100644
index 0000000..f2da65a
--- /dev/null
+++ b/main/survey/js/DragDrop/dragdropbox.js
@@ -0,0 +1,951 @@
+//************funkcija, ki skrbi za inicializacijo draggable elementov pri gridih
+function GridDraggableBox(tip, spremenljivka, vre_id, ajax, anketa, site_url, usr_id, other, mobile){
+ //*****za mobilne naprave
+ var top_cat = -1;
+ var left_cat = -1;
+ if (mobile == 0 || mobile == 2){
+ top_cat = -6;
+ top_cat_right = 30;
+ left_cat = -6;
+ }
+ //*********************
+
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).detach().css({top: -6,left: -6}).appendTo('#half_frame_dropping_'+spremenljivka) //zeleni element s kategorijami dodaj v zacetnem kontejnerju
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).detach().css({top: top_cat,left: left_cat}).appendTo('#half_frame_dropping_'+spremenljivka) //zeleni element s kategorijami dodaj v zacetnem kontejnerju
+ .draggable({ //ureditev, da je element draggable
+ cursor: 'move',
+ //revert: true,
+ helper: 'original',
+ zIndex: 100,
+ revert: function(socketObj)
+ {
+ checkBranching();
+ var revert = false;
+ var cat_default_height = 37;
+ var cat_margin_left = 10 + 5*2 + 1*2;
+ //var indeks_revert_1 = last_indeks[spremenljivka];
+ var last_vre_id_revert = last_vre_id[spremenljivka];
+ var trenutna_vre_id_revert = vre_id_global[spremenljivka];
+ //console.log("trenutna_vre_id_revert: "+trenutna_vre_id_revert);
+ //var indeks_revert = indeks_global[spremenljivka];
+ var indeks_revert = last_drop[trenutna_vre_id_revert];
+ vre_id = trenutna_vre_id_revert;
+ //grd_id = last_indeks[spremenljivka];
+ grd_id = indeks_revert;
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var trenutni_okvir = $('#half2_frame_dropping_'+last_drop[trenutna_vre_id_revert]+'_'+spremenljivka);
+ var draggable = draggable_global[trenutna_vre_id_revert];
+
+ //if false then no socket object drop occurred.
+ if(socketObj === false){
+ //revert the peg by returning true
+ //console.log("Reverting!")
+ revert = true;
+
+ if(tip == 6){
+ //ce odgovora ni v levem okvirju (ima indeks = 0),
+ //ce se odgovor reverta nazaj v desni okvir
+ if(indeks_revert != 0){
+ //oznacimo, da je trenutna kategorija odgovora v desnem okvirju
+ draggableOnDroppable[last_vre_id_revert][indeks_revert] = true;
+ //draggableOverDroppable[vre_id] = false;
+ draggableOverDroppable[vre_id][indeks_revert] = true;
+ //console.log('draggableOverDroppable['+vre_id+']['+indeks_revert+']: '+draggableOverDroppable[vre_id][indeks_revert]);
+ //postimajo visino
+ frame_and_question_height(trenutni_okvir, spremenljivka, num_grids_global[spremenljivka], cat_margin_left, cat_default_height, draggable);
+ //console.log("Frame and question height iz reverta");
+ }
+ var prejsnji_okvir_kat_prisotna = [];
+ var stevilo_prisotnih = prejsnji_okvir.children('div').length;
+ //console.log(stevilo_prisotnih);
+ //var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+
+ for(var z = 1; z <= stevilo_prisotnih; z++){
+ prejsnji_okvir_kat_prisotna[z] = prejsnji_okvir.children('div :nth-child('+z+')').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju, kateri odgovori so prisotni
+ //console.log("prejsnji_okvir_kat_prisotna["+z+"]: "+prejsnji_okvir_kat_prisotna[z]);
+ //}
+ //console.log("Tukaj!");
+ //ce zadnje obiskani okvir je bil eden od desnih in smo startali iz levega
+ if(last_indeks[spremenljivka] != 0 && indeks_revert == 0){
+ //spremeni velikost zadnje obiskanega desnega okvirja
+ //console.log("Tukaj!");
+ if(prejsnji_okvir_kat_prisotna[z] === undefined){
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids_global[spremenljivka], cat_margin_left, draggable_global[trenutna_vre_id_revert]);
+ }
+ last_indeks[spremenljivka] = 0;
+ }
+ //ce prejsnji okvir ni trenutni in ne revert-amo nazaj v levi okvir
+ if ( (last_indeks[spremenljivka] != last_drop[trenutna_vre_id_revert]) && (indeks_revert != 0) ){
+ //uredi velikost okvirja
+ frame_height(spremenljivka, vre_id, grd_id, revert);
+
+ //ce ni kategorije z odgovorom v okvirju
+ if(prejsnji_okvir_kat_prisotna[z] === undefined){
+ //uredi velikost zadnje obiskanega okvirja
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids_global[spremenljivka], cat_margin_left, draggable_global[trenutna_vre_id_revert]);
+ }
+
+ //uredi velikost celotnega vprasanja
+ //console.log("Uredi velikost celotnega vprašanja");
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ //var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ var default_var_height = 1;
+ dynamic_question_height(spremenljivka, num_grids_global[spremenljivka], default_var_height);
+ //************************************ konec - dinamicna visina celotnega vprasanja glede na visino prenesenih desnih okvirjev
+
+ }
+ }
+ }
+ return true;
+ }
+ else{
+ //socket object was returned,
+ //we can perform additional checks here if we like
+ //alert(socketObj.attr('id')); would work fine
+ //console.log(socketObj.attr('id'));
+ //return false so that the peg does not revert
+ //console.log("Success!");
+ revert = false;
+ return false;
+ }
+ },
+ stack: '#half2_'+spremenljivka+' div',
+ opacity: 0.9,
+ containment: '#spremenljivka_'+spremenljivka,
+ });
+
+
+ //dodajanje atributov, ki so prisotni pri vseh ostalih kategorijah odgovorov
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).attr({'value':vre_id, 'name':'vrednost_'+spremenljivka, 'onclick':'checkBranching();', 'missing':other});
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).attr({'reverted':false,'value':vre_id, 'name':'vrednost_'+spremenljivka, 'onclick':'checkBranching();', 'missing':other});
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).attr({'reverted':false,'value':vre_id, 'name':'vrednost_'+spremenljivka, 'onclick':'checkBranching(); checkPosition('+tip+','+spremenljivka+','+ vre_id+','+ usr_id+','+anketa+','+site_url+');', 'missing':other});
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).attr({'reverted':false,'value':vre_id, 'name':'vrednost_'+spremenljivka, 'onclick':'checkBranching(); checkPosition('+tip+','+spremenljivka+','+ vre_id+','+ usr_id+','+anketa+');', 'missing':other});
+
+
+ //ce je tabela vec odgovorov, rabimo clone
+ if(tip == 16){
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).draggable( "option", "helper", "clone" );
+ }
+
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta
+ var default_cat_height = 15;
+ var final_height = 0;
+ //var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ //console.log('Število znakov v kategoriji: '+cat_text_length);
+
+ var num_of_br = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' br').length; //hrani stevilo br oz. ročnih vnosov novih vrstic
+ //console.log('Število br v kategoriji: '+num_of_br);
+
+ var num_imgs = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').length; //hrani stevilo img v interesiranem div-u
+ //console.log('Število slik v kategoriji @grids: '+num_imgs);
+
+ var max_cat_text_length = 30; //hrani max stevilo dolzine teksta do katerega ni potrebno samodejno dodati <br>
+
+
+ if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs == 0) ){//ce je tekst daljsi od 30 znakov, nima breakov ali slik dodaj <br>
+ //if( (cat_text_length > max_cat_text_length) ){//ce je tekst daljsi od 35 znakov dodaj <br>
+ //console.log('Tekst je daljši od '+max_cat_text_length+' znakov');
+ //var txt2 = txt1.slice(0, 3) + "bar" + txt1.slice(3);
+ //var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text();
+ var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ //console.log(txt);
+ var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt);
+ final_height = final_height + default_cat_height + 25;
+ //console.log(final_height);
+ }
+ /* else if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs != 0) ){//ce je tekst daljsi od 35 znakov, nima breakov, ima pa sliko dodaj <br>
+
+ var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ console.log(txt);
+ var n_img_start = txt.search("<img"); //var n = str.search("W3Schools"); //hrani index, kjer se začne html za sliko
+ var n_img_end = txt.indexOf(">");
+ console.log(n_img_start);
+ console.log(n_img_end);
+ //var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt);
+ //final_height = final_height + default_cat_height + 25;
+ //console.log(final_height);
+
+ } */
+
+
+ if (num_imgs != 0){ // ce imamo sliko
+
+ var img_height = 0;
+ //var max_width = $('.ranking').width();
+ var max_width = 230;
+ var img = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img');
+ var img_width = img.width();
+ //console.log("img_width: "+img_width);
+
+ var img_height = img.height();
+ //console.log("img_height: "+img_height);
+
+ if (img_width > max_width){
+ img_height = (img_height / img_width) * max_width;
+ img.css({width: max_width});
+ img.css({height: img_height});
+ //$('#vre_id_'+vre_id).css({height: height});
+ //console.log("Vecji od max width");
+ }
+
+ //ureditev mobilne različice prikazovanja slik znotraj kategorij odgovorov
+/* if (mobile == 1){ //ce je mobilnik
+ img_height = (img_height / img_width) * 100;
+ img_width = 100;
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').attr('style', 'margin: auto !important'); //dodaj atribut
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').css({'height':img_height,'width':img_width}); //ustrezno spremeni visino in sirino slike
+ } */
+ //ureditev mobilne različice prikazovanja - konec
+
+ //console.log("img_height: "+img_height);
+ if(img_height > 25){ //ce je visina slike vecja od default visine kategorije
+ final_height = final_height + img_height;
+ }
+
+
+
+ //ureditev visine variable_holder, ki je znotraj okvirja !!!!!!!!!!
+ //$('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(final_height + img_height)+'px'});
+ }
+ if(num_of_br != 0){
+ var br_height = num_of_br*25;
+
+ if (num_imgs == 0){
+ final_height = final_height + default_cat_height + br_height;
+ }
+ else{
+ final_height = final_height + br_height;
+ }
+
+
+ //console.log(final_height);
+ if( (img_height < 25) && (img_height != 0) ){
+ final_height = final_height + img_height;
+ }
+ }
+ if (final_height != 0){
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).css({'height':final_height}); //dodaj style atributu še novo višino za levi blok
+ }
+
+}
+//***********************************************************************
+//var cat_total_height_left = 0; //hrani trenutno visino levega okvirja kategorij odgovorov
+//*********funkcija, ki skrbi za delovanje drag and drop grid funkcionalnosti
+function GridDragDropDelovanjeBox(num_grids, indeks, tip, spremenljivka, site_url, ajax, anketa, usr_id, num_of_cats, mobile){
+ //var default_var_height_1 = [];
+
+ //*****za mobilne naprave
+ var top_cat = -1;
+ var left_cat = -1;
+ var default_var_height = 290; //default visina celotnega vprasanja
+ if (mobile == 0 || mobile == 2){
+ top_cat = -6;
+ top_cat_right = 30;
+ left_cat = -6;
+ var default_var_height = 220; //default visina celotnega vprasanja
+ }
+ //*********************
+ //ureditev visine celotnega vprasanja, ce je ta visja od default-a*******************************************************************
+ //var default_var_height = 287; //default visina celotnega vprasanja
+ //var default_var_height = 220; //default visina celotnega vprasanja
+ //var cat_total_height = 0; //hrani trenutno visino celotnega trenutnega vprasanja
+ //var cat_total_height_left = 0; //hrani trenutno visino levega okvirja kategorij odgovorov
+ var cat_margin_left = 10 + 5*2 + 1*2; //hrani rob za ureditev visine levega okvirja = margin_spodnji + padding(spredi pa zadi) + border(spredi pa zadi) + neznanka
+ var cat_max_height = 0; //hrani trenutno najvecjo visino tretnutne kategorije
+ var grid_title_height = 15 + 5*2 + 1*2; //hrani default visino naslovov gridov oz. okvirjev
+ //var cat_default_height = 2 + 10 + 15 + 10; //hrani default visino kategorije odgovora = border + padding + notranja visina + spodnji margin
+ var cat_default_height = 37;
+ var title_heigth = 26; //visina okvricka z naslovom
+ var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').height(); //visina naslova vprasanja (besedila vprasanja)
+ var margin_now = 10; //rob po vsakem okvirju
+ var cat_default_inline_text_length = 16; //default dolzina teksta v eni vrstici kategorij odgovorov
+ //console.log("naslov_height: "+naslov_height);
+
+ //ureditev visine puscice med blokoma okvirjev
+ //var top = $('#spremenljivka_'+spremenljivka+' td.middle img').css('top');
+ var variable_holder_height = $('#spremenljivka_'+spremenljivka+' .variable_holder').height(); //visina variable_holder, potrebna za visino puscice med blokoma
+ //$('#spremenljivka_'+spremenljivka+' td.middle img').css({'top' : (naslov_height + 200) + 'px'});
+ $('#spremenljivka_'+spremenljivka+' td.middle img').css({'top' : (naslov_height + variable_holder_height/2) + 'px'}); //visina puscice med blokoma okvirjev
+
+ if (ajax){
+ //console.log('Getting data on load');
+ $.get(site_url+'/main/survey/ajax.php?a=get_dragdrop1_data', {spremenljivka: spremenljivka, anketa: anketa}, function(data){ //get potrebnih podatkov za resevanje missing
+ //trenutna visina celotnega vprasanja
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ //console.log("default_var_height: "+default_var_height + " indeks: "+indeks+" num of grids: "+num_grids);
+
+ if(indeks == 1){//samo enkrat pojdi skozi leve kategorije odgovorov
+ //if(indeks == num_grids || indeks == num_grids-1 ){
+/* //trenutna visina celotnega vprasanja@indeks = 1
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height());
+ console.log("default_var_height @ indeks = 1: "+default_var_height); */
+ var cat_total_height_left = 0; //hrani trenutno visino levega okvirja kategorij odgovorov
+ var array_length = data.length; //hrani koliko podatkov je prisotnih v polju s podatki iz baze
+ var vre_id = []; //polje, ki hrani id-je vrednosti vseh kategorij odgovorov interesirane spremenljivke
+ //var cat_total_height = 0; //hrani trenutno visino celotnega trenutnega vprasanja
+ var cat_margin = 30;
+
+ //console.log(array_length); //prikazi koliko podatkov je prisotnih v polju s podatki iz baze
+ for(var i = 0; i < array_length; i++){ //sprehodi se po vseh vrednostih polja vre_id v levem bloku
+ vre_id[i] = data[i]; //polje iz podatkov iz baze data[], shrani v polje vre_id[]
+
+ //var cat_height_px = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).css('height'); //visina kategorije z oznako px
+ //var cat_height = cat_height_px.replace('px',''); //hrani string z visino, kjer odstranimo "px"
+ var cat_height = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).height(); //visina kategorije
+ cat_height = parseInt(cat_height); //sprememba stringa s samo visino brez oznake "px" v stevilo
+
+ //console.log('Visina '+(i + 1)+': '+cat_height+' + '+cat_margin_left);
+ //cat_total_height = cat_total_height + cat_height + cat_margin; //izracun koncne visine vprasanja
+
+ if(mobile == 1){ //ko je mobilnik, uredi velikost okvirja kategorije glede na dolzino besedila
+ var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).text().length; //dolzina teksta v kategoriji odgovora
+
+ if(cat_text_length > (cat_default_inline_text_length)*2 ){ //ce je dolzina teksta v kategoriji daljsa 2-krat vec od default (16)
+ //console.log("Tekst je daljši!");
+ //console.log("Dolžina besedila v kategoriji: "+cat_text_length);
+ var num_of_rows = cat_text_length / cat_default_inline_text_length;
+ //console.log("num_of_rows: "+num_of_rows);
+ cat_height = cat_height + 25 * (num_of_rows - 1); //trenutno visino kategorije povecaj za 25
+ //console.log("num_of_rows final: "+ (num_of_rows - 1));
+ //console.log("cat_height: "+cat_height);
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id[i]).css({'height':(cat_height)+'px'}); //spremeni visino kategorije
+ }
+ }
+
+ cat_total_height_left = cat_total_height_left + cat_height + cat_margin_left; //izracun koncne visine levega okvirja
+
+ //console.log('Total left: '+cat_total_height_left);
+
+
+ if (cat_max_height < cat_height){ //ce je maksimalna visina kategorije manjsa od trenutne visine kategorije
+ cat_max_height = cat_height; //naj bo vrednost max visine kategorije trenutna visina kategorije
+ }
+
+
+ }
+ //console.log('Total left: '+cat_total_height_left);
+
+ //*************urejanje visine levega okvirja kategorij odgovorov
+ $('#half_frame_dropping_'+spremenljivka).css({'height':(cat_total_height_left)+'px'});//visina levega okvirja
+ }
+
+
+
+ if(indeks == 1){ //samo enkrat pojdi skozi desne okvirje
+ //if(indeks == num_grids-1 ){
+ for(var j = 1; j <= num_grids; j++){ //preglej vse desne okvirje v desnem bloku
+ //notranja visina trenutnega okvirja***************************************
+ //var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).css('height');
+ //okvir_height = parseInt(okvir_height.replace('px',''));
+ var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).height();
+
+ okvir_height = okvir_height + 10 + 2; //notranja visina + padding + border
+ //console.log('Visina desnega okvirja'+j+' : '+okvir_height);
+ frame_total_height_right[spremenljivka] = frame_total_height_right[spremenljivka] + okvir_height + margin_now + title_heigth;
+ //console.log('Koncna visina desnega bloka: '+frame_total_height_right[spremenljivka]);
+ }
+ //console.log("Desni blok visok ob indeksu 1: "+frame_total_height_right[spremenljivka]);
+ }
+
+
+ default_var_height_1[spremenljivka] = $('#spremenljivka_'+spremenljivka).height(); //belezenje celotne zacetne visine spremenljivke
+ //default_var_height_1[spremenljivka] = $('#spremenljivka_'+spremenljivka).css('height');
+
+ if(cat_total_height_left > frame_total_height_right[spremenljivka]){ //ce je trenutna visina levega okvirja z odgovori vecja od koncne visine desnega okvirja
+ //console.log("Levi okvir vecji od desnega");
+ //console.log("Levi visok: "+cat_total_height_left);
+ //console.log('Zacetna visina celotne spremenljivke: '+default_var_height_1[spremenljivka]);
+ //ce je koncna visina levega okvirja vecja od default visine celotnega vprasanja
+ //if( (cat_total_height_left > default_var_height) && (data_after_refresh[spremenljivka] == false) ){
+ if( (cat_total_height_left > default_var_height) ){ //ce je koncna visina levega okvirja z odgovori vecja od visine celotnega vprasanja
+ dynamic_question_height_sub(cat_total_height_left, spremenljivka, default_var_height_1[spremenljivka]); //ustrezno spremeni vesino celotnega vprasanja
+ }else if(cat_total_height_left < default_var_height_1[spremenljivka]){ //ce je koncna visina levega okvirja z odgovori manjsi od visine celotnega vprasanja
+ //console.log("default_var_height_1: "+default_var_height_1[spremenljivka]);
+ dynamic_question_height_sub(cat_total_height_left, spremenljivka, default_var_height_1[spremenljivka]); //ustrezno spremeni vesino celotnega vprasanja
+ } else{
+ //console.log("Tale druga pot");
+ dynamic_question_height_sub(cat_total_height_left, spremenljivka, default_var_height_1[spremenljivka]);//ustrezno spremeni vesino celotnega vprasanja
+ }
+ //default_var_height_1[spremenljivka] = $('#spremenljivka_'+spremenljivka).css('height'); //belezenje celotne zacetne visine spremenljivke
+ //console.log('Zacetna visina celotne spremenljivke: '+default_var_height_1[spremenljivka]);
+
+
+ //data_after_refresh[spremenljivka] == 0;
+ //console.log(cat_total_height_left);
+ //ce je trenutna visina levega okvirja z odgovori manjsa od koncne visine desnega okvirja
+ }else if(cat_total_height_left < frame_total_height_right[spremenljivka]){
+ //console.log("Levi okvir manjsi od desnega");
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(frame_total_height_right[spremenljivka] + 50);
+ frame_total_height_right[spremenljivka] = frame_total_height_right[spremenljivka] + naslov_height;
+ //console.log("Desni blok visok ob indeksu 1 povečan za naslov: "+frame_total_height_right[spremenljivka]);
+ //frame_total_height_right[spremenljivka] = frame_total_height_right[spremenljivka] + naslov_height;
+ $('#spremenljivka_'+spremenljivka).height(frame_total_height_right[spremenljivka] + 50);
+ //dynamic_question_height_sub(frame_total_height_right[spremenljivka], spremenljivka);
+ }
+
+ }, "json");
+ }
+
+ //default_var_height_1[spremenljivka] = $('#spremenljivka_'+spremenljivka).css('height'); //belezenje celotne zacetne visine spremenljivke
+
+ //************************ konec - ureditev visine celotnega vprasanja, ce je ta visja od default-a
+
+ //console.log("Grid delovanje: "+num_grids);
+
+ $('#half_frame_dropping_'+spremenljivka)
+ .droppable({
+ hoverClass: 'frame_dropping_hover',
+ drop: function (event, ui) {
+ checkBranching();
+
+ //$(ui.draggable).detach().css({top: -6,left: -6}).appendTo(this);
+ $(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this);
+ var vre_id = ui.draggable.attr('value');
+
+ if (ajax && tip == 6){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data_1', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa, indeks: last_indeks[spremenljivka]}); //post-aj potrebne podatke za brisanje
+ //}
+ draggableOnDroppable[vre_id][last_indeks[spremenljivka]] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ draggableOverDroppable[vre_id][last_indeks[spremenljivka]] = false;
+ //console.log('draggableOverDroppable['+vre_id+']['+last_indeks[spremenljivka]+']: '+draggableOverDroppable[vre_id][last_indeks[spremenljivka]])
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ if(prejsnji_okvir_kat_prisotna === undefined && last_indeks[spremenljivka] != 0){
+ //console.log("Levi frame last frame func");
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable); //spremeni visino zadnje obiskanega okvirja
+ }
+ dynamic_question_height(spremenljivka, num_grids);
+ last_indeks[spremenljivka] = 0;
+ last_drop[vre_id] = 0;
+ last_vre_id[spremenljivka] = 0;
+
+ }
+ from_left[vre_id] = true;
+/* var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ default_var_height_1[spremenljivka] = default_var_height; */
+ },
+ out: function (event, ui) { //ob izhodu iz drop zone
+ //answer_coming[spremenljivka] = true;
+ //var vre_id = ui.draggable.attr('value');
+ //console.log("from_left["+vre_id+"]: "+from_left[vre_id]);
+ },
+ over: function (event, ui) {
+ var vre_id = ui.draggable.attr('value');
+ //potrebno pridobiti informacijo ze tukaj, ker drugace so tezave @ revert v levi okvir
+ vre_id_global[spremenljivka] = vre_id;
+ draggable_global[vre_id] = ui.draggable;
+ }
+ });
+
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka)
+ .droppable({
+ //hoverClass: 'frame_ranking_hover',
+ hoverClass: 'frame_dropping_hover',
+ tolerance: "pointer",
+ //accept: '#half_'+spremenljivka+' div',
+ drop: function (event, ui) { //ob dropanju odgovora v desni blok
+ checkBranching();
+
+ if(mobile == 0 || mobile == 2){
+ //$(this).toggleClass('frame_dropping_wider'); //spremeni videz trenutnega okvirja
+ }else if(mobile == 1){
+ //$(this).toggleClass('frame_dropping_wider_mobile'); //spremeni videz trenutnega okvirja
+ }
+
+
+ num_grids = num_grids_global[spremenljivka];
+ //console.log("Drop");
+ var vre_id = ui.draggable.attr('value');
+ var other = ui.draggable.attr('missing'); //spremenljivka, ki hrani vrednost atributa missing
+ var other_present = $(this).children('div').attr('missing'); //missing, ki je trenutno v desnem bloku
+ //var cat_right = $(this).children('div').css('height'); //ali je prisotna kaksna kategorija v trenuntem desnem okvirju? Undefined = ne
+ var cat_right = $(this).children('div').height(); //ali je prisotna kaksna kategorija v trenuntem desnem okvirju? Undefined = ne
+ //var cat_right = $(this).children('div').outerHeight(); //ali je prisotna kaksna kategorija v trenuntem desnem okvirju? Undefined = ne
+ var vre_id_present = $(this).children('div').attr('value'); //vre_id kategorije odgovora, ki je prisotna v okvirju ob dropu
+ //var draggable_global[spremenljivka] = ui.draggable;
+ draggable_global[vre_id] = ui.draggable;
+
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ var title_heigth = 26; //visina okvricka z naslovom
+ var margin_now = 10; //rob po vsakem okvirju
+ var height_beside = 40; //visina od zacetka vprasanja do prvega okvirja (in malo po zadnjem okvirju)
+ var final_height_right_block = 0; //hrani koncno visino desnega bloka, torej vseh prisotnih okvirjev
+ final_height_right_block = final_height_right_block + height_beside; //koncni visini dodamo se "praznino" med zacetkom vprasanja in prvim okvirjem
+
+ for(var j = 1; j <= num_grids; j++){ //preglej vse okvirje
+ //notranja visina trenutnega okvirja***************************************
+ //var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).css('height');
+ //okvir_height = parseInt(okvir_height.replace('px',''));
+ var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).height();
+ //console.log('Visina '+j+' : '+okvir_height);
+ okvir_height = okvir_height + 10 + 2; //notranja visina + padding + border
+ //*************************************************************************
+ final_height_right_block = final_height_right_block + okvir_height + margin_now + title_heigth;
+ //console.log('Koncna visina desnega bloka: '+final_height_right_block);
+ }
+
+ //trenutna visina celotnega vprasanja
+ //var default_var_height = $('#spremenljivka_'+spremenljivka).css('height');
+ //default_var_height = parseInt(default_var_height.replace('px',''));
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ //console.log('Default: '+default_var_height);
+ //console.log('Final: '+final_height_right_block);
+ if(final_height_right_block > default_var_height){
+ $('#spremenljivka_'+spremenljivka).css({'height':final_height_right_block+'px'});
+ //da ne bo pri mobilnikih prevec skrito vprasanje
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(final_height_right_block - 100)+'px'});
+
+ }
+ //************************************ konec - dinamicna visina celotnega vprasanja glede na visino prenesenih desnih okvirjev
+
+
+ //$(ui.draggable).detach().css({top: -6,left: -6}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto
+ //$(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto
+
+ //ce je tabela - en odgovor
+ if(tip == 6){
+ //$(ui.draggable).detach().css({top: top_cat,left: left_cat}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto
+ //$(ui.draggable).detach().css({top: 30, left:-6}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto
+ if (cat_right){ //ce je ze nekaj v okvirju
+ //$(ui.draggable).detach().css({top: (top_cat_right + cat_right), left:-6}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto tako, da je nad prejsnjim
+ $(ui.draggable).detach().css({top: (top_cat_right), left:-6}).prependTo(this); //pozicioniraj kategorijo odgovora na pravo mesto tako, da je nad prejsnjim
+ }else{
+ $(ui.draggable).detach().css({top: top_cat_right, left:-6}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto
+ }
+
+
+/* if(cat_right == null){
+ $(ui.draggable).detach().css({top: ui.draggable.height(),left: left_cat}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto
+ }
+ $(ui.draggable).css({margin: '10px auto 0px auto'}); */
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=accept_dragdrop_grid', {vre_id_present: vre_id_present, tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, anketa: anketa, usr_id: usr_id, indeks: indeks, cat_right: cat_right, last_vre_id: last_vre_id[spremenljivka]}); //post-aj potrebne podatke za belezenje v bazo
+ if(last_drop[vre_id] != indeks || last_drop[vre_id] != 0){
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data_1', {spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa, indeks: last_drop[vre_id]}); //post-aj potrebne podatke za brisanje
+ }
+ }
+ }
+ else if(tip == 16 && draggableOnDroppable[vre_id][indeks] == false){ //ce je tabela - vec odgovorov in odgovora ni v trenutnem okvirju, uredi clone
+ var visina_test = ui.draggable.css('height');
+ //$(ui.draggable.clone()).detach().css({top: top_cat,left: left_cat, height: visina_test}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto in dodaj ustrezno visino
+ $(ui.draggable.clone()).detach().css({top: top_cat_right, left: left_cat, height: visina_test}).prependTo(this); //pozicioniraj kategorijo odgovora na pravo mesto in dodaj ustrezno visino
+ //$(ui.draggable).detach().css({top: 10,left: 10}).appendTo(this); //pozicioniraj kategorijo odgovora na pravo mesto
+ if (ajax){
+ $.post(site_url+'/main/survey/ajax.php?a=accept_dragdrop_grid', {vre_id_present: vre_id_present, tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, anketa: anketa, usr_id: usr_id, indeks: indeks, cat_right: cat_right, last_vre_id: last_vre_id[spremenljivka]}); //post-aj potrebne podatke za belezenje v bazo
+ }
+ }
+
+ if(last_indeks[spremenljivka] !== undefined){
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ //console.log("last_indeks[spremenljivka][indeks]: "+last_indeks[spremenljivka][indeks]);
+ if(last_indeks[spremenljivka] == 0 || prejsnji_okvir_kat_prisotna === undefined){
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable); //spremeni visino zadnje obiskanega okvirja
+ }
+ }
+
+ last_drop[vre_id] = indeks; //zabelezi indeks okvirja zadnjega drop-a
+ draggableOnDroppable[vre_id][indeks] = true; //oznacimo, da je trenutna kategorija odgovora v okvirju
+ if(tip == 6){
+ from_left[vre_id] = false;
+ }
+ },
+ over: function (event, ui) { //ob prenosu trenutne kategorije odgovora nad okvirjem
+ num_grids = num_grids_global[spremenljivka];
+ checkBranching();
+ var vre_id = ui.draggable.attr('value');
+ var vre_id_present = $(this).children('div').attr('value'); //vre_id kategorije odgovora, ki je prisotna v okvirju ob dropu
+ vre_id_global[spremenljivka] = vre_id;
+ var trenutni_okvir = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka);
+ //console.log("from_left["+vre_id+"]: "+from_left[vre_id]);
+
+ if (last_indeks[spremenljivka] == 0 && tip == 6){ //ce prenasamo kategorije odgovora iz levega okvirja
+ last_indeks[spremenljivka] = indeks; //zabelezi indeks prejsnjega okvirja
+
+ }else {
+
+ var last_vrednost_id_temp = last_vre_id[spremenljivka];
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+
+ //if(tip == 16 || tip == 6){
+ if(tip == 6){
+ var prejsnji_okvir_kat_prisotna = [];
+ var stevilo_prisotnih = prejsnji_okvir.children('div').length;
+ //console.log(stevilo_prisotnih);
+ for(var z = 1; z <= stevilo_prisotnih; z++){
+ //prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ prejsnji_okvir_kat_prisotna[z] = prejsnji_okvir.children('div :nth-child('+z+')').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju, kateri odgovori so prisotni
+ //console.log("prejsnji_okvir_kat_prisotna["+z+"]: "+prejsnji_okvir_kat_prisotna[z]);
+
+ if(last_vrednost_id_temp != 0){
+ //ce v prejsnjem okvirju ni nicesar in (v prejsnjem okvirju ni nicesar ali je identifikacija ista trenutni)
+ if( (draggableOnDroppable[last_vrednost_id_temp][indeks] == false) && ( (prejsnji_okvir_kat_prisotna === undefined) || (prejsnji_okvir_kat_prisotna == vre_id) ) ){
+ if ( (tip == 16 && draggableOnDroppable[vre_id][last_indeks[spremenljivka]] == false) || tip == 6 ){
+ //spremeni visino prejsnjega okvirja
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable);
+ //console.log("Spreminjam prejsnji okvir");
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ if(vre_id_present !== undefined){
+ //ce ni se nicesar v trenutnem okvirju, ali odgovor je na poti v okvir in je vprasanje tipa 16 (tabela - vec odgovorov) ali 6 (tabela - en odgovor)
+ if (draggableOnDroppable[vre_id_present][indeks] != true || (draggableOverDroppable[vre_id][indeks] == false && (tip == 16 || tip == 6) ) ){
+ //zabelezi, da je odgovor nad okvirjem
+ draggableOverDroppable[vre_id][indeks] = true;
+ if ((tip == 16 && draggableOnDroppable[vre_id][indeks] == false) || tip == 6){
+ //uredi visino okvirja in celotnega vprasanja
+ frame_and_question_height(trenutni_okvir, spremenljivka, num_grids, cat_margin_left, cat_default_height, ui.draggable);
+ if(from_left[vre_id] != false){
+ dynamic_question_height(spremenljivka, num_grids);
+ }
+
+ //console.log("Tukaj 1");
+ }
+ }
+ }else{
+
+ if (vre_id_present === undefined || (draggableOverDroppable[vre_id][indeks] == false && (tip == 16 || tip == 6) ) ){
+ //zabelezi, da je odgovor nad okvirjem
+ draggableOverDroppable[vre_id][indeks] = true;
+ if ( (tip == 16 && (draggableOnDroppable[vre_id][indeks] == false || last_drop[vre_id] == 0 )) || tip == 6){
+ //uredi visino okvirja in celotnega vprasanja
+ frame_and_question_height(trenutni_okvir, spremenljivka, num_grids, cat_margin_left, cat_default_height, ui.draggable);
+ if(from_left[vre_id] != false){
+ dynamic_question_height(spremenljivka, num_grids);
+ }
+ //console.log("Tukaj 2");
+ }
+ }
+ }
+
+ //spremeni videz trenutnega okvirja
+ if(draggableOverDroppable[vre_id][indeks] == true){
+ if(mobile == 0 || mobile == 2){
+ //$(this).toggleClass('frame_dropping_wider');
+ }
+ else if(mobile == 1){
+ //$(this).toggleClass('frame_dropping_wider_mobile');
+ }
+ }
+
+ last_indeks[spremenljivka] = indeks; //zabelezi indeks (trenutnega oz. bodocega) prejsnjega okvirja
+ cat_pushed[spremenljivka] = false;
+ },
+ out: function (event, ui) { //ob izhodu iz drop zone
+ num_grids = num_grids_global[spremenljivka];
+ var vre_id = ui.draggable.attr('value');
+ var vre_id_present = $(this).children('div').attr('value'); //vre_id kategorije odgovora, ki je prisotna v okvirju ob dropu
+ var prejsnji_okvir = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka);
+ var prejsnji_okvir_kat_prisotna = prejsnji_okvir.children('div').attr('value'); //belezi, ce je kaj prisotnega v prejsnjem okvirju
+ //console.log("Out");
+ //draggableOnDroppable[vre_id] = false; //oznacimo, da smo tretnutno kategorijo odgovora odstranili iz okvirja
+
+
+ //if(draggableOverDroppable[vre_id] == true && tip == 16){
+ if(draggableOverDroppable[vre_id][indeks] == true && ( (tip == 16 && draggableOnDroppable[vre_id][last_indeks[spremenljivka]] == false) || tip == 6) ){
+ //console.log("Last frame out pri indeksu: "+last_indeks[spremenljivka]);
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, ui.draggable);
+ }
+ last_vre_id[spremenljivka] = vre_id;
+ last_indeks[spremenljivka] = indeks;
+ if( tip == 6 || (tip == 16 && draggableOnDroppable[vre_id][last_indeks[spremenljivka]] == false) ){
+ draggableOnDroppable[vre_id][indeks] = false; //oznacimo, da trenutne kategorije odgovora ni v okvirju
+ }
+ draggableOverDroppable[vre_id][indeks] = false;
+ draggable_global[vre_id] = ui.draggable;
+
+ //spremeni videz prejsnjega okvirja
+ if(draggableOverDroppable[vre_id][indeks] == false){
+ if(mobile == 0 || mobile == 2){
+ //prejsnji_okvir.toggleClass('frame_dropping_wider');
+ }else if(mobile == 1){
+ //prejsnji_okvir.toggleClass('frame_dropping_wider_mobile');
+ }
+ }
+
+ }
+ });
+
+ //********************** odstranitev odgovorov iz desnih okvirjev @ tabela - vec odgovorov
+ // ce je tabela - vec odgovorov
+ if(tip == 16){ //uredi odstranjevanje kategorij odgovorov iz desnega okvirja ob kliku na njih
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka).click(function(){
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka).children().click(function(){ //ob kliku na kategorijo odgovora
+
+ var index1 = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka).children().index(this); //indeks klikanega odgovora
+ var prejsnji_okvir = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka); //
+ var vre_id = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka+' div:nth-child('+(index1 + 1)+')').attr('value');
+ var draggable = $('#half2_frame_dropping_'+indeks+'_'+spremenljivka+' div:nth-child('+(index1 + 1)+')');
+
+ $('#half2_frame_dropping_'+indeks+'_'+spremenljivka+' div:nth-child('+(index1 + 1)+')').detach();//odstrani odgovor iz okvirja
+
+ if (ajax){ //odstrani podatek o odgovoru iz baze
+ $.post(site_url+'/main/survey/ajax.php?a=delete_dragdrop_grid_data', {tip: tip, spremenljivka: spremenljivka, vre_id: vre_id, usr_id: usr_id, anketa: anketa, indeks: indeks}); //post-aj potrebne podatke za brisanje
+ }
+ console.log(draggableOnDroppable[vre_id][indeks]);
+ last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, draggable); //spremeni visino zadnje obiskanega okvirja
+ draggableOnDroppable[vre_id][indeks] = false; //oznacimo, da smo trenutno kategorijo odgovora odstranili iz okvirja
+ //console.log("draggableOnDroppable["+vre_id+"]["+indeks+"]: "+draggableOnDroppable[vre_id][indeks]);
+ draggableOverDroppable[vre_id][indeks] = false;
+ from_left[vre_id] = true;
+ dynamic_question_height(spremenljivka, num_grids);
+ //console.log("vre_id: "+vre_id);
+ });
+
+ });
+
+ }
+ //********************** konec - odstranitev odgovorov iz desnih okvirjev @ tabela - vec odgovorov
+}
+//**************************************************************************************
+
+function frame_and_question_height(trenutni_okvir, spremenljivka, num_grids, cat_margin_left, cat_default_height, draggable){
+ //console.log('Frame and question height');
+ //uredi visino okvirja in celotnega vprasanja
+ var other = draggable.attr('missing'); //spremenljivka, ki hrani vrednost atributa missing
+ var other_present = trenutni_okvir.children('div').attr('missing'); //missing, ki je trenutno v desnem bloku
+
+ //***************** glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+ //visina trenutno prenesenega odgovora*************
+ //var cat_height_px_now = draggable.css('height'); //visina kategorije z oznako px
+ //var cat_height_now = cat_height_px_now.replace('px',''); //hrani string z visino, kjer odstranimo "px"
+ var cat_height_now = draggable.height(); //visina kategorije
+ //cat_height_now = parseInt(cat_height_now); //sprememba stringa s samo visino brez oznake "px" v stevilo
+ //*************************************************visina trenutno prenesenega odgovora - konec
+
+ //cat_height_now = cat_height_now + cat_margin_left; //izracun koncne visine desnega okvirja
+ //cat_height_now = cat_height_now + cat_default_height; //izracun koncne visine desnega okvirja
+ //console.log(cat_height_now);
+
+ //var cat_right = trenutni_okvir.children('div').css('height');//belezi visino kategorije odgovora, ce je ta prisotna v trenutnem desnem okvirju
+ var cat_right = trenutni_okvir.children('div').height();//belezi visino kategorije odgovora, ce je ta prisotna v trenutnem desnem okvirju
+
+ //ce je v trenutnem desnem okvirju ze prisotna kategorija odgovora, trenutni visini okvirja dodaj se visino trenutne kategorije
+ if(cat_right){
+ //console.log('Ima children');
+ //var whole_heigth = trenutni_okvir.css('height');
+ //whole_heigth = whole_heigth.replace('px','');
+ var whole_heigth = trenutni_okvir.height();
+ //console.log(whole_heigth);
+ cat_height_now = cat_height_now + cat_margin_left; //izracun koncne visine desnega okvirja, ce imamo ze kategorije v okvirju
+ //var okvir_height = parseInt(whole_heigth) + parseInt(cat_height_now);
+ var okvir_height = whole_heigth + cat_height_now;
+ trenutni_okvir.css({'height':(okvir_height)+'px'}); //visina desnega okvirja
+ //console.log('Koncna visina: '+(okvir_height));
+ }else{ //drugace
+ cat_height_now = cat_height_now + cat_default_height; //izracun koncne visine desnega okvirja, ce ni kategorij v okvirju
+ if (cat_height_now < 15){ //ce je visina trenutne kategorije odgovova manjsa od 15, prej 20
+ cat_height_now = 15; //naj bo visina okvirja 15px, prej 20px
+ }
+ trenutni_okvir.css({'height':(cat_height_now)+'px'}); //visina trenutnega desnega okvirja
+ //console.log('Koncna visina: '+(cat_height_now));
+ }
+ //************************************ konec - glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ //trenutna visina celotnega vprasanja
+ //var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ //var default_var_height = 1;
+ //dynamic_question_height(spremenljivka, num_grids, default_var_height);
+ //************************************ konec - dinamicna visina celotnega vprasanja glede na visino prenesenih desnih okvirjev
+}
+
+//funkcija za urejanje visine okvirjev
+function frame_height(spremenljivka, vre_id, grd_id, revert){
+
+ //***************** glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+ //visina trenutno prenesenega odgovora*************
+ var cat_default_height = 37;
+ //var cat_height_px_now = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).css('height'); //visina trenutne kategorije odgovora
+ //var cat_height_now = cat_height_px_now.replace('px',''); //hrani string z visino, kjer odstranimo "px"
+ var cat_height_now = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).height(); //visina trenutne kategorije odgovora
+ //cat_height_now = parseInt(cat_height_now); //sprememba stringa s samo visino brez oznake "px" v stevilo
+ //*************************************************visina trenutno prenesenega odgovora - konec
+ //console.log("Frame height");
+ //console.log("cat_height_now: "+cat_height_now);
+ //console.log("spremenljivka: "+spremenljivka);
+ //console.log("vre_id: "+vre_id);
+
+ //cat_height_now = cat_height_now + cat_margin_left; //izracun koncne visine desnega okvirja
+ //cat_height_now = cat_height_now + cat_default_height; //izracun koncne visine desnega okvirja
+ //console.log(cat_height_now);
+
+ //var cat_right = $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).children('div').css('height');//belezi visino kategorije odgovora, ce je ta prisotna v trenutnem desnem okvirju
+ var cat_right = $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).children('div').height();//belezi visino kategorije odgovora, ce je ta prisotna v trenutnem desnem okvirju
+
+ //ce je v trenutnem desnem okvirju ze prisotna kategorija odgovora, trenutni visini okvirja dodaj se visino trenutne kategorije
+ if(cat_right || revert){
+ //console.log('Ima children');
+ //var whole_heigth = $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).css('height');
+ //whole_heigth = whole_heigth.replace('px','');
+ var whole_heigth = $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).height();
+ //console.log(whole_heigth);
+ cat_height_now = cat_height_now + cat_margin_left; //izracun koncne visine desnega okvirja, ce imamo ze kategorije v okvirju
+ var okvir_height = parseInt(whole_heigth) + parseInt(cat_height_now);
+ $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).css({'height':(okvir_height)+'px'}); //visina desnega okvirja
+ //console.log('Koncna visina: '+(okvir_height));
+
+ }else{ //drugace
+ cat_height_now = cat_height_now + cat_default_height; //izracun koncne visine desnega okvirja, ce ni kategorij v okvirju
+ if (cat_height_now < 15){ //ce je visina trenutne kategorije odgovova manjsa od 15, prej 20
+ cat_height_now = 15; //naj bo visina okvirja 15px, prej 20px
+ }
+ $('#half2_frame_dropping_'+grd_id+'_'+spremenljivka).css({'height':(cat_height_now)+'px'}); //visina trenutnega desnega okvirja
+ //console.log('Koncna visina okvirja z odgovorom: '+(cat_height_now));
+ }
+ //************************************ konec - glede na visino trenutno prenesenih kategorij odgovora, povecaj visino okvirja
+
+ //console.log("cat_height_now ["+vre_id+"]: "+cat_height_now);
+}
+//************** konec - funkcije za urejanje visine okvirjev
+
+//***************funkcija za urejanje visine zadnje obiskanega okvirja @ drag and drop
+function last_frame_height(prejsnji_okvir, spremenljivka, num_grids, cat_margin_left, draggable){
+ //console.log('last_frame_height: '+prejsnji_okvir.children('div').attr('value'));
+ //console.log("num_grids v last frame: "+num_grids);
+ //console.log('last_frame_height ');
+ //****glede na odstrajeno kategorijo odgovora, trenutni visini okvirja odstrani visino odstranjene kategorije
+ //var trenutna_visina_okvirja = $('#half2_frame_dropping_'+last_indeks[spremenljivka]+'_'+spremenljivka).css('height');
+ //var trenutna_visina_okvirja = prejsnji_okvir.css('height');
+ var trenutna_visina_okvirja = prejsnji_okvir.height();
+ //console.log("trenutna_visina_okvirja: "+trenutna_visina_okvirja);
+ //var trenutna_visina_kategorije = draggable.css('height')//visina odnesene kategorije odgovora
+ var trenutna_visina_kategorije = draggable.height();//visina odnesene kategorije odgovora
+ //trenutna_visina_okvirja = trenutna_visina_okvirja.replace('px','');
+ //trenutna_visina_kategorije = trenutna_visina_kategorije.replace('px','');
+ //koncna_visina_zapuscenega_okvirja = parseInt(trenutna_visina_okvirja) - parseInt(trenutna_visina_kategorije) - cat_margin_left;
+ koncna_visina_zapuscenega_okvirja = trenutna_visina_okvirja - trenutna_visina_kategorije - cat_margin_left;
+
+ if (koncna_visina_zapuscenega_okvirja < 15){
+ koncna_visina_zapuscenega_okvirja = 15;
+ }
+
+ prejsnji_okvir.css({'height':(koncna_visina_zapuscenega_okvirja)+'px'}); //visina desnega okvirja
+
+
+ //var default_var_height = default_var_height_1[spremenljivka];
+ //console.log(default_var_height);
+ //$('#spremenljivka_'+spremenljivka).css({'height':(default_var_height - koncna_visina_zapuscenega_okvirja + 50)+'px'});
+ //****** konec - glede na odstrajeno kategorijo odgovora, trenutni visini okvirja odstrani visino odstranjene kategorije
+
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ //var default_height_no_px = default_var_height_1[spremenljivka];
+ //var default_height_no_px = 0;
+
+ //dynamic_question_height(spremenljivka, num_grids);
+ //dynamic_question_height(spremenljivka, num_grids, default_height_no_px);
+
+ //************************************ konec - dinamicna visina celotnega vprasanja glede na visino prenesenih desnih okvirjev
+}
+//*************** konec - funkcija za urejanje visine zadnje obiskanega okvirja
+
+//********* funkcija, ki skrbi za koncno ureditev visine celotnega vprasanja glede na visino (levega ali desnega) bloka @ drag and drop
+//function dynamic_question_height_sub(frame_height, spremenljivka, default_height_no_px){
+function dynamic_question_height_sub(frame_height, spremenljivka){
+ //var default_height_no_px = default_var_height_1[spremenljivka];
+
+ //console.log("default_height_no_px before: "+default_height_no_px);
+ //default_var_height_1[spremenljivka] = $('#spremenljivka_'+spremenljivka).css('height');
+ //default_height_no_px = parseInt(default_height_no_px.replace('px',''));
+
+ default_height_no_px = $('#spremenljivka_'+spremenljivka).height();
+
+ var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').height();
+ //console.log("default_height_no_px dyn: "+default_height_no_px);
+ //console.log("tallest frame_height: "+frame_height);
+ //console.log("Dynamic question height sub");
+
+ if( (frame_height + naslov_height) > default_height_no_px){ //ce je koncna visina desnega dela z okvirji vecji od trenutne default visine celotnega vprasanja
+ $('#spremenljivka_'+spremenljivka).height(frame_height + naslov_height + 50);
+ //console.log("Spreminjam 1");
+ //da ne bo pri mobilnikih prevec skrito vprasanje, spremeni visino variable_holder
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(frame_height + 25);
+ }else if((frame_height + naslov_height) < default_height_no_px){ //ce je koncna visina desnega dela z okvirji manjsi od trenutne default visine celotnega vprasanja
+ //$('#spremenljivka_'+spremenljivka).css({'height':(default_height_no_px + 50)+'px'});
+ $('#spremenljivka_'+spremenljivka).height(default_height_no_px + 50);
+ //console.log("Spreminjam 2");
+ //da ne bo pri mobilnikih prevec skrito vprasanje, spremeni visino variable_holder
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(default_height_no_px - naslov_height + 25);
+
+ }
+}
+
+//*********** @ drag and drop
+//function dynamic_question_height(spremenljivka, num_grids, default_height_flag){
+function dynamic_question_height(spremenljivka, num_grids){
+ //*******************dinamicna visina celotnega vprasanja glede na vsebino prenesenih desnih okvirjev
+ var naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').height();
+ var title_heigth = 26; //visina okvricka z naslovom
+ var margin_now = 10; //rob po vsakem okvirju
+ var height_beside = 40; //visina od zacetka vprasanja do prvega okvirja (in malo po zadnjem okvirju)
+ var final_height_right_block = 0; //hrani koncno visino desnega bloka, torej vseh prisotnih okvirjev
+ final_height_right_block = final_height_right_block + height_beside; //koncni visini dodamo se "praznino" med zacetkom vprasanja in prvim okvirjem
+
+ //var frame_height_left = $('#half_frame_dropping_'+spremenljivka).css('height'); //visina celotnega levega okvirja
+ //frame_height_left = parseInt(frame_height_left.replace('px',''));
+ var frame_height_left = $('#half_frame_dropping_'+spremenljivka).height(); //visina celotnega levega okvirja
+ frame_height_left= frame_height_left + 10 + 2; //notranja visina + padding + border
+ frame_height_left = frame_height_left + height_beside;
+ //console.log('Koncna visina levega bloka: '+frame_height_left);
+
+ for(var j = 1; j <= num_grids; j++){ //preglej vse okvirje
+ //notranja visina trenutnega okvirja***************************************
+ //var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).css('height');
+ var okvir_height = $('#half2_frame_dropping_'+j+'_'+spremenljivka).height();
+ //okvir_height = parseInt(okvir_height.replace('px',''));
+ //console.log('Visina '+j+' : '+okvir_height);
+ okvir_height = okvir_height + 10 + 2; //notranja visina + padding + border
+
+ final_height_right_block = final_height_right_block + okvir_height + margin_now + title_heigth;
+ //console.log('Koncna visina desnega bloka: '+final_height_right_block);
+ }
+ //console.log('Koncna visina desnega bloka: '+final_height_right_block);
+ /* if (default_height_flag == 1){
+ //trenutna visina celotnega vprasanja
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+ }else if(default_height_flag == 0){
+ var default_var_height = default_var_height_1[spremenljivka];
+ } */
+
+
+ var default_var_height_now = $('#spremenljivka_'+spremenljivka).height();
+ //console.log("default_var_height: "+default_var_height_now);
+ var default_var_height = $('#spremenljivka_'+spremenljivka).height();
+
+ //ce je visina okvirja (levi ali desni) z naslovom vprasanja vecja od visine celotnega vprasanja
+ if( (default_var_height < (frame_height_left + naslov_height)) || (default_var_height < (final_height_right_block + naslov_height)) ){
+ if(frame_height_left < final_height_right_block){
+ //console.log("Levi manjsi od desnega");
+ //dynamic_question_height_sub(final_height_right_block, spremenljivka, default_var_height); //glede na visino desnega bloka uredi velikost celotnega vprasanja
+ dynamic_question_height_sub(final_height_right_block, spremenljivka); //glede na visino desnega bloka uredi velikost celotnega vprasanja
+ }else if(frame_height_left > final_height_right_block){
+ //console.log("Levi vecji od desnega");
+ //dynamic_question_height_sub(frame_height_left, spremenljivka, default_var_height); //glede na visino levega bloka uredi velikost celotnega vprasanja
+ dynamic_question_height_sub(frame_height_left, spremenljivka); //glede na visino levega bloka uredi velikost celotnega vprasanja
+ }
+ }else if (frame_height_left < final_height_right_block){
+ $('#spremenljivka_'+spremenljivka).height(final_height_right_block + naslov_height + 50);
+ //console.log("Spreminjam A1");
+ //da ne bo pri mobilnikih prevec skrito vprasanje, spremeni visino variable_holder
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(final_height_right_block + 25);
+ }else if (frame_height_left > final_height_right_block){
+ $('#spremenljivka_'+spremenljivka).height(frame_height_left + naslov_height + 50);
+ //console.log("Spreminjam A2");
+ //da ne bo pri mobilnikih prevec skrito vprasanje, spremeni visino variable_holder
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(frame_height_left + 25);
+ }
+
+ //************************************ konec - dinamicna visina celotnega vprasanja glede na visino prenesenih desnih okvirjev
+} \ No newline at end of file
diff --git a/main/survey/js/Fotografiranje/FotoDeclaration.js b/main/survey/js/Fotografiranje/FotoDeclaration.js
new file mode 100644
index 0000000..d82d654
--- /dev/null
+++ b/main/survey/js/Fotografiranje/FotoDeclaration.js
@@ -0,0 +1,82 @@
+/*
+ * Author: Uros Podkriznik
+ * Date: 29.7.2016
+ *
+ * Deklaracija tipa vprasanja Fotografiranje/Selfi
+ */
+
+//osnovni id-ji tagov brez predpon - za vse fotografije v eni grupi
+var vse_kamere_ids = [];
+
+/**
+ * Deklarira tipe vprasanj fotografiraj
+ * Preveri, ce browser podpira funkcije za kamere ter kamero nastavi - odpre se popup za dovoljenje
+ * @param {type} inpid - standard id html tagov tagov
+ * @returns {undefined}
+ */
+function FotoDeclaration(inpid, site_url){
+ vse_kamere_ids.push(inpid);
+
+ // use the proper vendor prefix
+ navigator.getMedia = ( navigator.getUserMedia ||
+ navigator.webkitGetUserMedia ||
+ navigator.mozGetUserMedia ||
+ navigator.msGetUserMedia);
+
+ //za IE in Safari, ker se ne podpirata getmedia
+ //if(navigator.getMedia){
+ //nastavi kamero
+ Webcam.set({
+ width: 320,
+ height: 240,
+ image_format: 'jpeg',
+ jpeg_quality: 90,
+ swfURL: site_url+'main/survey/js/Fotografiranje/webcam.swf'
+ });
+ Webcam.attach( inpid );
+ //}
+}
+
+/**
+ * Ob kliku na gumb za fotografiranje se izvede ta F
+ * @param {type} inpid - standard id html tagov tagov
+ * @returns {undefined}
+ */
+function take_snapshot(inpid) {
+
+ // take snapshot and get image data
+ Webcam.snap( function(data_uri) {
+
+ // display results in page
+ $('#fotoresults_'+inpid).html('<img src="'+data_uri+'"/>');
+
+ var raw_image_data = data_uri.replace(/^data\:image\/\w+\;base64\,/, '');
+ $('#foto_'+inpid).val(raw_image_data);
+
+ $('#fotoresults_delete_'+inpid).show();
+ });
+}
+
+// Pobrisemo snapshot
+function delete_snapshot(inpid) {
+ $('#fotoresults_'+inpid).html('<p>'+lang['srv_resevanje_foto_pre_result']+'</p>');
+ $('#foto_'+inpid).val('');
+
+ $('#fotoresults_delete_'+inpid).hide();
+}
+
+// Pobrisemo upload fotografije
+function delete_upload_foto(inpid) {
+ $('#'+inpid).val(null);
+
+ //var reader = new FileReader();
+
+ //reader.onload = function (e) {
+ $('#upload_foto_result_'+inpid).css("display", "none");
+ $('#upload_foto_result_'+inpid).attr('src', "#");
+ //};
+
+ //reader.readAsDataURL(input.files[0]);
+
+ $('#upload_fotoresults_delete_'+inpid).hide();
+}
diff --git a/main/survey/js/Fotografiranje/webcam.js b/main/survey/js/Fotografiranje/webcam.js
new file mode 100644
index 0000000..478086c
--- /dev/null
+++ b/main/survey/js/Fotografiranje/webcam.js
@@ -0,0 +1,833 @@
+// WebcamJS v1.0.10
+// Webcam library for capturing JPEG/PNG images in JavaScript
+// Attempts getUserMedia, falls back to Flash
+// Author: Joseph Huckaby: http://github.com/jhuckaby
+// Based on JPEGCam: http://code.google.com/p/jpegcam/
+// Copyright (c) 2012 - 2015 Joseph Huckaby
+// Licensed under the MIT License
+
+//array vseh video v eni grupi
+var videos = [];
+
+(function(window) {
+var _userMedia;
+
+// declare error types
+
+// inheritance pattern here:
+// https://stackoverflow.com/questions/783818/how-do-i-create-a-custom-error-in-javascript
+function FlashError() {
+ var temp = Error.apply(this, arguments);
+ temp.name = this.name = "FlashError";
+ this.stack = temp.stack;
+ this.message = temp.message;
+}
+
+function WebcamError() {
+ var temp = Error.apply(this, arguments);
+ temp.name = this.name = "WebcamError";
+ this.stack = temp.stack;
+ this.message = temp.message;
+}
+
+IntermediateInheritor = function() {};
+IntermediateInheritor.prototype = Error.prototype;
+
+FlashError.prototype = new IntermediateInheritor();
+WebcamError.prototype = new IntermediateInheritor();
+
+var Webcam = {
+ version: '1.0.10',
+
+ // globals
+ protocol: location.protocol.match(/https/i) ? 'https' : 'http',
+ loaded: false, // true when webcam movie finishes loading
+ live: false, // true when webcam is initialized and ready to snap
+ userMedia: true, // true when getUserMedia is supported natively
+
+ params: {
+ width: 0,
+ height: 0,
+ dest_width: 0, // size of captured image
+ dest_height: 0, // these default to width/height
+ image_format: 'jpeg', // image format (may be jpeg or png)
+ jpeg_quality: 90, // jpeg image quality from 0 (worst) to 100 (best)
+ force_flash: false, // force flash mode,
+ flip_horiz: false, // flip image horiz (mirror mode)
+ fps: 30, // camera frames per second
+ upload_name: 'webcam', // name of file in upload post data
+ constraints: null, // custom user media constraints,
+ swfURL: '', // URI to webcam.swf movie (defaults to the js location)
+ flashNotDetectedText: 'ERROR: No Adobe Flash Player detected. Webcam.js relies on Flash for browsers that do not support getUserMedia (like yours).',
+ unfreeze_snap: true // Whether to unfreeze the camera after snap (defaults to true)
+ },
+
+ errors: {
+ FlashError: FlashError,
+ WebcamError: WebcamError
+ },
+
+ hooks: {}, // callback hook functions
+
+ init: function() {
+ // initialize, check for getUserMedia support
+ var self = this;
+
+ // Setup getUserMedia, with polyfill for older browsers
+ // Adapted from: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
+ this.mediaDevices = (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) ?
+ navigator.mediaDevices : ((navigator.mozGetUserMedia || navigator.webkitGetUserMedia) ? {
+ getUserMedia: function(c) {
+ return new Promise(function(y, n) {
+ (navigator.mozGetUserMedia ||
+ navigator.webkitGetUserMedia).call(navigator, c, y, n);
+ });
+ }
+ } : null);
+
+ window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
+ this.userMedia = this.userMedia && !!this.mediaDevices && !!window.URL;
+
+ // Older versions of firefox (< 21) apparently claim support but user media does not actually work
+ if (navigator.userAgent.match(/Firefox\D+(\d+)/)) {
+ if (parseInt(RegExp.$1, 10) < 21) this.userMedia = null;
+ }
+
+ // Make sure media stream is closed when navigating away from page
+ if (this.userMedia) {
+ window.addEventListener( 'beforeunload', function(event) {
+ self.reset();
+ } );
+ }
+ },
+
+ attach: function(inpid) {
+ //get parent div for visibility when all is ok
+ var parent_element = document.getElementById('fotoparent_'+inpid);
+ parent_element.style.display='';
+
+ // create webcam preview and attach to DOM element
+ // pass in actual DOM reference, ID, or CSS selector
+ if (typeof(inpid) == 'string') {
+ elem = document.getElementById('#my_camera_'+inpid) || document.querySelector('#my_camera_'+inpid);
+ }
+ if (!elem) {
+ return this.dispatch('error', new WebcamError("Could not locate DOM element to attach to."));
+ fotoShowNormalFileUploadInput();
+ }
+ this.container = elem;
+ elem.innerHTML = ''; // start with empty element
+
+ // insert "peg" so we can insert our preview canvas adjacent to it later on
+ var peg = document.createElement('div');
+ elem.appendChild( peg );
+ this.peg = peg;
+
+ // set width/height if not already set
+ if (!this.params.width) this.params.width = elem.offsetWidth;
+ if (!this.params.height) this.params.height = elem.offsetHeight;
+
+ // make sure we have a nonzero width and height at this point
+ if (!this.params.width || !this.params.height) {
+ return this.dispatch('error', new WebcamError("No width and/or height for webcam. Please call set() first, or attach to a visible element."));
+ fotoShowNormalFileUploadInput();
+ }
+
+ // set defaults for dest_width / dest_height if not set
+ if (!this.params.dest_width) this.params.dest_width = this.params.width;
+ if (!this.params.dest_height) this.params.dest_height = this.params.height;
+
+ this.userMedia = _userMedia === undefined ? this.userMedia : _userMedia;
+ // if force_flash is set, disable userMedia
+ if (this.params.force_flash) {
+ _userMedia = this.userMedia;
+ this.userMedia = null
+ }
+
+ // check for default fps
+ if (typeof this.params.fps !== "number") this.params.fps = 30;
+
+ // adjust scale if dest_width or dest_height is different
+ var scaleX = this.params.width / this.params.dest_width;
+ var scaleY = this.params.height / this.params.dest_height;
+
+ if (this.userMedia) {
+ // setup webcam video container
+ var video = document.createElement('video');
+ video.setAttribute('autoplay', 'autoplay');
+ video.setAttribute('id', 'video_'+inpid);
+ video.style.width = '' + this.params.dest_width + 'px';
+ video.style.height = '' + this.params.dest_height + 'px';
+
+ if ((scaleX != 1.0) || (scaleY != 1.0)) {
+ elem.style.overflow = 'hidden';
+ video.style.webkitTransformOrigin = '0px 0px';
+ video.style.mozTransformOrigin = '0px 0px';
+ video.style.msTransformOrigin = '0px 0px';
+ video.style.oTransformOrigin = '0px 0px';
+ video.style.transformOrigin = '0px 0px';
+ video.style.webkitTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ video.style.mozTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ video.style.msTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ video.style.oTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ video.style.transform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ }
+
+ // add video element to dom
+ elem.appendChild( video );
+ this.video = video;
+
+ //dodaj video v array
+ videos.push(video);
+ //spet skrij parent, dokler se ne preveri ali je uporabnik dovolil snemanje
+ parent_element.style.display='none';
+
+ // ask user for access to their camera
+ var self = this;
+ this.mediaDevices.getUserMedia({
+ "audio": false,
+ "video": this.params.constraints || {
+ mandatory: {
+ minWidth: this.params.dest_width,
+ minHeight: this.params.dest_height
+ }
+ }
+ })
+ .then( function(stream) {
+ //stevec za stetje, koliko kamer se je ze naloadalo v asinhroni F
+ var stejcam = 0;
+
+ //zanka, ki gre cez vse kamere v grupi
+ for(i=0; i<videos.length; i++){
+ var video1 = videos[i];
+
+ // got access, attach stream to video
+ video1.onloadedmetadata = function(e) {
+ self.stream = stream;
+ self.loaded = true;
+ self.live = true;
+ self.dispatch('load');
+ self.dispatch('live');
+ self.flip();
+
+ //vse to se rabi ker je asinhrona F, prikaz potrebnih elementov in skritje navadnega uploada
+ document.getElementById(vse_kamere_ids[stejcam]).style.display='none';
+ parent_element = document.getElementById('fotoparent_'+vse_kamere_ids[stejcam]);
+ stejcam++;
+ parent_element.style.display='';
+ parent_element.style.visibility='visible';
+ };
+ // as window.URL.createObjectURL() is deprecated, adding a check so that it works in Safari.
+ // older browsers may not have srcObject
+ if ("srcObject" in video1) {
+ video1.srcObject = stream;
+ }
+ else {
+ // using URL.createObjectURL() as fallback for old browsers
+ video1.src = window.URL.createObjectURL(stream);
+ }
+ }
+ })
+ .catch( function(err) {
+ parent_element.style.display='none';
+ return self.dispatch('error', err);
+ fotoShowNormalFileUploadInput();
+ });
+ }
+ else {
+ document.getElementById(inpid).style.display='none';
+ parent_element.style.display='';
+ parent_element.style.visibility='visible';
+
+ // flash fallback
+ window.Webcam = Webcam; // needed for flash-to-js interface
+ var div = document.createElement('div');
+ div.innerHTML = this.getSWFHTML();
+ elem.appendChild( div );
+ }
+
+ // setup final crop for live preview
+ if (this.params.crop_width && this.params.crop_height) {
+ var scaled_crop_width = Math.floor( this.params.crop_width * scaleX );
+ var scaled_crop_height = Math.floor( this.params.crop_height * scaleY );
+
+ elem.style.width = '' + scaled_crop_width + 'px';
+ elem.style.height = '' + scaled_crop_height + 'px';
+ elem.style.overflow = 'hidden';
+
+ elem.scrollLeft = Math.floor( (this.params.width / 2) - (scaled_crop_width / 2) );
+ elem.scrollTop = Math.floor( (this.params.height / 2) - (scaled_crop_height / 2) );
+ }
+ else {
+ // no crop, set size to desired
+ elem.style.width = '' + this.params.width + 'px';
+ elem.style.height = '' + this.params.height + 'px';
+ }
+ },
+
+ reset: function() {
+ // shutdown camera, reset to potentially attach again
+ if (this.preview_active) this.unfreeze();
+
+ // attempt to fix issue #64
+ this.unflip();
+
+ if (this.userMedia) {
+ if (this.stream) {
+ if (this.stream.getVideoTracks) {
+ // get video track to call stop on it
+ var tracks = this.stream.getVideoTracks();
+ if (tracks && tracks[0] && tracks[0].stop) tracks[0].stop();
+ }
+ else if (this.stream.stop) {
+ // deprecated, may be removed in future
+ this.stream.stop();
+ }
+ }
+ delete this.stream;
+ delete this.video;
+ }
+
+ if (this.userMedia !== true) {
+ // call for turn off camera in flash
+ this.getMovie()._releaseCamera();
+ }
+
+ if (this.container) {
+ this.container.innerHTML = '';
+ delete this.container;
+ }
+
+ this.loaded = false;
+ this.live = false;
+ },
+
+ set: function() {
+ // set one or more params
+ // variable argument list: 1 param = hash, 2 params = key, value
+ if (arguments.length == 1) {
+ for (var key in arguments[0]) {
+ this.params[key] = arguments[0][key];
+ }
+ }
+ else {
+ this.params[ arguments[0] ] = arguments[1];
+ }
+ },
+
+ on: function(name, callback) {
+ // set callback hook
+ name = name.replace(/^on/i, '').toLowerCase();
+ if (!this.hooks[name]) this.hooks[name] = [];
+ this.hooks[name].push( callback );
+ },
+
+ off: function(name, callback) {
+ // remove callback hook
+ name = name.replace(/^on/i, '').toLowerCase();
+ if (this.hooks[name]) {
+ if (callback) {
+ // remove one selected callback from list
+ var idx = this.hooks[name].indexOf(callback);
+ if (idx > -1) this.hooks[name].splice(idx, 1);
+ }
+ else {
+ // no callback specified, so clear all
+ this.hooks[name] = [];
+ }
+ }
+ },
+
+ dispatch: function() {
+ // fire hook callback, passing optional value to it
+ var name = arguments[0].replace(/^on/i, '').toLowerCase();
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ if (this.hooks[name] && this.hooks[name].length) {
+ for (var idx = 0, len = this.hooks[name].length; idx < len; idx++) {
+ var hook = this.hooks[name][idx];
+
+ if (typeof(hook) == 'function') {
+ // callback is function reference, call directly
+ hook.apply(this, args);
+ }
+ else if ((typeof(hook) == 'object') && (hook.length == 2)) {
+ // callback is PHP-style object instance method
+ hook[0][hook[1]].apply(hook[0], args);
+ }
+ else if (window[hook]) {
+ // callback is global function name
+ window[ hook ].apply(window, args);
+ }
+ } // loop
+ return true;
+ }
+ else if (name == 'error') {
+ if (args[0] instanceof FlashError) {
+ message = args[0].message;
+ //ce je pri flashu prislo do zavrnitve dovoljenja
+ if(message === 'Access to camera denied'){
+ //prikazi input za upload foto in skrij flash okenca
+ }
+ }
+ else if (args[0] instanceof WebcamError) {
+ message = args[0].message;
+ } else {
+ message = "Could not access webcam: " + args[0].name + ": " +
+ args[0].message + " " + args[0].toString();
+ }
+
+ // default error handler if no custom one specified
+ //alert("Webcam.js Error: " + message);
+ console.log("Webcam.js Error: " + message);
+ fotoShowNormalFileUploadInput();
+ }
+
+ return false; // no hook defined
+ },
+
+ setSWFLocation: function(value) {
+ // for backward compatibility.
+ this.set('swfURL', value);
+ },
+
+ detectFlash: function() {
+ // return true if browser supports flash, false otherwise
+ // Code snippet borrowed from: https://github.com/swfobject/swfobject
+ var SHOCKWAVE_FLASH = "Shockwave Flash",
+ SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
+ FLASH_MIME_TYPE = "application/x-shockwave-flash",
+ win = window,
+ nav = navigator,
+ hasFlash = false;
+
+ if (typeof nav.plugins !== "undefined" && typeof nav.plugins[SHOCKWAVE_FLASH] === "object") {
+ var desc = nav.plugins[SHOCKWAVE_FLASH].description;
+ if (desc && (typeof nav.mimeTypes !== "undefined" && nav.mimeTypes[FLASH_MIME_TYPE] && nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) {
+ hasFlash = true;
+ }
+ }
+ else if (typeof win.ActiveXObject !== "undefined") {
+ try {
+ var ax = new ActiveXObject(SHOCKWAVE_FLASH_AX);
+ if (ax) {
+ var ver = ax.GetVariable("$version");
+ if (ver) hasFlash = true;
+ }
+ }
+ catch (e) {;}
+ }
+
+ return hasFlash;
+ },
+
+ getSWFHTML: function() {
+ // Return HTML for embedding flash based webcam capture movie
+ var html = '',
+ swfURL = this.params.swfURL;
+
+ // make sure we aren't running locally (flash doesn't work)
+ if (location.protocol.match(/file/)) {
+ this.dispatch('error', new FlashError("Flash does not work from local disk. Please run from a web server."));
+ //return '<h3 style="color:red">ERROR: the Webcam.js Flash fallback does not work from local disk. Please run it from a web server.</h3>';
+ fotoShowNormalFileUploadInput();
+ }
+
+ // make sure we have flash
+ if (!this.detectFlash()) {
+ this.dispatch('error', new FlashError("Adobe Flash Player not found. Please install from get.adobe.com/flashplayer and try again."));
+ //return '<h3 style="color:red">' + this.params.flashNotDetectedText + '</h3>';
+ fotoShowNormalFileUploadInput();
+ }
+
+ // set default swfURL if not explicitly set
+ if (!swfURL) {
+ // find our script tag, and use that base URL
+ var base_url = '';
+ var scpts = document.getElementsByTagName('script');
+ for (var idx = 0, len = scpts.length; idx < len; idx++) {
+ var src = scpts[idx].getAttribute('src');
+ if (src && src.match(/\/webcam(\.min)?\.js/)) {
+ base_url = src.replace(/\/webcam(\.min)?\.js.*$/, '');
+ idx = len;
+ }
+ }
+ if (base_url) swfURL = base_url + '/webcam.swf';
+ else swfURL = 'webcam.swf';
+ }
+
+ // if this is the user's first visit, set flashvar so flash privacy settings panel is shown first
+ if (window.localStorage && !localStorage.getItem('visited')) {
+ this.params.new_user = 1;
+ localStorage.setItem('visited', 1);
+ }
+
+ // construct flashvars string
+ var flashvars = '';
+ for (var key in this.params) {
+ if (flashvars) flashvars += '&';
+ flashvars += key + '=' + escape(this.params[key]);
+ }
+
+ // construct object/embed tag
+ html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" type="application/x-shockwave-flash" codebase="'+this.protocol+'://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+this.params.width+'" height="'+this.params.height+'" id="webcam_movie_obj" align="middle"><param name="wmode" value="opaque" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+swfURL+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><embed id="webcam_movie_embed" src="'+swfURL+'" wmode="opaque" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+this.params.width+'" height="'+this.params.height+'" name="webcam_movie_embed" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'"></embed></object>';
+
+ return html;
+ },
+
+ getMovie: function() {
+ // get reference to movie object/embed in DOM
+ if (!this.loaded) return this.dispatch('error', new FlashError("Flash Movie is not loaded yet"));
+ var movie = document.getElementById('webcam_movie_obj');
+ if (!movie || !movie._snap) movie = document.getElementById('webcam_movie_embed');
+ if (!movie) this.dispatch('error', new FlashError("Cannot locate Flash movie in DOM"));
+ return movie;
+ },
+
+ freeze: function() {
+ // show preview, freeze camera
+ var self = this;
+ var params = this.params;
+
+ // kill preview if already active
+ if (this.preview_active) this.unfreeze();
+
+ // determine scale factor
+ var scaleX = this.params.width / this.params.dest_width;
+ var scaleY = this.params.height / this.params.dest_height;
+
+ // must unflip container as preview canvas will be pre-flipped
+ this.unflip();
+
+ // calc final size of image
+ var final_width = params.crop_width || params.dest_width;
+ var final_height = params.crop_height || params.dest_height;
+
+ // create canvas for holding preview
+ var preview_canvas = document.createElement('canvas');
+ preview_canvas.width = final_width;
+ preview_canvas.height = final_height;
+ var preview_context = preview_canvas.getContext('2d');
+
+ // save for later use
+ this.preview_canvas = preview_canvas;
+ this.preview_context = preview_context;
+
+ // scale for preview size
+ if ((scaleX != 1.0) || (scaleY != 1.0)) {
+ preview_canvas.style.webkitTransformOrigin = '0px 0px';
+ preview_canvas.style.mozTransformOrigin = '0px 0px';
+ preview_canvas.style.msTransformOrigin = '0px 0px';
+ preview_canvas.style.oTransformOrigin = '0px 0px';
+ preview_canvas.style.transformOrigin = '0px 0px';
+ preview_canvas.style.webkitTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ preview_canvas.style.mozTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ preview_canvas.style.msTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ preview_canvas.style.oTransform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ preview_canvas.style.transform = 'scaleX('+scaleX+') scaleY('+scaleY+')';
+ }
+
+ // take snapshot, but fire our own callback
+ this.snap( function() {
+ // add preview image to dom, adjust for crop
+ preview_canvas.style.position = 'relative';
+ preview_canvas.style.left = '' + self.container.scrollLeft + 'px';
+ preview_canvas.style.top = '' + self.container.scrollTop + 'px';
+
+ self.container.insertBefore( preview_canvas, self.peg );
+ self.container.style.overflow = 'hidden';
+
+ // set flag for user capture (use preview)
+ self.preview_active = true;
+
+ }, preview_canvas );
+ },
+
+ unfreeze: function() {
+ // cancel preview and resume live video feed
+ if (this.preview_active) {
+ // remove preview canvas
+ this.container.removeChild( this.preview_canvas );
+ delete this.preview_context;
+ delete this.preview_canvas;
+
+ // unflag
+ this.preview_active = false;
+
+ // re-flip if we unflipped before
+ this.flip();
+ }
+ },
+
+ flip: function() {
+ // flip container horiz (mirror mode) if desired
+ if (this.params.flip_horiz) {
+ var sty = this.container.style;
+ sty.webkitTransform = 'scaleX(-1)';
+ sty.mozTransform = 'scaleX(-1)';
+ sty.msTransform = 'scaleX(-1)';
+ sty.oTransform = 'scaleX(-1)';
+ sty.transform = 'scaleX(-1)';
+ sty.filter = 'FlipH';
+ sty.msFilter = 'FlipH';
+ }
+ },
+
+ unflip: function() {
+ // unflip container horiz (mirror mode) if desired
+ if (this.params.flip_horiz) {
+ var sty = this.container.style;
+ sty.webkitTransform = 'scaleX(1)';
+ sty.mozTransform = 'scaleX(1)';
+ sty.msTransform = 'scaleX(1)';
+ sty.oTransform = 'scaleX(1)';
+ sty.transform = 'scaleX(1)';
+ sty.filter = '';
+ sty.msFilter = '';
+ }
+ },
+
+ savePreview: function(user_callback, user_canvas) {
+ // save preview freeze and fire user callback
+ var params = this.params;
+ var canvas = this.preview_canvas;
+ var context = this.preview_context;
+
+ // render to user canvas if desired
+ if (user_canvas) {
+ var user_context = user_canvas.getContext('2d');
+ user_context.drawImage( canvas, 0, 0 );
+ }
+
+ // fire user callback if desired
+ user_callback(
+ user_canvas ? null : canvas.toDataURL('image/' + params.image_format, params.jpeg_quality / 100 ),
+ canvas,
+ context
+ );
+
+ // remove preview
+ if (this.params.unfreeze_snap) this.unfreeze();
+ },
+
+ snap: function(user_callback, user_canvas) {
+ // take snapshot and return image data uri
+ var self = this;
+ var params = this.params;
+
+ if (!this.loaded) return this.dispatch('error', new WebcamError("Webcam is not loaded yet"));
+ // if (!this.live) return this.dispatch('error', new WebcamError("Webcam is not live yet"));
+ if (!user_callback) return this.dispatch('error', new WebcamError("Please provide a callback function or canvas to snap()"));
+
+ // if we have an active preview freeze, use that
+ if (this.preview_active) {
+ this.savePreview( user_callback, user_canvas );
+ return null;
+ }
+
+ // create offscreen canvas element to hold pixels
+ var canvas = document.createElement('canvas');
+ canvas.width = this.params.dest_width;
+ canvas.height = this.params.dest_height;
+ var context = canvas.getContext('2d');
+
+ // flip canvas horizontally if desired
+ if (this.params.flip_horiz) {
+ context.translate( params.dest_width, 0 );
+ context.scale( -1, 1 );
+ }
+
+ // create inline function, called after image load (flash) or immediately (native)
+ var func = function() {
+ // render image if needed (flash)
+ if (this.src && this.width && this.height) {
+ context.drawImage(this, 0, 0, params.dest_width, params.dest_height);
+ }
+
+ // crop if desired
+ if (params.crop_width && params.crop_height) {
+ var crop_canvas = document.createElement('canvas');
+ crop_canvas.width = params.crop_width;
+ crop_canvas.height = params.crop_height;
+ var crop_context = crop_canvas.getContext('2d');
+
+ crop_context.drawImage( canvas,
+ Math.floor( (params.dest_width / 2) - (params.crop_width / 2) ),
+ Math.floor( (params.dest_height / 2) - (params.crop_height / 2) ),
+ params.crop_width,
+ params.crop_height,
+ 0,
+ 0,
+ params.crop_width,
+ params.crop_height
+ );
+
+ // swap canvases
+ context = crop_context;
+ canvas = crop_canvas;
+ }
+
+ // render to user canvas if desired
+ if (user_canvas) {
+ var user_context = user_canvas.getContext('2d');
+ user_context.drawImage( canvas, 0, 0 );
+ }
+
+ // fire user callback if desired
+ user_callback(
+ user_canvas ? null : canvas.toDataURL('image/' + params.image_format, params.jpeg_quality / 100 ),
+ canvas,
+ context
+ );
+ };
+
+ // grab image frame from userMedia or flash movie
+ if (this.userMedia) {
+ // native implementation
+ context.drawImage(this.video, 0, 0, this.params.dest_width, this.params.dest_height);
+
+ // fire callback right away
+ func();
+ }
+ else {
+ // flash fallback
+ var raw_data = this.getMovie()._snap();
+
+ // render to image, fire callback when complete
+ var img = new Image();
+ img.onload = func;
+ img.src = 'data:image/'+this.params.image_format+';base64,' + raw_data;
+ }
+
+ return null;
+ },
+
+ configure: function(panel) {
+ // open flash configuration panel -- specify tab name:
+ // "camera", "privacy", "default", "localStorage", "microphone", "settingsManager"
+ if (!panel) panel = "camera";
+ this.getMovie()._configure(panel);
+ },
+
+ flashNotify: function(type, msg) {
+ // receive notification from flash about event
+ switch (type) {
+ case 'flashLoadComplete':
+ // movie loaded successfully
+ this.loaded = true;
+ this.dispatch('load');
+ break;
+
+ case 'cameraLive':
+ // camera is live and ready to snap
+ this.live = true;
+ this.dispatch('live');
+ break;
+
+ case 'error':
+ // Flash error
+ this.dispatch('error', new FlashError(msg));
+ break;
+
+ default:
+ // catch-all event, just in case
+ console.log("webcam flash_notify: " + type + ": " + msg);
+ break;
+ }
+ },
+
+ b64ToUint6: function(nChr) {
+ // convert base64 encoded character to 6-bit integer
+ // from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding
+ return nChr > 64 && nChr < 91 ? nChr - 65
+ : nChr > 96 && nChr < 123 ? nChr - 71
+ : nChr > 47 && nChr < 58 ? nChr + 4
+ : nChr === 43 ? 62 : nChr === 47 ? 63 : 0;
+ },
+
+ base64DecToArr: function(sBase64, nBlocksSize) {
+ // convert base64 encoded string to Uintarray
+ // from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding
+ var sB64Enc = sBase64.replace(/[^A-Za-z0-9\+\/]/g, ""), nInLen = sB64Enc.length,
+ nOutLen = nBlocksSize ? Math.ceil((nInLen * 3 + 1 >> 2) / nBlocksSize) * nBlocksSize : nInLen * 3 + 1 >> 2,
+ taBytes = new Uint8Array(nOutLen);
+
+ for (var nMod3, nMod4, nUint24 = 0, nOutIdx = 0, nInIdx = 0; nInIdx < nInLen; nInIdx++) {
+ nMod4 = nInIdx & 3;
+ nUint24 |= this.b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << 18 - 6 * nMod4;
+ if (nMod4 === 3 || nInLen - nInIdx === 1) {
+ for (nMod3 = 0; nMod3 < 3 && nOutIdx < nOutLen; nMod3++, nOutIdx++) {
+ taBytes[nOutIdx] = nUint24 >>> (16 >>> nMod3 & 24) & 255;
+ }
+ nUint24 = 0;
+ }
+ }
+ return taBytes;
+ },
+
+ upload: function(image_data_uri, target_url, callback) {
+ // submit image data to server using binary AJAX
+ var form_elem_name = this.params.upload_name || 'webcam';
+
+ // detect image format from within image_data_uri
+ var image_fmt = '';
+ if (image_data_uri.match(/^data\:image\/(\w+)/))
+ image_fmt = RegExp.$1;
+ else
+ throw "Cannot locate image format in Data URI";
+
+ // extract raw base64 data from Data URI
+ var raw_image_data = image_data_uri.replace(/^data\:image\/\w+\;base64\,/, '');
+
+ // contruct use AJAX object
+ var http = new XMLHttpRequest();
+ http.open("POST", target_url, true);
+
+ // setup progress events
+ if (http.upload && http.upload.addEventListener) {
+ http.upload.addEventListener( 'progress', function(e) {
+ if (e.lengthComputable) {
+ var progress = e.loaded / e.total;
+ Webcam.dispatch('uploadProgress', progress, e);
+ }
+ }, false );
+ }
+
+ // completion handler
+ var self = this;
+ http.onload = function() {
+ if (callback) callback.apply( self, [http.status, http.responseText, http.statusText] );
+ Webcam.dispatch('uploadComplete', http.status, http.responseText, http.statusText);
+ };
+
+ // create a blob and decode our base64 to binary
+ var blob = new Blob( [ this.base64DecToArr(raw_image_data) ], {type: 'image/'+image_fmt} );
+
+ // stuff into a form, so servers can easily receive it as a standard file upload
+ var form = new FormData();
+ form.append( form_elem_name, blob, form_elem_name+"."+image_fmt.replace(/e/, '') );
+
+ // send data to server
+ http.send(form);
+ }
+
+};
+
+Webcam.init();
+
+if (typeof define === 'function' && define.amd) {
+ define( function() { return Webcam; } );
+}
+else if (typeof module === 'object' && module.exports) {
+ module.exports = Webcam;
+}
+else {
+ window.Webcam = Webcam;
+}
+
+}(window));
+
+function fotoShowNormalFileUploadInput(){
+ $('.upload_foto_file').css('display','');
+ $('.fotoparent').css('display','none');
+}
diff --git a/main/survey/js/Fotografiranje/webcam.swf b/main/survey/js/Fotografiranje/webcam.swf
new file mode 100644
index 0000000..e1d88cd
--- /dev/null
+++ b/main/survey/js/Fotografiranje/webcam.swf
Binary files differ
diff --git a/main/survey/js/HeatMap/HeatMapCanvas.js b/main/survey/js/HeatMap/HeatMapCanvas.js
new file mode 100644
index 0000000..393a40d
--- /dev/null
+++ b/main/survey/js/HeatMap/HeatMapCanvas.js
@@ -0,0 +1,285 @@
+var heatmap_num_clicksGlobal = []; //belezi stevilo klikov na canvas
+var mousePos = []; //belezi koordinate izbranih tock
+var indeksMousePos = [];
+
+//inicializacija canvas-a
+function InitHeatMapCanvas(spremenljivka, quick_view){
+ //console.log("InitHeatMapCanvas: "+spremenljivka);
+ var imageJQ = $('#hotspot_'+spremenljivka+'_image');
+ var visina = imageJQ.height();
+ var sirina = imageJQ.width();
+ //var canvasJQ = $('#heatmapCanvas_'+spremenljivka);
+ var canvas = document.getElementById('heatmapCanvas_'+spremenljivka);
+
+
+ imageJQ.css( "display", "none" ); //skrij sliko
+
+ image = new Image();
+ image.src = $('#hotspot_'+spremenljivka+'_image').attr("src");
+ image.height = visina;
+ image.width = sirina;
+
+ //canvasJQ.height(visina);
+ //canvasJQ.width(sirina);
+ canvas.setAttribute('height',visina);
+ canvas.setAttribute('width',sirina);
+
+
+ if (canvas.getContext){
+ var context = canvas.getContext('2d');
+ context.drawImage(image, 0, 0, sirina, visina); //drawImage(image, dx, dy, dWidth, dHeight); //narisi sliko ustrezne dimenzije (sirina, visina) na canvas
+ } else {
+ console.log("Canvas not supported");
+ }
+
+}
+
+
+function HeatMapCanvasDelovanje(evt, spremenljivka, heatmap_show_clicks, heatmap_num_clicks, heatmap_click_color, heatmap_click_size, heatmap_click_shape, quick_view){
+ var canvas = document.getElementById('heatmapCanvas_'+spremenljivka);
+ //var canvas = document.getElementsByClassName('mapster_el_'+spremenljivka);
+ var context = canvas.getContext('2d');
+
+ //console.log("heatmap_num_clicksGlobal: "+heatmap_num_clicksGlobal[spremenljivka]);
+ if(heatmap_num_clicksGlobal[spremenljivka] != 0){ //dokler je stevilo moznih klikov razlicno od nula zbiraj koordinate klikanih tock
+
+ mousePos[spremenljivka][indeksMousePos[spremenljivka]] = getMousePos(canvas, evt);
+ //console.log("x: "+mousePos[spremenljivka][indeksMousePos[spremenljivka]].x+" y: "+mousePos[spremenljivka][indeksMousePos[spremenljivka]].y+" za spremenljivko "+spremenljivka);
+
+
+ //oznacevanje checkbox vezani na obmocja
+ //preveri, ce je izbrana tocka znotraj obmocja
+ checkIfPointInsidePoly(spremenljivka);
+ //oznacevanje checkbox vezani na obmocja - konec
+
+
+ heatmap_num_clicksGlobal[spremenljivka]--;
+ if(heatmap_show_clicks){ //ce je to potrebno, pokazi klike na canvas v obliki okvirja
+ //drawRectangleOnCanvas(mousePos[spremenljivka][indeksMousePos[spremenljivka]], canvas, context);
+ drawShapeOnCanvas(mousePos[spremenljivka][indeksMousePos[spremenljivka]], canvas, context, heatmap_click_color, heatmap_click_size, heatmap_click_shape);
+ }
+
+ HeatMapAddInput(spremenljivka, 0, 0); //dodaj obstojece inpute za tocke iz baze ob morebitnem refreshu ali prehodu na prejsnjo stran
+
+ indeksMousePos[spremenljivka] = indeksMousePos[spremenljivka] + 1;
+
+ $('#heatmapClickNumber_'+spremenljivka).text(indeksMousePos[spremenljivka]); //posodobi stevilo klikov na stevcu klikov
+
+ if(heatmap_num_clicksGlobal[spremenljivka] == 0){ //ce ni vec moznih klikov
+ $('#heatmapCanvas_'+spremenljivka).css( 'cursor', 'default' ); //spremeni misko v navadno puscico
+ }
+
+
+ }else{ //ce ni vec moznih klikov
+/* context.clearRect(0, 0, canvas.width, canvas.height);
+ //context.clearRect(0, 0, context.canvas.width, context.canvas.height); //Izbriši vse na canvasu
+ InitHeatMapCanvas(spremenljivka);
+ heatmap_num_clicksGlobal[spremenljivka] = heatmap_num_clicks; */
+ //pokazi zbrane tocke
+/* for(var i = 0; i<indeksMousePos;i++){
+ console.log((i+1)+". točka ("+mousePos[i].x+", "+mousePos[i].y+")");
+ } */
+ $('#heatmapCanvas_'+spremenljivka).css( 'cursor', 'default' ); //spremeni misko v navadno puscico
+ }
+ //console.log("indeksMousePos["+spremenljivka+"]"+indeksMousePos[spremenljivka]);
+}
+
+//funkcija, ki vrne x pa y koordinate klika oz. tocke na canvas
+function getMousePos(canvas, evt) {
+ var rect = canvas.getBoundingClientRect();
+ return {
+ x: parseInt(evt.clientX - rect.left),
+ y: parseInt(evt.clientY - rect.top)
+ };
+}
+
+//funkcija, ki doda html inpute za izbrane tocke na canvas
+function HeatMapAddInput(spremenljivka, refresh, mousePosRefresh){
+ var $variable_holder = $("#heatmapInputs_" + spremenljivka);
+ var pointId = "pointId_"+spremenljivka+"_"+indeksMousePos[spremenljivka];
+ //console.log(pointId);
+ if (refresh){
+ var $pointInput = $("<input>", {id: pointId, name: "vrednost_" + spremenljivka + "[]",
+ value: pointId + "|" + mousePosRefresh.lat + "|" + mousePosRefresh.lng});
+ }else{
+ var $pointInput = $("<input>", {id: pointId, name: "vrednost_" + spremenljivka + "[]",
+ value: pointId + "|" + mousePos[spremenljivka][indeksMousePos[spremenljivka]].x + "|" + mousePos[spremenljivka][indeksMousePos[spremenljivka]].y});
+ }
+ $variable_holder.append($pointInput);
+}
+
+
+//funkcija, ki narise izbrano obliko, kjer je izbrana tocka
+function drawShapeOnCanvas(mousePos, canvas, context, heatmap_click_color, heatmap_click_size, heatmap_click_shape, refresh){
+ //context.fillRect(mousePos.x, mousePos.y, 25, 25);
+ stranicaRect = heatmap_click_size;
+ if(heatmap_click_shape == 1)
+ {
+ if(refresh == 1){
+ context.arc(mousePos.lat, mousePos.lng, stranicaRect, 0, 2 * Math.PI, false);
+ }
+ else{
+ context.arc(mousePos.x, mousePos.y, stranicaRect, 0, 2 * Math.PI, false);
+ }
+
+ }else if(heatmap_click_shape == 2)
+ {
+ if(refresh == 1){
+ context.rect(mousePos.lat-stranicaRect/2, mousePos.lng-stranicaRect/2, stranicaRect, stranicaRect);
+ }else{
+ context.rect(mousePos.x-stranicaRect/2, mousePos.y-stranicaRect/2, stranicaRect, stranicaRect);
+ }
+ }
+
+ context.fillStyle = heatmap_click_color;
+ context.fill();
+ context.closePath(); //risanje je potrebno zakljuciti da, konkretno pri krogih, se ti ne povezujemo med sabo in naredijo vecji lik
+}
+
+//funkcija, ki resetira canvas in ostale spremenljivke na default
+function resetHeatMapCanvas(spremenljivka, heatmap_num_clicks, quick_view){
+ //pokazi zbrane tocke
+/* for(var i = 0; i<indeksMousePos[spremenljivka];i++){
+ console.log((i+1)+". točka ("+mousePos[spremenljivka][i].x+", "+mousePos[spremenljivka][i].y+") spremenljivka "+spremenljivka);
+ } */
+
+ var canvas = document.getElementById('heatmapCanvas_'+spremenljivka);
+ //var canvas = document.getElementsByClassName('mapster_el_'+spremenljivka);
+ var context = canvas.getContext('2d');
+ context.clearRect(0, 0, canvas.width, canvas.height); //zbrise celoten canvas
+ //context.clearRect(0, 0, context.canvas.width, context.canvas.height); //Izbriši vse na canvasu
+ InitHeatMapCanvas(spremenljivka); //initializing canvas, da se ponovno pokaze slika
+ heatmap_num_clicksGlobal[spremenljivka] = heatmap_num_clicks; //stevilo klikov je zacetno
+ indeksMousePos[spremenljivka] = 0;
+ var $variable_holder = $("#heatmapInputs_" + spremenljivka);
+ $variable_holder.children().remove();
+ $('#heatmapCanvas_'+spremenljivka).css( 'cursor', 'pointer' ); //spremeni misko v rokico
+
+ //resetiranje oznacenih checkbox-ov
+ $("#heatmapCheckbox_"+spremenljivka).children().each(function (index, name) {
+ //console.log($(this).find('input').attr('value'));
+ $(this).find('input').prop("checked", false);
+ });
+
+ $('#heatmapClickNumber_'+spremenljivka).text(0); //stevec klikov resetiraj na 0
+
+}
+
+//funkcija, ki zbrise zadnje izbrano tocko iz canvasa in ustrezno uredi ostale zadeve
+function resetHeatMapLastPoint(spremenljivka, heatmap_num_clicks, heatmap_show_clicks, heatmap_click_color, heatmap_click_size, heatmap_click_shape, heatmap_data, quick_view){
+/* //pokazi zbrane tocke
+ for(var i = 0; i<indeksMousePos[spremenljivka];i++){
+ console.log((i+1)+". točka ("+mousePos[spremenljivka][i].x+", "+mousePos[spremenljivka][i].y+") spremenljivka "+spremenljivka);
+ } */
+
+ var canvas = document.getElementById('heatmapCanvas_'+spremenljivka);
+ //var canvas = document.getElementsByClassName('mapster_el_'+spremenljivka);
+ var context = canvas.getContext('2d');
+ context.clearRect(0, 0, canvas.width, canvas.height); //zbrise celoten canvas
+ //context.clearRect(0, 0, context.canvas.width, context.canvas.height); //Izbriši vse na canvasu
+
+ InitHeatMapCanvas(spremenljivka); //initializing canvas, da se ponovno pokaze slika
+ var $variable_holder = $("#heatmapInputs_" + spremenljivka);
+ $variable_holder.children().remove();
+ //$('#heatmapCanvas_'+spremenljivka).css( 'cursor', 'pointer' ); //spremeni misko v rokico
+
+ //resetiranje oznacenih checkbox-ov
+ $("#heatmapCheckbox_"+spremenljivka).children().each(function (index, name) {
+ //console.log($(this).find('input').attr('value'));
+ $(this).find('input').prop("checked", false);
+ });
+
+ if((heatmap_num_clicks - heatmap_num_clicksGlobal[spremenljivka]) > 0)
+ {
+ indeksMousePos[spremenljivka] = indeksMousePos[spremenljivka] - 1;
+ heatmap_num_clicksGlobal[spremenljivka] = heatmap_num_clicksGlobal[spremenljivka] + 1; //stevilo moznih klikov se poveca za ena
+ $('#heatmapClickNumber_'+spremenljivka).text(heatmap_num_clicks - heatmap_num_clicksGlobal[spremenljivka]); //stevec klikov
+ }
+
+ //dodaj ostale nezbrisane tocke ******************
+ //ce je bil refresh ali se je uporabnik vrnil na prejsnjo stran
+ if(refreshed[spremenljivka] == 1){
+ for (var row in heatmap_data) {
+ var row_object = heatmap_data[row];
+ mousePos[spremenljivka][row] = {x: row_object.lat, y: row_object.lng};
+ //console.log("mousePos["+spremenljivka+"]["+row+"].x:"+mousePos[spremenljivka][row].x);
+ }
+ refreshed[spremenljivka] = 0;
+ }
+ for(var i = 0; i<indeksMousePos[spremenljivka];i++){
+ //console.log((i+1)+". točka ("+mousePos[spremenljivka][i].x+", "+mousePos[spremenljivka][i].y+") spremenljivka "+spremenljivka);
+ //console.log("Dodaj neizbrisano točko "+i);
+ var pointId = "pointId_"+spremenljivka+"_"+i;
+ var $pointInput = $("<input>", {id: pointId, name: "vrednost_" + spremenljivka + "[]",
+ value: pointId + "|" + mousePos[spremenljivka][i].x + "|" + mousePos[spremenljivka][i].y});
+ $variable_holder.append($pointInput);
+ if(heatmap_show_clicks){ //ce je to potrebno, pokazi klike na canvas v obliki okvirja
+ drawShapeOnCanvas(mousePos[spremenljivka][i], canvas, context, heatmap_click_color, heatmap_click_size, heatmap_click_shape);
+ }
+ }
+
+ //dodaj ostale nezbrisane tocke - konec ******************
+}
+
+//funkcija, ki se sprozi ob vrnitvi na prejsnjo stran
+function heatmap_data_add(spremenljivka, heatmap_data, heatmap_click_color, heatmap_click_size, heatmap_click_shape, heatmap_show_clicks, heatmap_num_clicks) {
+ heatmap_num_clicksGlobal[spremenljivka] = heatmap_num_clicks;
+ var i = 0;
+ for (var row in heatmap_data) {
+ var row_object = heatmap_data[row];
+ var mousePos = {lat: row_object.lat, lng: row_object.lng};
+ var canvas = document.getElementById('heatmapCanvas_'+spremenljivka);
+ var context = canvas.getContext('2d');
+
+ if(heatmap_show_clicks){
+ drawShapeOnCanvas(mousePos, canvas, context, heatmap_click_color, heatmap_click_size, heatmap_click_shape, 1);
+ }
+ indeksMousePos[spremenljivka]++;
+ i++
+ HeatMapAddInput(spremenljivka, 1, mousePos);
+ }
+ //uredi limit klikov glede na ze prisotne tocke na canvas
+ heatmap_num_clicksGlobal[spremenljivka] = heatmap_num_clicksGlobal[spremenljivka] - i;
+ $('#heatmapClickNumber_'+spremenljivka).text(i); //prikazi pravilno stevilo klikov na stevcu klikov
+}
+
+//funkcija, ki skrbi za pretvorbo koordinat v pravilno obliko za nadaljnje delovanje
+function convertPolyString(polypoints, vre_id){
+ var poly = [];
+ var polyObjectArray = [];
+ var tmpX;
+ var tmpY;
+ var j = 0;
+ poly = polypoints.split(",");
+
+ for(var i = 0; i<poly.length; i++){
+ if(i == 0 || i%2 == 0){
+ tmpX = parseInt(poly[i]);
+ }else{
+ tmpY = parseInt(poly[i]);
+ polyObjectArray.push({x: tmpX, y: tmpY});
+ }
+ }
+ //console.log("dolzina polja polyObjectArray je: "+polyObjectArray.length);
+ return polyObjectArray;
+}
+
+//funkcija, ki ureja preverjanje prisotnosti trenutne tocke znotraj predefiniranega obmocja
+function checkIfPointInsidePoly(spremenljivka){
+ $("#hotspot_"+spremenljivka+"_map").children().each(function (index, name) {
+ //console.log('coords: ' + $(this).attr('coords') + ' vre_id: ' + $(this).attr('name'));
+ var vre_id = $(this).attr('name');
+ var polypoints = $(this).attr('coords');
+
+ poly = convertPolyString(polypoints, vre_id); //pretvori polje s tockami obmocja v ustrezno obliko
+
+ //preveri, ce je izbrana tocka znotraj obmocja
+ var inside = insidePoly(poly, mousePos[spremenljivka][indeksMousePos[spremenljivka]].x, mousePos[spremenljivka][indeksMousePos[spremenljivka]].y, vre_id);
+ //preveri, ce je izbrana tocka znotraj obmocja - konec
+
+ if (inside == true){
+ //console.log("Točka je znotraj območja "+vre_id);
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).prop("checked", true); //oznacitev ustreznega radio button-a / checkbox v skritem menuju
+ }
+ });
+} \ No newline at end of file
diff --git a/main/survey/js/HeatMap/heatmap4Respondents.js b/main/survey/js/HeatMap/heatmap4Respondents.js
new file mode 100644
index 0000000..465b771
--- /dev/null
+++ b/main/survey/js/HeatMap/heatmap4Respondents.js
@@ -0,0 +1,13 @@
+
+function insidePoly(poly, pointx, pointy, vre_id) {
+ //console.log("Za poly: "+vre_id+" je x: "+pointx+" y: "+pointy);
+
+ var i, j;
+ var inside = false;
+ for (i = 0, j = poly.length - 1; i < poly.length; j = i++) {
+ //console.log(poly[i].x+" "+poly[i].y);
+ if(((poly[i].y > pointy) != (poly[j].y > pointy)) && (pointx < (poly[j].x-poly[i].x) * (pointy-poly[i].y) / (poly[j].y-poly[i].y) + poly[i].x) ) inside = !inside;
+ }
+ //console.log("inside je: "+inside);
+ return inside;
+} \ No newline at end of file
diff --git a/main/survey/js/ImageHotSpot/imagemapRespondent.js b/main/survey/js/ImageHotSpot/imagemapRespondent.js
new file mode 100644
index 0000000..16f3d93
--- /dev/null
+++ b/main/survey/js/ImageHotSpot/imagemapRespondent.js
@@ -0,0 +1,859 @@
+var vre_id_prej = []; //polje, ki belezi indeks prejsnjega obmocja
+var refresh = []; //polje, ki belezi, ali je bil refresh ali ne
+var refreshed = []; //polje, ki belezi, ali je bil refresh ali ne
+//init za radio grid
+function mapinitRadioGrid (spremenljivka, options, hotspot_region_visibility_option, hotspot_tooltips_option, hotspot_region_color, hotspot_visibility_color) {
+
+ $('#hotspot_image_'+spremenljivka+' .grid_table').css("display", "none"); //skrij tabelo z odgovori radio button, kjer se bodo bele�ili odgovori
+
+ hotspot_visibility_color = hotspot_visibility_color.slice(1);
+
+ //identifier za sliko na katero se veze mapa z obmocji
+ var image1 = $('#hotspot_'+spremenljivka+'_image');
+
+ //urejanje prikazovanja obmocij za respondente
+ if (hotspot_region_visibility_option == 0){ //skrij obmocja
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = false;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 1){ //pokazi obmocja
+ hotspot_region_visibility_option = true;
+ var hotspot_region_visibility_option_highlight = true;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 2){ //pokazi obmocja ob mouse over
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = true;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 3){
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = false;
+ var hotspot_region_visibility_option_clicked = true;
+ }
+
+ //za handle-anje refresh in naprej/nazaj **********************************************************************
+ //vre_id_d belezi, ali ob morebitnem odgovarjanju in naprej/nazaj ali refresh-u, kateri radio button je izbran
+ var vre_id_d = [];
+ var grid_id = [];
+
+ var hiddenInputs = $('#hotspot_image_'+spremenljivka+' .grid_table').children('tbody').children('tr');
+
+ hiddenInputs.each(function (index, value) {
+ //vre_id_d[index] = $(this).val();
+ var that = $(this);
+ //vre_id_d[index] = $(this).attr('id');
+ //console.log(vre_id_d[index]);
+ that.each(function (i, value) {
+ var this_id = $(this).attr('id');
+ var vre_id_child = $('#'+this_id).find('input[ checked="" ]').attr('vre_id'); //vre_id tistih radio buttonov, ki so izbrani
+ var grid_id_child = $('#'+this_id).find('input[ checked="" ]').val(); //vre_id tistih radio buttonov, ki so izbrani
+ //console.log("vre_id_child:"+vre_id_child+" z indeksom:"+index);
+ vre_id_d[index] = vre_id_child;
+ grid_id[vre_id_child] = grid_id_child;
+ refreshed[vre_id_child] = false;
+ //console.log("refreshed za vre_id:"+vre_id_d[index]+" je false v imagemapRespondent");
+ //console.log("vre_id:"+vre_id_d[index]);
+ });
+ //console.log("vre_id_d: "+vre_id_d[index]);
+
+ });
+
+/* $('#hotspot_image_'+spremenljivka+' .checked input[ checked="" ]').each(function (index, value) {
+ vre_id_d[index] = $(this).val();
+ console.log(vre_id_d[index]);
+ }); */
+
+
+
+ if(vre_id_d[0] === undefined){
+ refresh[spremenljivka] = false;
+ //console.log("Not refreshed");
+ }else{
+ refresh[spremenljivka] = true;
+ //console.log("Refreshed");
+ }
+
+ //za handle-anje refresh in naprej/nazaj - konec ********************************************************************
+
+ var map = $('#hotspot_'+spremenljivka+'_map');
+ var izbranaObmocja = {};
+
+ //pokazi vse atribute name, ki so children od map
+/* test.children().each(function (index, value) {
+ console.log('div' + index + ':' + $(this).attr('name'));
+ }); */
+ var obmocja = []; //polje za belezenje imen obmocij
+
+ //poberi imena obmocij (area) map in jih zabelezi b polje "obmocja"
+ map.children().each(function (index, value) {
+ obmocja[index] = $(this).attr('name');
+ });
+
+ //polje obmocja preuredi v besedilo
+ var obmocja_string = obmocja.toString();
+
+ //funkcija, ki se sprozi ob prikazovanju tooltip-a
+ function urediRadioGrid(data){
+ //console.log("Uredi Radio z data: "+data.key);
+ var vre_id = 0;
+ var identifikator = '';
+ //if(refresh[spremenljivka] && refreshed[data.key] == false){
+ if(refreshed[data.key] == false){
+ vre_id_d.forEach(function (item, i){
+ //console.log("grem cez vse, ce je refresh data.key:"+data.key);
+ //console.log("Vred_id z indeksom "+i+" je:"+item);
+ if(item == data.key){
+ //console.log("Sta enaka:"+data.key);
+ vre_id = item;
+ //console.log("Vre_id r:"+vre_id)
+ identifikator = '#vrednost_'+vre_id+"_grid_"+grid_id[vre_id];
+ }
+ });
+ }else{
+ vre_id = data.key;
+ identifikator = '#vrednost_if_'+vre_id;
+ //console.log("Vre_id not r:"+vre_id);
+ }
+ //console.log("Vre_id:"+vre_id);
+ //var identifikator = '#vrednost_if_'+vre_id;
+ //console.log("identifikator:"+identifikator);
+
+ if($(identifikator).hasClass('checked')){ //ce je checked
+ //oznaci na tooltip ustrezen radio button
+ var id = $(identifikator+' input:checked').attr("id"); //id zabelezenega radio button-a v multigrid-u
+ id = "im_"+id;
+ //console.log("id:"+id);
+ $('#'+id).prop( "checked", true ); //oznacitev ustreznega radio button-a v tooltip-u
+ }else if($(identifikator).attr('checked')){
+ //oznaci na tooltip ustrezen radio button
+ var id = $(identifikator).attr('id'); //id zabelezenega radio button-a v multigrid-u
+ id = "im_"+id;
+ //console.log("id:"+id);
+ $('#'+id).prop( "checked", true ); //oznacitev ustreznega radio button-a v tooltip-u
+ }
+
+ }
+
+ //funkcija, ki se sprozi ob kliku na obmocje
+ function pokaziNamigObKliku(data){
+ if (hotspot_tooltips_option == 2){
+ var vre_id = data.key;
+ image1.mapster('tooltip',vre_id);
+ }
+ }
+
+ //funkcija, ki uredi delovanje toolTipClose
+ function urediZapiranjeNamiga(data){
+ if (hotspot_tooltips_option == 2){ //ce je moznost prikazovanja namiga ob kliku na obmocje
+ var vre_id = data.key;
+ return ["area-click"];
+ }else if(hotspot_tooltips_option != 2){ //drugace, naj se namig zapre ob kliku na sam namig
+ return ["tooltip-click"];
+ }
+ }
+
+ //funkcija, ki uredi delovanje prikazovanja namiga
+ function urediNamig(data){
+ //urejanje prikazovanja namigov/tooltips za respondente
+ if (hotspot_tooltips_option == 0){ //Prikazi namig ob vstopu miske
+ var out = true;
+ return out;
+ }else if (hotspot_tooltips_option == 1){ //Skrij namig
+ var out = false;
+ return out;
+ } else if (hotspot_tooltips_option == 2){ //Prikazi namig ob kliku miske
+ var out = false;
+ return out;
+ }
+ }
+
+ //urejanje prikazovanja namigov/tooltips za respondente
+ if (hotspot_tooltips_option == 0){ //Prikazi namig ob vstopu miske
+ var hotspot_show_tooltips = true;
+ }else if (hotspot_tooltips_option == 1){ //Skrij namig
+ var hotspot_show_tooltips = false;
+ } else if (hotspot_tooltips_option == 2){ //Prikazi namig ob kliku miske
+ var hotspot_show_tooltips = false;
+ }
+
+ hotspot_region_color = hotspot_region_color.slice(1);
+
+ //options za prikaz ze izbranega obmocja
+ var izbrano_obmocje_prikaz = { //uredi prikaz izbranega obmocja za trenutno obmocje
+ //fillColor: '00ffff',
+ fillColor: hotspot_region_color,
+ stroke: false,
+ strokeColor: '000000',
+ strokeWidth: 2
+ };
+
+ image1
+ .mapster({
+ scaleMap: false, //zelo pomemben parameter, ker drugace se koordinate spremenijo
+ //fillOpacity: 0.4,
+ fillColor: hotspot_visibility_color,
+ //stroke: false,
+ //strokeColor: "3320FF",
+ //strokeOpacity: 0.8,
+ //strokeWidth: 2,
+ //singleSelect: true, //ce je prisoten, ni mozno pokazati vec obmocij na enkrat
+ isSelectable: false, //na false, da se ne skrije prikaz obmocja ob kliku na njega
+ mapKey: 'name',
+ listKey: 'name',
+ //showToolTip: true,
+ showToolTip: hotspot_show_tooltips,
+ //showToolTip: urediNamig,
+ highlight: hotspot_region_visibility_option_highlight,
+ //toolTipClose: ["area-click"], //ob kliku na obmocje, se tooltip zapre
+ //toolTipClose: ["tooltip-click"],
+ toolTipClose: ["image-mouseout"],
+ //toolTipClose: urediZapiranjeNamiga,
+ onShowToolTip: urediRadioGrid,
+ onClick: pokaziNamigObKliku
+ })
+ //.mapster('set',true,obmocja_string) //pokazi na sliki mape obmocij, obmocja naj bodo vidna od samega zacetka
+ //.mapster('set',hotspot_region_visibility_option,obmocja_string) //ce je ta nastavitev prisotna, ob refreshu nekaj v knjiznici se sesuje
+ .mapster('set_options', options);
+
+ if(vre_id_d[0] !== undefined){ //zadeva se sprozi ob morebitnem refresh-u strani ali naprej/nazaj po anketi
+ //console.log("Ni undefined za spr: "+spremenljivka);
+ //$('.mapster_tooltip').find('').;
+ }
+
+
+}
+
+//ob kliku na radio button v tooltip - za radio grid
+function mapdelovanjeRadioGrid(htmlobject, vre_id_d){
+ htmlobjectid = htmlobject.id.substring(3); //odstrani prve tri crke trenutnega id-ja iz tooltip-a za dobiti id iz multigrid
+
+ if ($('#'+htmlobjectid).is(':checked')){ //ce je radio button ze klikan
+ $('#'+htmlobject.id).prop( "checked", false ); //odstrani check iz tooltip-a
+ $('#'+htmlobjectid).prop( "checked", false ); //v skritem klasicnem multigrid-u odstrani ustrezen odgovor
+ }else{
+ $('#'+htmlobjectid).prop( "checked", true ); //v skritem klasicnem multigrid-u izberi ustrezen odgovor
+ refreshed[vre_id_d] = true;
+ //console.log("refreshed za vre_id:"+vre_id_d+" je "+refreshed[vre_id_d]+" v mapdelovanjeRadioGrid");
+ }
+
+}
+
+
+//init za radio
+/* var vre_id_prej = []; //polje, ki belezi indeks prejsnjega obmocja
+var refresh = []; //polje, ki belezi, ali je bil refresh ali ne */
+function mapinitRadio(spremenljivka, options, tip, hotspot_region_visibility_option, hotspot_tooltips_option, hotspot_region_color, hotspot_visibility_color) {
+
+ $('#hotspot_image_'+spremenljivka+' .variabla').css("display", "none"); //skrij radio/checkbox button odgovore, kjer se bodo bele�ili odgovori
+ $('#hotspot_image_'+spremenljivka+' .missing').css("display", ""); //pokazi missing radio/checkbox odgovore, ce so prisotni
+
+ //urejanje prikazovanja obmocij za respondente
+ if (hotspot_region_visibility_option == 0){ //skrij obmocja
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = false;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 1){ //pokazi obmocja
+ hotspot_region_visibility_option = true;
+ var hotspot_region_visibility_option_highlight = true;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 2){ //pokazi obmocja ob mouse over
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = true;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 3){
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = false;
+ var hotspot_region_visibility_option_clicked = true;
+ }
+
+ //urejanje prikazovanja namigov/tooltips za respondente
+ if (hotspot_tooltips_option == 0){ //Prikazi namig ob vstopu miske
+ hotspot_tooltips_option = true;
+ //console.log("hotspot_tooltips_option: "+hotspot_tooltips_option);
+ //var hotspot_region_visibility_option_highlight = false;
+ //var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_tooltips_option == 1){ //Skrij namig
+ hotspot_tooltips_option = false;
+ //console.log("hotspot_tooltips_option: "+hotspot_tooltips_option);
+ //var hotspot_region_visibility_option_highlight = true;
+ //var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_tooltips_option == 2){ //Prikazi namig ob kliku miske
+ hotspot_tooltips_option = false;
+ //var hotspot_region_visibility_option_highlight = true;
+ //var hotspot_region_visibility_option_clicked = false;
+ }
+
+
+ //vre_id_d belezi, ali ob morebitnem odgovarjanju in naprej/nazaj ali refresh-u, kateri radio button je izbran
+ if (tip == 1){
+ var vre_id_d = $('#hotspot_image_'+spremenljivka+' .checked input[name=vrednost_'+spremenljivka+']').val();
+ //console.log("vre_id_d: "+vre_id_d+" za spr: "+spremenljivka);
+ }else if(tip == 2){
+ var vre_id_d = [];
+ $('#hotspot_image_'+spremenljivka+' .checked input[ checked="" ]').each(function (index, value) {
+ vre_id_d[index] = $(this).val();
+ //console.log(vre_id_d[index]);
+ });
+
+/* //var vre_id_d = $('#hotspot_image_'+spremenljivka+' .checked input[name=vrednost_'+spremenljivka+']').val();
+ vre_id_d = $('#hotspot_image_'+spremenljivka+' .checked input[ checked="" ]').val();
+ console.log(vre_id_d[0]); */
+ }
+
+
+ if(vre_id_d === undefined){
+ refresh[spremenljivka] = false;
+ }else{
+ refresh[spremenljivka] = true;
+ }
+
+ var map = $('#hotspot_'+spremenljivka+'_map');
+ var izbranaObmocja = {};
+
+ //pokazi vse atribute name, ki so children od map
+/* test.children().each(function (index, value) {
+ console.log('div' + index + ':' + $(this).attr('name'));
+ }); */
+ var obmocja = []; //polje za belezenje imen obmocij
+
+ //poberi imena obmocij (area) map in jih zabelezi b polje "obmocja"
+ map.children().each(function (index, value) {
+ obmocja[index] = $(this).attr('name');
+ });
+
+ //polje obmocja preuredi v besedilo
+ var obmocja_string = obmocja.toString();
+
+ //identifier za sliko na katero se veze mapa z obmocji
+ var image1 = $('#hotspot_'+spremenljivka+'_image');
+
+ hotspot_visibility_color = hotspot_visibility_color.slice(1);
+ //options za default prikaz obmocja
+ var default_prikaz = {
+ scaleMap: false, //zelo pomemben parameter, ker drugace se koordinate spremenijo
+ isSelectable: false, //na false, da se ne skrije prikaz obmocja ob kliku na njega
+ mapKey: 'name',
+ highlight: hotspot_region_visibility_option_highlight,
+ //listKey: 'name',
+ //showToolTip: true
+ showToolTip: hotspot_tooltips_option,
+ fillColor: hotspot_visibility_color
+ };
+
+ hotspot_region_color = hotspot_region_color.slice(1);
+ //options za prikaz izbranega obmocja
+ var izbrano_obmocje_prikaz = { //uredi prikaz izbranega obmocja za trenutno obmocje
+ //fillColor: '00ffff',
+ fillColor: hotspot_region_color,
+ stroke: false,
+ strokeColor: '000000',
+ strokeWidth: 2
+ };
+
+ //funkcija, ki se sprozi ob kliku na obmocje
+/* function urediRadio(data){
+ //console.log("Uredi Radio z data: "+data.key);
+ var vre_id = data.key;
+ if ($('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).is(':checked')){ //ce je radio button ze klikan
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).prop( "checked", false); //odstranitev oznacitve ustreznega radio button-a v skritem menuju spremenljivka_4448_vrednost_23664
+ image1.mapster('set', false, vre_id);
+ image1.mapster('set', true, vre_id, default_prikaz); //uredi default prikaz obmocja za trenutno obmocje
+ }else{
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).prop( "checked", true); //oznacitev ustreznega radio button-a v skritem menuju
+ //console.log(image1);
+ image1.mapster('set', false, vre_id); //spucaj trenutno izbrano obmocje iz slike
+ image1.mapster('set', false, vre_id_prej[spremenljivka]); //spucaj prejsnje izbrano obmocje iz slike
+ if (vre_id != vre_id_prej[spremenljivka]){ //ce sta razlicna obmocja
+ image1.mapster('set', true, vre_id_prej[spremenljivka], default_prikaz); //uredi default prikaz obmocja za prejsnje obmocje
+ }
+ image1.mapster('set', true, vre_id, izbrano_obmocje_prikaz); //uredi prikaz izbranega obmocja za trenutno obmocje
+ vre_id_prej[spremenljivka] = vre_id;
+ }
+ } */
+
+ function urediObmocja(data){
+ //console.log("Uredi Radio z data: "+data.key);
+ //console.log("Clicked! hotspot_region_visibility_option_highlight je :"+hotspot_region_visibility_option_highlight);
+ var vre_id = data.key;
+ //if(hotspot_region_visibility_option_clicked == false){
+ //if ($('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).is(':checked')){ //ce je radio button ze klikan
+ if ( $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).is(':checked') || $('#missing_value_spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).is(':checked')){ //ce je radio button ali missing ze oznacen
+
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).prop( "checked", false); //odstranitev oznacitve ustreznega radio button-a v skritem menuju spremenljivka_4448_vrednost_23664
+
+ $('#missing_value_spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).prop( "checked", false); //odstranitev oznacitve ustreznega missing-a (missing_value_spremenljivka_4466_vrednost_23822)
+
+ image1.mapster('set', false, vre_id);
+
+ //image1.mapster('set', true, vre_id, default_prikaz); //uredi default prikaz obmocja za trenutno obmocje
+ image1.mapster('set', hotspot_region_visibility_option, vre_id, default_prikaz); //uredi default prikaz obmocja za trenutno obmocje
+
+ }else{ //ce radio button ni ze klikan
+
+ //console.log(image1);
+
+ image1.mapster('set', false, vre_id); //spucaj trenutno izbrano obmocje iz slike
+
+ if ( (vre_id_d !== undefined) && (refresh[spremenljivka] == true) ){ //ce sta razlicna obmocja
+ //console.log("Ni undefined");
+ vre_id_prej[spremenljivka] = vre_id_d;
+ refresh[spremenljivka] = false;
+ }
+
+ if (tip == 1){ //ce je radio tip postavitve, je potrebno ustrezno urediti obmocja
+ image1.mapster('set', false, vre_id_prej[spremenljivka]); //spucaj prejsnje izbrano obmocje iz slike
+ if (vre_id != vre_id_prej[spremenljivka]){ //ce sta razlicna obmocja
+ //image1.mapster('set', true, vre_id_prej[spremenljivka], default_prikaz); //uredi default prikaz obmocja za prejsnje obmocje
+ image1.mapster('set', hotspot_region_visibility_option, vre_id_prej[spremenljivka], default_prikaz); //uredi default prikaz obmocja za prejsnje obmocje
+
+ }
+ }
+
+ //ce je checkbox in je missing, ki je oznacen
+ if( tip == 2 && ($('#hotspot_image_'+spremenljivka).children().hasClass('missing')) && ($('#hotspot_image_'+spremenljivka).children().hasClass('checked')) ){
+ //console.log("Missing"); //nic ne narediti
+ }else{ //drugace
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).prop( "checked", true); //oznacitev ustreznega radio button-a / checkbox v skritem menuju
+ image1.mapster('set', true, vre_id, izbrano_obmocje_prikaz); //uredi prikaz izbranega obmocja za trenutno obmocje
+ //image1.mapster('set', hotspot_region_visibility_option, vre_id, izbrano_obmocje_prikaz); //uredi prikaz izbranega obmocja za trenutno obmocje
+ }
+
+ vre_id_prej[spremenljivka] = vre_id;
+
+ }
+ //}else if(hotspot_region_visibility_option_clicked == true){
+ // image1.mapster('set', hotspot_region_visibility_option_clicked, vre_id);
+ //console.log("Clicked! hotspot_region_visibility_option_highlight je :"+hotspot_region_visibility_option);
+ //}
+ }
+
+
+ image1
+ .mapster({
+ scaleMap: false, //zelo pomemben parameter, ker drugace se koordinate spremenijo
+ isSelectable: false, //na false, da se ne skrije prikaz obmocja ob kliku na njega
+ mapKey: 'name',
+ highlight: hotspot_region_visibility_option_highlight,
+ //listKey: 'name',
+ //showToolTip: true,
+ showToolTip: hotspot_tooltips_option,
+ onClick: urediObmocja,
+ fillColor: hotspot_visibility_color
+ })
+ //.mapster('set',true,obmocja_string) //pokazi na sliki mape obmocij, obmocja naj bodo vidna od samega zacetka
+ .mapster('set', hotspot_region_visibility_option, obmocja_string) //pokazi na sliki mape obmocij, obmocja naj bodo vidna od samega zacetka
+ .mapster('set_options', options);
+
+ if(vre_id_d !== undefined){ //zadeva se sprozi ob morebitnem refresh-u strani ali naprej/nazaj po anketi
+ //console.log("Ni undefined za spr: "+spremenljivka);
+ image1.mapster('set', false, vre_id_d); //spucaj trenutno izbrano obmocje iz slike
+ image1.mapster('set', true, vre_id_d, izbrano_obmocje_prikaz); //uredi prikaz prej izbranega obmocja za tole obmocje
+ //image1.mapster('set', hotspot_region_visibility_option, vre_id_d, izbrano_obmocje_prikaz); //uredi prikaz prej izbranega obmocja za tole obmocje
+ }
+}
+
+
+//init za ranking
+function mapinitRanking (spremenljivka, options, hotspot_region_visibility_option, hotspot_tooltips_option, hotspot_region_color, hotspot_visibility_color) {
+
+ $('#hotspot_image_'+spremenljivka+' .variabla').css("display", "none"); //skrij ranking ostevilcevanje, kjer se bodo bele�ili odgovori
+ //$('#hotspot_image_'+spremenljivka+' .komentar').css("display", "none"); //skrij textarea, kjer se bodo bele�ili komentarji
+
+ hotspot_visibility_color = hotspot_visibility_color.slice(1);
+
+ //identifier za sliko na katero se veze mapa z obmocji
+ var image1 = $('#hotspot_'+spremenljivka+'_image');
+
+ //urejanje prikazovanja obmocij za respondente
+ if (hotspot_region_visibility_option == 0){ //skrij obmocja
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = false;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 1){ //pokazi obmocja
+ hotspot_region_visibility_option = true;
+ var hotspot_region_visibility_option_highlight = true;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 2){ //pokazi obmocja ob mouse over
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = true;
+ var hotspot_region_visibility_option_clicked = false;
+ }else if (hotspot_region_visibility_option == 3){
+ hotspot_region_visibility_option = false;
+ var hotspot_region_visibility_option_highlight = false;
+ var hotspot_region_visibility_option_clicked = true;
+ }
+
+ //za handle-anje refresh in naprej/nazaj **********************************************************************
+ //vre_id_d belezi, ali ob morebitnem odgovarjanju in naprej/nazaj ali refresh-u, kateri radio button je izbran
+ var vre_id_d = [];
+
+
+ var values = [];
+
+ //preleti skrite odgovore razvrscanje-ostevilcevanje in belezi vrednosti odgovorov ####################
+ $('#hotspot_image_'+spremenljivka+' .variabla input').each(function(index){
+ //console.log("value: "+$(this).attr('value'));
+ var value = $(this).attr('value');
+ var vre_id = $(this).attr('vred_id');
+ //console.log("vre_id po refreshu: "+vre_id);
+ if(value!=''){
+ values[vre_id] = value;
+ refreshed[vre_id] = false;
+ $(this).parent().addClass('checked'); //dodaj info, da je prisoten odgovor
+ }else{
+ refreshed[vre_id] = true;
+ }
+ //console.log("vrednosti odgovorov po refreshu: "+value+" z indeksom: "+index);
+ });
+
+
+ var valuesLength = values.length; //hrani stevilo nepraznih odgovorov
+ //console.log("Velikost polja values: "+valuesLength);
+
+ //preleti skrite odgovore razvrscanje-ostevilcevanje in belezi vrednosti odgovorov - konec ##############
+
+ //za handle-anje refresh in naprej/nazaj - konec ********************************************************************
+
+ var map = $('#hotspot_'+spremenljivka+'_map');
+ var izbranaObmocja = {};
+
+ //pokazi vse atribute name, ki so children od map
+/* test.children().each(function (index, value) {
+ console.log('div' + index + ':' + $(this).attr('name'));
+ }); */
+ var obmocja = []; //polje za belezenje imen obmocij
+
+ //poberi imena obmocij (area) map in jih zabelezi b polje "obmocja"
+ map.children().each(function (index, value) {
+ obmocja[index] = $(this).attr('name');
+ });
+
+ //polje obmocja preuredi v besedilo
+ var obmocja_string = obmocja.toString();
+
+ //funkcija, ki se sprozi ob prikazovanju tooltip-a
+ function urediRadioGrid(data){
+
+ var vre_id = 0;
+ var identifikator = '';
+ vre_id = data.key;
+
+ // ce se je zgodil refresh, ali se je uporabnik vrnil na stran z vprasanjem, zapolni odgovore
+ if(refreshed[data.key] == false){
+
+ $('#im_vrednost_if_'+vre_id+' .category input').each(function(index){
+ var id = $(this).attr('id');
+ var vrstni_red = $(this).attr('vrstni_red');
+
+ if(vrstni_red == values[vre_id]){
+ $('#'+id).prop( "checked", true );
+
+ // disable ostale odgovore, ki so bili izbrani ze drugje
+ disableOthers(spremenljivka, vre_id);
+
+ // enable trenuten odgovor, ce je disable-an
+ enableCurrent(id);
+ }
+ });
+ }
+ else{
+ identifikator = '#vrednost_if_'+vre_id;
+ }
+
+ // ce je checked
+ if($(identifikator).hasClass('checked')){
+
+ // oznaci na tooltip ustrezen radio button
+ var id = $(identifikator+' input').attr('id'); //id zabelezenega odgovora
+ id = $('#vrednost_if_'+vre_id).attr('tooltipid');
+
+ id = 'im_'+id;
+ $('#'+id).prop( "checked", true ); //oznacitev ustreznega radio button-a v tooltip-u
+
+ // disable ali skriti ostale odgovore, ki so bili izbrani ze drugje
+ disableOthers(spremenljivka, vre_id);
+
+ // enable trenuten odgovor, ce je disable-an
+ enableCurrent(id);
+ }
+ else if($(identifikator).attr('checked')){
+ // oznaci na tooltip ustrezen radio button
+ var id = $(identifikator).attr('id'); //id zabelezenega radio button-a v multigrid-u
+ id = "im_"+id;
+
+ $('#'+id).prop( "checked", true ); //oznacitev ustreznega radio button-a v tooltip-u
+ }
+ else if(refreshed[data.key]==true){
+ // enable trenuten odgovor, ce je disable-an
+ enableCurrent(id);
+
+ // disable ostale odgovore, ki so bili izbrani ze drugje
+ disableOthers(spremenljivka, vre_id);
+ }
+
+ // ZA KOMENTAR
+ var identifikatorKomentar = '#vrednost_if_komentar_'+vre_id;
+ if($(identifikatorKomentar+' input').attr('value')){ //ce je komentar prisoten v skritem textarea
+ var komentarTooltip = $(identifikatorKomentar+' input').attr('value');
+ $('#im_vrednost_komentar_'+vre_id).attr('value', komentarTooltip);
+ }
+ }
+
+ // funkcija, ki se sprozi ob kliku na obmocje
+ function pokaziNamigObKliku(data){
+ if (hotspot_tooltips_option == 2){
+ var vre_id = data.key;
+ image1.mapster('tooltip', vre_id);
+ }
+ }
+
+ //funkcija, ki uredi delovanje toolTipClose
+ function urediZapiranjeNamiga(data){
+ if (hotspot_tooltips_option == 2){ //ce je moznost prikazovanja namiga ob kliku na obmocje
+ var vre_id = data.key;
+ return ["area-click"];
+ }else if(hotspot_tooltips_option != 2){ //drugace, naj se namig zapre ob kliku na sam namig
+ return ["tooltip-click"];
+ }
+ }
+
+ //funkcija, ki uredi delovanje prikazovanja namiga
+ function urediNamig(data){
+ //urejanje prikazovanja namigov/tooltips za respondente
+ if (hotspot_tooltips_option == 0){ //Prikazi namig ob vstopu miske
+ var out = true;
+ return out;
+ }else if (hotspot_tooltips_option == 1){ //Skrij namig
+ var out = false;
+ return out;
+ } else if (hotspot_tooltips_option == 2){ //Prikazi namig ob kliku miske
+ var out = false;
+ return out;
+ }
+ }
+
+ //urejanje prikazovanja namigov/tooltips za respondente
+ if (hotspot_tooltips_option == 0){ //Prikazi namig ob vstopu miske
+ var hotspot_show_tooltips = true;
+ }
+ else if (hotspot_tooltips_option == 1){ //Skrij namig
+ var hotspot_show_tooltips = false;
+ }
+ else if (hotspot_tooltips_option == 2){ //Prikazi namig ob kliku miske
+ var hotspot_show_tooltips = false;
+ }
+
+ hotspot_region_color = hotspot_region_color.slice(1);
+
+ // options za prikaz ze izbranega obmocja
+ var izbrano_obmocje_prikaz = { //uredi prikaz izbranega obmocja za trenutno obmocje
+ //fillColor: '00ffff',
+ fillColor: hotspot_region_color,
+ stroke: false,
+ strokeColor: '000000',
+ strokeWidth: 2
+ };
+
+
+ // samo pri sazu anketi - obarvamo oznacena obmocja
+ var areas = [];
+ if($('#hotspot_image_' + spremenljivka + '_sazu').val() == '1'){
+
+ var colors = {
+ 1: '009900',
+ 2: '88ff00',
+ 3: 'ffff00',
+ 4: 'ff9900',
+ 5: 'ff3300',
+ 6: 'bb0000'
+ };
+
+ $('#hotspot_image_' + spremenljivka + ' .variabla.checked').each(function(i, obj) {
+ var id_string = $(obj).attr('id');
+ var id = id_string.split('_');
+
+ var vrstni_red = $(obj).find('input').val();
+
+ // Obarvamo obmocje z vrednostjo
+ var area = {
+ key: id[2].toString(),
+ fillColor: colors[vrstni_red],
+ selected: true
+ }
+
+ areas.push(area);
+ });
+ }
+
+ image1
+ .mapster({
+ scaleMap: false, //zelo pomemben parameter, ker drugace se koordinate spremenijo
+
+ //fillOpacity: 0.4,
+ fillColor: hotspot_visibility_color,
+
+ stroke: true,
+ strokeColor: "1e88e5",
+ strokeOpacity: 0.8,
+ strokeWidth: 2,
+
+ singleSelect: false, //ce je prisoten, ni mozno pokazati vec obmocij na enkrat
+ //isSelectable: false, //na false, da se ne skrije prikaz obmocja ob kliku na njega
+ mapKey: 'name',
+ listKey: 'name',
+
+ showToolTip: hotspot_show_tooltips,
+ highlight: hotspot_region_visibility_option_highlight,
+
+ toolTipClose: [],
+
+ onShowToolTip: urediRadioGrid,
+ onClick: pokaziNamigObKliku,
+
+ isDeselectable: false,
+
+ areas: areas, // samo pri sazu anketi - obarvamo oznacena obmocja
+ })
+ //.mapster('set',hotspot_region_visibility_option,obmocja_string) //ce je ta nastavitev prisotna, ob refreshu nekaj v knjiznici se sesuje
+ .mapster('set_options', options);
+}
+
+
+
+//ob kliku na radio button v tooltip - za ranking
+function mapdelovanjeRanking(htmlobject, vre_id_d){
+
+ htmlobjectid = htmlobject.id.substring(3); //odstrani prve tri crke trenutnega id-ja iz tooltip-a za dobiti id iz multigrid
+ var vrstni_red = 0;
+
+ //ce je ze prisoten odgovor v razvrscanju
+ if ($('#vrednost_if_'+vre_id_d+' input').attr('value') == $('#im_'+htmlobjectid).attr('vrstni_red')){
+
+ $('#'+htmlobject.id).prop( "checked", false ); //odstrani check iz tooltip-a
+ $('#vrednost_if_'+vre_id_d+' input').val(''); //v skritem razvrscanju odstrani ustrezen odgovor
+ $('#vrednost_if_'+vre_id_d+' input').attr('value', ''); //v skritem razvrscanju uredi odgovor, da se bo belezil v bazo
+
+ refreshed[vre_id_d] = true;
+ }
+ else{
+ vrstni_red = $('#im_'+htmlobjectid).attr('vrstni_red');
+
+ $('#vrednost_if_'+vre_id_d+' input').val(vrstni_red); //v skritem razvrscanju uredi odgovor, da se vidi
+ $('#vrednost_if_'+vre_id_d+' input').attr('value', vrstni_red); //v skritem razvrscanju uredi odgovor, da se bo belezil v bazo
+ $('#vrednost_if_'+vre_id_d).attr('tooltipid', htmlobjectid); //zabelezi id tooltip-a za kasneje
+
+ refreshed[vre_id_d] = true;
+ }
+}
+//ob kliku na radio button v tooltip - za ranking za SAZU
+function mapdelovanjeRankingSazu(htmlobject, vre_id_d){
+
+ var colors = {
+ 1: '009900',
+ 2: '88ff00',
+ 3: 'ffff00',
+ 4: 'ff9900',
+ 5: 'ff3300',
+ 6: 'bb0000'
+ };
+
+ htmlobjectid = htmlobject.id.substring(3); //odstrani prve tri crke trenutnega id-ja iz tooltip-a za dobiti id iz multigrid
+ var vrstni_red = 0;
+
+ //ce je ze prisoten odgovor v razvrscanju
+ if ($('#vrednost_if_'+vre_id_d+' input').attr('value') == $('#im_'+htmlobjectid).attr('vrstni_red')){
+
+ $('#'+htmlobject.id).prop( "checked", false ); //odstrani check iz tooltip-a
+ $('#vrednost_if_'+vre_id_d+' input').val(''); //v skritem razvrscanju odstrani ustrezen odgovor
+ $('#vrednost_if_'+vre_id_d+' input').attr('value', ''); //v skritem razvrscanju uredi odgovor, da se bo belezil v bazo
+
+ refreshed[vre_id_d] = true;
+
+ // Razbarvamo obmocje
+ colorArea(vre_id_d.toString(), 'ffffff');
+ }
+ else{
+ vrstni_red = $('#im_'+htmlobjectid).attr('vrstni_red');
+
+ $('#vrednost_if_'+vre_id_d+' input').val(vrstni_red); //v skritem razvrscanju uredi odgovor, da se vidi
+ $('#vrednost_if_'+vre_id_d+' input').attr('value', vrstni_red); //v skritem razvrscanju uredi odgovor, da se bo belezil v bazo
+ $('#vrednost_if_'+vre_id_d).attr('tooltipid', htmlobjectid); //zabelezi id tooltip-a za kasneje
+
+ refreshed[vre_id_d] = true;
+
+ // Obarvamo obmocje
+ colorArea(vre_id_d.toString(), colors[vrstni_red]);
+ }
+}
+
+// ob pisanju v textarea za komentar v tooltip - za ranking
+function mapdelovanjeRankingKomentar(textarea_id, comment){
+
+ // v skritem razvrscanju uredi odgovor, da se bo belezil v bazo
+ $('#' + textarea_id).attr('value', comment);
+
+ //console.log("komentar: " + comment);
+}
+
+
+//disable ostale odgovore, ki so bili izbrani ze drugje
+function disableOthers(spremenljivka, vre_id){
+
+ $('#hotspot_image_'+spremenljivka+' .checked input').each(function(){
+ var value = $(this).attr('value');
+
+ $('#im_vrednost_if_'+vre_id+' .category input').each(function(){
+ var vrstni_red = $(this).attr('vrstni_red');
+
+ if(vrstni_red == value){
+
+ $(this).parent().addClass('disabled-item'); // dodamo class za disabled
+ $(this).attr('disabled','disabled'); // disable odgovor, ki je ze izbran
+ $(this).parent().css('cursor','not-allowed'); // spremeni kurzor miske odgovora, ki je ze izbran
+ }
+ });
+ });
+}
+
+
+//enable trenuten odgovor, ce je disable-an
+function enableCurrent(id){
+
+ $('#'+id).parent().removeClass('disabled-item'); // odstrtanimo class za disabled
+ $('#'+id).parent().addClass('active-item'); // dodamo class za active
+
+ $('#'+id).prop( "disabled", "" );
+ $('#'+id).parent().css('cursor','pointer');
+}
+
+// Zapremo tooltip
+function removeMapsterTooltip(){
+
+ // Dobimo id obmocja za katerega imamo odprt tooltip
+ var id_string = $(".mapster_tooltip > div").attr('id');
+ var id = id_string.split('_');
+
+ // Deselectamo obmocje tooltipa - samo ce ni oznacen noben radio gumb
+ if(!$(".mapster_tooltip .question input:checked").val())
+ $('img').mapster('set', false, id);
+
+ $('img').mapster('tooltip');
+}
+
+// Pobarvamo doloceno obmocje
+function colorArea(area_id, color){
+
+ var newOp = {
+ areas: [
+ {
+ key: area_id,
+ fillColor: color
+ }
+ ]
+ };
+ // Deselectamo obmocje
+ $('img').mapster('set', false, area_id);
+ // Nastavimo usrezno barvo
+ $('img').mapster('set_options', newOp);
+ // Ga na novo selectamo
+ $('img').mapster('set', true, area_id);
+}
diff --git a/main/survey/js/Maps/Geocoding.js b/main/survey/js/Maps/Geocoding.js
new file mode 100644
index 0000000..836d215
--- /dev/null
+++ b/main/survey/js/Maps/Geocoding.js
@@ -0,0 +1,92 @@
+// Author: Uroš Podkrižnik (17.12.2015)
+// Tip vprasanja = 26
+
+// GEOCODING
+
+/**
+ * pretvorba iz latitude, longitude v berljiv naslov
+ * funkcija vrne String - results[0] - prvi (najdaljsi naslov)
+ * @param {type} pos - koordinate - objekt {lat: ???, lng: ???}
+ * @param {type} callback - function - ker je geocode asinhrona funkcija, se uporabi, da se vrne rezultat
+ * @returns {undefined}
+ */
+function GeocodingF(pos, callback) {
+ geocoder.geocode({'location': pos}, function (results, status) {
+
+ // ce je status OK - pridobil informacije o naslovu
+ if (status === google.maps.GeocoderStatus.OK) {
+ //console.log(results);//[0]= polni naslov, [1]= Ljubljana, Slovenija,....
+ if (results[0]) {
+ //console.log(results[0].formatted_address);
+ //vrne rezultat (Objekt s polnim naslovom)
+ callback(results[0]);
+ } else {
+ console.log('No results found');
+ callback(null);
+ }
+ }
+ // ce je prislo do napake
+ else {
+ console.log('Geocoder failed due to: ' + status);
+ if(status == 'ZERO_RESULTS'){
+ var obj = {formatted_address: ""}
+ callback(obj);
+ }
+ else
+ callback(null);
+ }
+ });
+}
+
+/**
+ * centriranje na zemljevidu (kaj se bo prikazalo na zemljevidu / zajelo v okvir)
+ * @param {type} centerInMap - String - naslov, ki ga naj zemljevid zajame v okvir
+ * @param {type} map - mapa/zemljevid
+ * @returns {undefined}
+ */
+function centrirajMap (centerInMap, map){
+ geocoderFromAddress(centerInMap, function(place){
+ if(place){
+ map.setCenter(place.geometry.location);
+ map.fitBounds(place.geometry.viewport);
+ //povecaj zoom za 1, ker google naredi prevec oddaljeno
+ //pri vecji povrsini na mapi (npr Slovenija), ne dela ok
+ //map.setZoom(map.getZoom()+1);
+ }
+ });
+}
+
+/**
+ * Geocoding from address to places, in callback only first place is returned
+ * @param {type} address - address to geocode
+ * @param {type} callback - callback function to call when place is found
+ * @returns {undefined}
+ */
+function geocoderFromAddress(address, callback){
+ var delay = 100;
+ var stej_poizvedbe = 0;
+
+ geocoder.geocode({'address': address}, function (results, status) {
+ if (status === google.maps.GeocoderStatus.OK) {
+ callback(results[0]);
+ }
+ //zelo redko pride do tega, recimo ce uporabnik na polno stanca lokacije
+ else if(status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT){
+ if(stej_poizvedbe < 10){
+ setTimeout(geocoderFromAddress(address, callback), delay);
+ stej_poizvedbe++;
+ delay += 100;
+ }
+ else
+ console.log('Geocoder error: OVER_QUERY_LIMIT; repeated: '+stej_poizvedbe);
+ }
+ //ce ni najdenih rezultatov za vpisan naslov v nastavitvah (fokus)
+ else if(status === google.maps.GeocoderStatus.ZERO_RESULTS){
+ alert(lang['srv_branching_no_results_geo_map']+': '+address);
+ }
+ else
+ console.log('Geocoder error: ' + status);
+
+ return null;
+ });
+} \ No newline at end of file
diff --git a/main/survey/js/Maps/KlikNaMapo.js b/main/survey/js/Maps/KlikNaMapo.js
new file mode 100644
index 0000000..4effd1e
--- /dev/null
+++ b/main/survey/js/Maps/KlikNaMapo.js
@@ -0,0 +1,43 @@
+// Author: Uroš Podkrižnik (17.12.2015)
+// Tip vprasanja = 26
+
+// KLIK NA MAPO
+
+/**
+ * izvrsi funkcionalnost za klik na zemljevid
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @returns {undefined}
+ */
+function klikNaMapo(spremenljivka) {
+ //pridobi mapo spremenljivke
+ var map = document.getElementById("map_"+spremenljivka).gMap;
+
+ // ko user klikne na mapo, funkcija vrne pozicijo (koordinate - position) ter kreira
+ google.maps.event.addListener(map, 'click', function (event) {
+
+ //koordinate
+ var pos = {
+ lat: event.latLng.lat(),
+ lng: event.latLng.lng()
+ };
+
+ //za omejitev odgovorov
+ if(ml_sprem.indexOf(spremenljivka) > -1 || max_mark[spremenljivka] != st_markerjev[spremenljivka]){
+ // naslov se pridobi, da se klice geocoding
+ GeocodingF(pos, function (data) {
+ //ce ne vrne null - je nasel naslov
+ if (data != null) {
+
+ //kreira marker na lokaciji, kjer je uporabnik kliknil
+ createMarker(spremenljivka, data.formatted_address, pos, false);
+
+ } else {
+ //odpre se okno, ce je prislo do napake - null - (mozen je tudi prekratek delay med geocoding requesti)
+ alert(lang['srv_resevanje_alert_location_not_found_map']);
+ }
+ });
+ }
+
+ return pos;
+ });
+} \ No newline at end of file
diff --git a/main/survey/js/Maps/MapDeclaration.js b/main/survey/js/Maps/MapDeclaration.js
new file mode 100644
index 0000000..7ca8a7f
--- /dev/null
+++ b/main/survey/js/Maps/MapDeclaration.js
@@ -0,0 +1,323 @@
+// Author: Uroš Podkrižnik (1.7.2016)
+// Tip vprasanja = 26
+
+//DECLARATION
+
+//GLOBALNE SPREMENLJIVKE ZA VSE SPREMENLJIVKE TIP 26 NA ENI STRANI
+//mej/okvira prikaza na zemljevidu objekt za vsako spremenljivko
+var bounds = {},
+ //objekt stevila vseh markerjev za vsako spremenljivk posebej
+ st_markerjev = {},
+ //object of number of shapes and ID of last shape for every variable ({spr_id: {'count': 5, 'last_id': 9}, ...})
+ //'last_id' is not fully reliable as it is used for shapes colours
+ // -> to make it reliable, method must be creaed to store all id's and removing last id at shame removal
+ st_shapes = {},
+ //infowindow iz API-ja, za prikaz markerja in informacije o markerju
+ infowindow,
+ //array id-jev spremenljivk, ki so tipa moja lokacija (max 1 marker)
+ ml_sprem = [],
+ //array id-jev spremenljivk, ki imajo F user location
+ usrLoc_sprem = [],
+ geocoder,
+ //ce je true, se do skript dostopa iz podatkov, analiz
+ //v primeru, ko se gre za resevanje mora vedno biti false
+ viewMode = false,
+ //objekt id spremenljivka : boolean, kjer je true, ce spremenljivka
+ //uporablja F z podvprasanjem v infowindow markerja
+ podvprasanje = {},
+ //objekt id spremenljivka : string, kjer je naslov podvprasanja, ce
+ //uporablja F z podvprasanjem v infowindow markerja
+ podvprasanje_naslov = {},
+ //objekt id spremenljivka : int, kjer je int stevilo max
+ //dovoljenih markerjev na mapi
+ max_mark = {},
+ //objekt vseh markerjev na strani (respondetn ali branching) {spr_id:[markers array]}
+ allMarkers = {},
+ //objekt id spremenljivka : marker
+ //potrebujejo ga samo spremenljivke tipa moja lokacija (max 1 marker)
+ //uporablja se za brisanje prejsnjega markerja na mapi
+ mlmarker = {},
+ //colors for shapes - polylines and polgons
+ mapShapeColors = ['c0504d', '4f81bd', '9bbb59', '8064a2', '4bacc6', 'f79646', '92a9cf', '8c0000', 'f00800', 'ff8a82', 'f2c4c8', '0b0387', '0400fc', '9794f2'],
+ deleteMenu;
+
+function mapsAPIseNi(MapDeclaration) {
+ //prveri, ce je element skripte APIja ze kreiran
+ var google_api = document.getElementById("google_api");
+ //ce je ze kreiran, dodaj funkcijo v onload (da se mapa kreira, ko se api dokoncno naloada)
+ if (google_api) {
+ //element z apijem ze obstaja, se pravi da se se loada
+ //deklariraj funkcijo za onload
+ var addFunctionOnLoad = function (callback) {
+ if (google_api.addEventListener) {
+ google_api.addEventListener('load', callback, false);
+ } else {
+ google_api.attachEvent('onload', callback);
+ }
+ };
+ //dodaj funkcijo v onload
+ addFunctionOnLoad(MapDeclaration);
+ }
+ //ce element skripte za API se ne obstaja, jo nalozi
+ else
+ loadGoogleMapsScript(function () {
+ MapDeclaration();
+ initializeDeleteMenu();
+ });
+}
+
+//includaj oz. nalozi skripno google APIja ter nastavi mapo
+function loadGoogleMapsScript(callback)
+{
+ // Adding the script tag to the head as suggested before
+ var head = document.getElementsByTagName('head')[0];
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.id = 'google_api';
+ script.src = "https://maps.googleapis.com/maps/api/js?key="+google_maps_API_key+"&libraries=places,drawing";
+
+ // Then bind the event to the callback function.
+ // There are several events for cross browser compatibility.
+ script.onreadystatechange = callback;
+ script.onload = callback;
+
+ // Fire the loading
+ head.appendChild(script);
+}
+
+/**
+ * Used for clearing a map of polyline or polygon
+ * @param {type} controlDiv - div to put in custom settings - buttons
+ * @returns {div element} element of a control
+ */
+function drawingControl(controlDiv) {
+
+ controlDiv.style.padding = '10px';
+
+ // Set CSS for the control border.
+ var controlUI = document.createElement('div');
+ controlUI.style.backgroundColor = '#fff';
+ controlUI.style.border = '2px solid #fff';
+ controlUI.style.borderRadius = '3px';
+ controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
+ controlUI.style.cursor = 'pointer';
+ controlUI.style.marginBottom = '22px';
+ controlUI.style.textAlign = 'center';
+ controlUI.style.display = 'inline-block';
+ controlUI.title = lang['srv_vprasanje_button_map_clear'];
+ controlDiv.appendChild(controlUI);
+
+ // Set CSS for the control interior.
+ var controlText = document.createElement('div');
+ controlText.style.color = 'rgb(25,25,25)';
+ controlText.style.fontFamily = 'Roboto,Arial,sans-serif';
+ controlText.style.fontSize = '16px';
+ controlText.style.lineHeight = '28px';
+ controlText.style.paddingLeft = '5px';
+ controlText.style.paddingRight = '5px';
+ controlText.innerHTML = lang['srv_vprasanje_button_map_clear'];
+ controlUI.appendChild(controlText);
+
+ return controlUI;
+}
+
+/**
+ * create bounds of all points of polygon/polyline
+ * @param {type} path gon.getPath()
+ * @param {int} spremenljivka - id spremenljivke
+ */
+function createBoundsFromPath(path, spremenljivka) {
+ var pathArray = path.getArray();
+ for (var i = 0, n = pathArray.length; i < n; i++) {
+ var latLng = pathArray[i];
+ bounds[spremenljivka].extend(latLng);
+ }
+}
+
+//pretvori lat in lng v en string
+//uporabi se kot kljuc markerja za ID iz objekta markers
+function getMarkerUniqueId(lat, lng, spr) {
+ var zdot = spr + '_' + lat + '_' + lng;
+ return zdot.split('.').join("-");
+}
+
+/**
+ * Find out if marker already exist on this variable whit this address
+ * @param {type} add - address to find if exist at some marker
+ * @param {type} spr - variable id
+ * @returns {type} - marker if exist, null otherwise
+ */
+function findMarkerFromAddress(add, spr) {
+ for (var i = 0; i < allMarkers[spr].length; i++) {
+ if (allMarkers[spr][i].address === add)
+ return allMarkers[spr][i];
+ }
+ return null;
+}
+
+////////////BRISANJE TOCK
+function initializeDeleteMenu() {
+ /**
+ * A menu that lets a user delete a selected vertex of a path.
+ * @constructor
+ */
+ function DeleteMenu() {
+ this.div_ = document.createElement('div');
+ this.div_.className = 'maps-delete-menu';
+ this.div_.innerHTML = lang['srv_vprasanje_delete_point_map'];
+
+ var menu = this;
+ google.maps.event.addDomListener(this.div_, 'click', function (e) {
+ //this prevents to trigger click event on map (klikNaMapo.js)
+ e.cancelBubble = true;
+ if (e.stopPropagation) e.stopPropagation();
+
+ //remove whole shape
+ if(menu.get('shape') && menu.get('vertex') == undefined && menu.get('marker') == undefined)
+ menu.removeShape();
+ //remove vertex in shape or marker
+ else
+ menu.removeVertex();
+ });
+ }
+ DeleteMenu.prototype = new google.maps.OverlayView();
+
+ DeleteMenu.prototype.onAdd = function () {
+ var deleteMenu = this;
+ var map = this.getMap();
+ this.getPanes().floatPane.appendChild(this.div_);
+
+ // mousedown anywhere on the map except on the menu div will close the
+ // menu.
+ this.divListener_ = google.maps.event.addDomListener(map.getDiv(), 'mousedown', function (e) {
+ if (e.target != deleteMenu.div_) {
+ deleteMenu.close();
+ }
+ }, true);
+ };
+
+ DeleteMenu.prototype.onRemove = function () {
+ google.maps.event.removeListener(this.divListener_);
+ this.div_.parentNode.removeChild(this.div_);
+
+ // clean up
+ this.set('position');
+ this.set('shape');
+ this.set('vertex');
+ this.set('spremenljivka');
+ this.set('DrawingControl');
+ this.set('drawingManager');
+ this.set('marker');
+ this.set('markerId');
+ };
+
+ DeleteMenu.prototype.close = function () {
+ this.setMap(null);
+ };
+
+ DeleteMenu.prototype.draw = function () {
+ var position = this.get('position');
+ var projection = this.getProjection();
+
+ if (!position || !projection) {
+ return;
+ }
+
+ var point = projection.fromLatLngToDivPixel(position);
+ this.div_.style.top = point.y + 'px';
+ this.div_.style.left = point.x + 'px';
+ };
+
+ /**
+ * Opens the menu at a vertex of a given path.
+ */
+ DeleteMenu.prototype.open = function (map, shape, vertex, spremenljivka, DrawingControl, drawingManager, marker, markerId) {
+ if(shape)
+ this.set('position', shape.getPath().getAt(vertex));
+ else if(marker)
+ this.set('position', marker.getPosition());
+
+ this.set('shape', shape);
+ this.set('vertex', vertex);
+ this.set('spremenljivka', spremenljivka);
+ this.set('DrawingControl', DrawingControl);
+ this.set('drawingManager', drawingManager);
+ this.set('marker', marker);
+ this.set('markerId', markerId);
+ this.setMap(map);
+ this.draw();
+ };
+
+ /**
+ * Opens the menu at a geofence.
+ */
+ DeleteMenu.prototype.open_shape = function (map, shape, position, spremenljivka) {
+ this.set('position', position);
+ this.set('shape', shape);
+ this.set('spremenljivka', spremenljivka);
+ this.setMap(map);
+ this.draw();
+ };
+
+ /**
+ * Deletes the vertex from the path.
+ */
+ DeleteMenu.prototype.removeVertex = function () {
+ var spremenljivka = this.get('spremenljivka');
+ //shape
+ var shape = this.get('shape');
+ var vertex = this.get('vertex');
+ var DrawingControl = this.get('DrawingControl');
+ var drawingManager = this.get('drawingManager');
+ //marker
+ var marker = this.get('marker');
+ var markerId = this.get('markerId');
+
+ if ((!shape || vertex == undefined) && !marker) {
+ this.close();
+ return;
+ }
+
+ //removing marker
+ if(marker){
+ //accessed from respondent
+ if(markerId)
+ removeMarker(spremenljivka, marker, markerId);
+ //accessed from admin
+ else
+ removeMarkerVM(spremenljivka, marker);
+ }
+ //removing shape
+ else if(shape){
+ shape.getPath().removeAt(vertex);
+
+ if (shape.getPath().length < 2) {
+ //accessed from respondent
+ if(DrawingControl != null && drawingManager != null)
+ //handle visibility of tools
+ clearAndMakeDrawableAgain(spremenljivka, shape, DrawingControl, drawingManager);
+ //accessed from admin
+ else
+ //remove shape from DB
+ deleteLineInDB(spremenljivka, shape);
+ }
+ }
+ this.close();
+ };
+
+ /**
+ * Deletes the whole shape.
+ */
+ DeleteMenu.prototype.removeShape = function () {
+ //shape
+ var shape = this.get('shape');
+
+ //removing shape from DB and map
+ if(shape){
+ maza_delete_geofence(shape);
+ }
+ this.close();
+ };
+
+ deleteMenu = new DeleteMenu();
+} \ No newline at end of file
diff --git a/main/survey/js/Maps/Markers.js b/main/survey/js/Maps/Markers.js
new file mode 100644
index 0000000..cb37863
--- /dev/null
+++ b/main/survey/js/Maps/Markers.js
@@ -0,0 +1,317 @@
+// Author: Uroš Podkrižnik (17.12.2015)
+// Tip vprasanja = 26
+
+//MARKERS
+
+/**
+ * Ce obstajajo podatki v bazi (rec. uporabnik klikne 'Prejsnja stran').
+ * Kreirajo se markerji, shranjeni v bazi.
+ * @param spremenljivka int id spremenljivke
+ * @param map_data JSON Object
+ * @param podtip int - podtip/enota - 1-mojalokacija, 2-multilokacija, 3-chooselokacija
+ */
+function map_data_fill(spremenljivka, map_data, podtip) {
+ for (var row in map_data) {
+ var row_object = map_data[row];
+ var pos = {lat: row_object.lat, lng: row_object.lng};
+ //kreiraj marker
+ createMarker(spremenljivka, row_object.address, pos, false, row_object.text, podtip, row_object.naslov, row_object.vre_id);
+ }
+}
+
+/**
+ * funkcija, ki kreira osnovni marker (rdec)
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @param {type} add - String - label o informacijah markerja
+ * @param {type} pos - koordinate - objekt {lat: ???, lng: ???}
+ * @param {boolean} fromSearchBox - true if called from searchBox, false otherwise (used to avoid duplicates)
+ * @param {type} text - string - text za windowinfo textarea
+ * @param {type} podtip - int - podtip/enota - 1-mojalokacija, 2-multilokacija, 3-chooselokacija
+ * @param {type} naslov - string - title of marker
+ * @param {type} vre_id - int - id of vrednost
+ * @returns {undefined}
+ */
+function createMarker(spremenljivka, add, pos, fromSearchBox, text, podtip, naslov, vre_id) {
+ //in case, we are creating marker from searchbox, check if marker with this address already exist
+ //if yes, do not create marker and focus on marker with this address, if not, create marker
+ var marker = fromSearchBox ? findMarkerFromAddress(add, spremenljivka) : null;
+
+ if (!marker) {
+ //pridobi mapo spremenljivke
+ var map;
+ if (document.getElementById("map_" + spremenljivka))
+ map = document.getElementById("map_" + spremenljivka).gMap;
+ else
+ map = document.getElementById("map_canvas_all").gMap;
+
+ //pridobi ID markerja
+ var markerId = ((podtip == 3) && vre_id) ? vre_id : getMarkerUniqueId(pos.lat, pos.lng, spremenljivka);
+
+ //ce ze obstaja marker s tocno takim ID (iste koordinate), ignoriraj
+ //do te situacije pride (da je spodaj false) lahko samo tako, da v
+ //searchbox uporabnik dvakrat vpise isto lokacijo in jo markira -podvajanje podatkov
+ if ($('#' + markerId).length == 0) {
+
+ var path_img_dir = srv_site_url + 'admin/survey/img_0/';
+
+ var icon = {
+ fillColor: '#FF5555',
+ url: path_img_dir + (podvprasanje[spremenljivka] ? 'marker_text_off.png' :
+ 'marker_default.svg'),
+ fillOpacity: 1,
+ strokeWeight: 1
+ }
+
+ var namapo = null;
+ //var soda = spremenljivka % 2 == 0;
+
+ //v view mode naredimo clusters, pri resevanju pa jhi sproti filamo v mapo
+ if (!viewMode)
+ namapo = map;
+ else if(podtip == 3){
+ namapo = map;
+ }
+
+ //nastavitve markerja
+ var marker = new google.maps.Marker({
+ position: new google.maps.LatLng(pos.lat, pos.lng),
+ id: 'marker_' + markerId,
+ map: namapo,
+ icon: icon,
+ address: add
+ });
+
+
+ //store marker in markers array
+ allMarkers[spremenljivka].push(marker);
+
+ //ce je tip moja lokacija
+ if (ml_sprem.indexOf(spremenljivka) > -1) {
+ //ce obstaja marker, ga izbrisi
+ if (mlmarker['' + spremenljivka]){
+ removeMarker(spremenljivka, mlmarker['' + spremenljivka], markerId);
+ deleteAllMarkerInputs(spremenljivka);
+ }
+ //shrani marker v array, za kasnejsi iibris markerja iz mape pri mojilokaciji
+ mlmarker['' + spremenljivka] = marker;
+ }
+
+ if (!viewMode) {
+ //ustvari input, ce ze ne obstaja ta id (tocno te koordinate)
+ createMarkerInput(spremenljivka, marker, markerId, text);
+
+ if (podtip != 3)
+ //markers[markerId] = marker; // cache marker in markers object
+ bindMarkerEvents(spremenljivka, marker, markerId, map); // bind right click event to marker
+ }
+
+ //Create a div element for container.
+ var container = document.createElement("div");
+
+ if (podtip == 3) {
+ if (naslov) {
+ //Create a label element for title.
+ var title = document.createElement("label");
+ title.innerHTML = '<b>' + naslov + '</b><br>';
+ container.appendChild(title);
+ }
+
+ //Create a label element for address.
+ var label = document.createElement("label");
+ label.innerHTML = '<i>' + add + '</i><br>' + (podvprasanje_naslov[spremenljivka] ? '<br>' : '');
+ label.style.cssText = 'font-size:0.85em';
+ container.appendChild(label);
+ } else {
+ //Create a label element for address.
+ var label = document.createElement("label");
+ label.innerHTML = viewMode ? '<b>' + add + '</b><br>' : add + '<br>';
+ container.appendChild(label);
+ }
+
+ //naredi textbox, ce je nastavljeno podvprasanje
+ if (podvprasanje[spremenljivka]) {
+ //Create a label element for subquestion title
+ if (podvprasanje_naslov[spremenljivka]) {
+ var podvprasanje_title = document.createElement("label");
+ podvprasanje_title.innerHTML = viewMode ? podvprasanje_naslov[spremenljivka] + '<br>' :
+ '<b>' + podvprasanje_naslov[spremenljivka] + '</b><br>';
+ container.appendChild(podvprasanje_title);
+ }
+
+ if (!viewMode) {
+ //Create a textarea for the input text
+ var textBox = document.createElement("textarea");
+ textBox.setAttribute("id", markerId + "_textarea");
+ textBox.style.width = "100%";
+ textBox.id = markerId + "_textarea_id";
+ textBox.className = "boxsizingBorder";
+ textBox.style.height = "50px";
+ } else {
+ //Create a label for respondent text response
+ var textBox = document.createElement("label");
+ }
+ //ce obstaja text, ga vstavi v textarea
+ if (text && (text != '-2' && text != '-4' && text != '-1')) {
+ textBox.innerHTML = viewMode ? '<i>' + text + '</i>' : text;
+ marker.setIcon({url: path_img_dir + 'marker_text_on.png'});
+ }
+
+ container.appendChild(textBox);
+
+ if (!viewMode) {
+ //ko se spremeni textarea v windowinfo, spremeni value inputa za text
+ google.maps.event.addDomListener(textBox, "input", function () {
+ document.getElementById(markerId + '_text').value = textBox.value;
+ if (textBox.value)
+ marker.setIcon({url: path_img_dir + 'marker_text_on.png'});
+ else
+ marker.setIcon({url: path_img_dir + 'marker_text_off.png'});
+ });
+ }
+ }
+
+ //if "choose location" in view mode, declare own infowindow for each marker and open in
+ //otherwise use global variable infowindow
+ var infowin = (podtip == 3 && viewMode) ? new google.maps.InfoWindow() : infowindow;
+
+ //listener ob kliku na marker - focus input mora biti po nastavljanju bounds ali zoom
+ google.maps.event.addListener(marker, 'click', function () {
+ infowin.setContent(container);
+ infowin.open(map, marker);
+ //focus on input
+ $("#" + markerId + "_textarea_id").focus();
+ });
+
+ //nastavi label
+ infowin.setContent(container);
+ //odpre marker - prikaze label (kot da bi ga kliknil)
+ infowin.open(map, marker);
+
+ if (ml_sprem.indexOf(spremenljivka) == -1)
+ //v okvir se doda nov marker
+ bounds[spremenljivka].extend(marker.position);
+
+ //ce je samo eden marker, ga malo odzoomaj
+ if (ml_sprem.indexOf(spremenljivka) > -1 || (st_markerjev[spremenljivka] == 0) && viewMode) {
+ map.setCenter(marker.position);
+ map.setZoom(17);
+ } else if (st_markerjev[spremenljivka] > 0) {
+ //zemljevid se prilagodi okviru
+ map.fitBounds(bounds[spremenljivka]);
+
+ //ce ni v viewMode - je v resevanju ankete - se za vsak marker odzooma
+ /*if(!viewMode && podtip != 3){
+ //zmanjsaj zoom za 1, ker google naredi prevec oddaljeno
+ google.maps.event.addListenerOnce(map, "bounds_changed", function() {
+ map.setZoom(map.getZoom()-1);
+ });
+ }*/
+ //ce je v viewMode - v podatkih ali analizah - se odzooma za 1 samo pri zadnjem markerju
+ if (viewMode && max_mark[spremenljivka] == st_markerjev[spremenljivka] + 1) {
+ //zmanjsaj zoom za 1, ker google naredi prevec oddaljeno
+ google.maps.event.addListenerOnce(map, "bounds_changed", function () {
+ map.setZoom(map.getZoom() - 1);
+ });
+ }
+ }
+
+ //stevilo markerjev se poveca
+ st_markerjev[spremenljivka]++;
+
+ //odstej od dovoljenih za opozorilo
+ if (ml_sprem.indexOf(spremenljivka) == -1 && !viewMode && max_mark[spremenljivka] == st_markerjev[spremenljivka])
+ $('#max_marker_' + spremenljivka).show();
+
+ //focus on input - must be after setting bounds or zooming
+ $("#" + markerId + "_textarea_id").focus();
+ }
+ } else {
+ //trigger click on marker, to focus it and open infowindow
+ google.maps.event.trigger(marker, 'click');
+ }
+}
+
+/**
+ * handler za desni klik in dvojni klik na markerja
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @param {type} marker
+ * @param {type} markerId
+ * @param {type} map - google map
+ */
+function bindMarkerEvents(spremenljivka, marker, markerId, map) {
+ google.maps.event.addListener(marker, "rightclick", function () {
+ //removeMarker(spremenljivka, marker, markerId); // remove marker from array
+ deleteMenu.open(map, null, null, spremenljivka, null, null, marker, markerId);
+ $('#max_marker_' + spremenljivka).hide();
+ });
+ google.maps.event.addListener(marker, "dblclick", function () {
+ //removeMarker(spremenljivka, marker, markerId); // remove marker from array
+ deleteMenu.open(map, null, null, spremenljivka, null, null, marker, markerId);
+ $('#max_marker_' + spremenljivka).hide();
+ });
+}
+
+/**
+ * brise marker iz zemljevida
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @param {type} marker
+ * @param {type} markerId
+ */
+function removeMarker(spremenljivka, marker, markerId) {
+ marker.setMap(null); // set markers setMap to null to remove it from map
+ //remove marker from marker array
+ var index = allMarkers[spremenljivka].indexOf(marker);
+ if (index > -1)
+ allMarkers[spremenljivka].splice(index, 1);
+ //stevilo markerjev se zmanjsa
+ st_markerjev[spremenljivka]--;
+
+ deleteMarkerInput(markerId); //remove input of marker fro form
+}
+
+/**
+ * kreira hidden inpute s podatki markerja
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @param {type} marker
+ * @param {type} markerId - id markerja
+ * @param {type} text - text za textarea v windowinfo
+ * @returns {undefined}
+ */
+function createMarkerInput(spremenljivka, marker, markerId, text) {
+ //najdi element za drzanje variabel
+ var $variable_holder = $("#spremenljivka_" + spremenljivka + "_variabla");
+
+ //kreiraj input s statičnimi podatki markerja
+ var $markerInput = $("<input>", {id: markerId, name: "vrednost_" + spremenljivka + "[]",
+ type: "hidden", class: "marker_input",
+ value: markerId + "|" + marker.getPosition().lat() + "|" +
+ marker.getPosition().lng() + "|" + marker.address});
+ $variable_holder.append($markerInput);
+
+ if (podvprasanje[spremenljivka]) {
+ //kreiraj input s textom - textarea v infowindow
+ var $textareaInput = $("<input>", {id: markerId + '_text', name: markerId + '_text',
+ type: "hidden", value: text, class: "marker_input"});
+ $variable_holder.append($textareaInput);
+ }
+}
+
+/**
+ * brise inpute s podatki markerja
+ * @param {type} markerId - id markerja
+ */
+function deleteMarkerInput(markerId) {
+ //brisi input s staticnimi podatki markerja
+ $('#' + markerId).remove();
+ //brisi input s textom markerja v windowinfo
+ $('#' + markerId + '_text').remove();
+}
+
+/**
+ * brise vse inpute mape (vse markerje)
+ * @param {type} spremenljivka - int - id spremenljivke
+ */
+function deleteAllMarkerInputs(spremenljivka) {
+ //brisi vse inpute s staticnimi podatki markerja
+ $('#spremenljivka_' + spremenljivka + '_variabla').find('input.marker_input').remove();
+} \ No newline at end of file
diff --git a/main/survey/js/Maps/SearchBox.js b/main/survey/js/Maps/SearchBox.js
new file mode 100644
index 0000000..e71b6ea
--- /dev/null
+++ b/main/survey/js/Maps/SearchBox.js
@@ -0,0 +1,78 @@
+// Author: Uroš Podkrižnik (25.6.2016)
+// Tip vprasanja = 26
+
+// SEARCH BOX
+
+/**
+ * Skripta, ki ustvari in nastavi iskalno polje za zemljevid
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @returns {undefined}
+ */
+function searchBox(spremenljivka, doOnPlacesChanged){
+ //pridobi mapo spremenljivke
+ var map;
+ if(document.getElementById("map_"+spremenljivka))
+ map = document.getElementById("map_"+spremenljivka).gMap;
+ else if(document.getElementById("br_map_"+spremenljivka)){
+ map = document.getElementById("br_map_"+spremenljivka).gMap;
+ }
+ else{
+ map = document.getElementById("maza_map_geofencing").gMap;
+ }
+
+ // Create the search box and link it to the UI element.
+ var input = document.getElementById('pac-input_'+spremenljivka);
+ input.style.display='inline-block';
+ var searchBox = new google.maps.places.SearchBox(input);
+ map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
+
+ // Bias the SearchBox results towards current map's viewport.
+ map.addListener('bounds_changed', function() {
+ searchBox.setBounds(map.getBounds());
+ });
+
+ // Listen for the event fired when the user selects a prediction and retrieve
+ // more details for that place.
+ searchBox.addListener('places_changed', function() {
+ var places = searchBox.getPlaces();
+
+ if (places.length == 0)
+ return;
+
+ //first place has data of geometry
+ if(places[0].geometry){
+ //pozicija v latitude in longitude, ki jo najde
+ var pos = {
+ lat: places[0].geometry.location.lat(),
+ lng: places[0].geometry.location.lng()
+ };
+
+ doOnPlacesChanged(pos, places[0].formatted_address);
+ }
+ //first place does not have data of geometry, do a geocoding from adress
+ else{
+ findPlace(places[0].name, function(pos, formatted_address){
+ doOnPlacesChanged(pos, formatted_address);
+ });
+ }
+ });
+}
+
+/**
+ * Find place from addres
+ * @param {type} address - address to geocode
+ * @param {type} doAfterPlaceFound - callback function to call when place is found
+ * @returns {undefined}
+ */
+function findPlace (address, doAfterPlaceFound){
+ geocoderFromAddress(address, function(place){
+ if(place){
+ var pos = {
+ lat: place.geometry.location.lat(),
+ lng: place.geometry.location.lng()
+ };
+
+ doAfterPlaceFound(pos, place.formatted_address);
+ }
+ });
+}
diff --git a/main/survey/js/Maps/ShapeDrawing.js b/main/survey/js/Maps/ShapeDrawing.js
new file mode 100644
index 0000000..8495671
--- /dev/null
+++ b/main/survey/js/Maps/ShapeDrawing.js
@@ -0,0 +1,397 @@
+// Author: Uroš Podkrižnik (24.1.2017)
+// Tip vprasanja = 26
+
+//DRAWING POLYLINE
+
+/**
+ * Function to set parameters for drawing a shape on map
+ *
+ * @param {type} spremenljivka - id spremenljivke
+ * @param {google's shape} shape - polyline or polygon if already exists
+ * @param shape_type - string - type of shape 'polyline' or 'polygon'
+ * @returns {undefined}
+ */
+function drawShape(spremenljivka, shape, shape_type) {
+ var map = document.getElementById("map_"+spremenljivka).gMap;
+
+ var drawingMode = (shape_type === 'polyline') ?
+ google.maps.drawing.OverlayType.POLYLINE : google.maps.drawing.OverlayType.POLYGON;
+ var startDrawingMode = shape!==null ? null : drawingMode;
+ var shapeOptions = (shape_type === 'polyline') ? polylineOptions() : polygonOptions();
+
+ var drawingManager = new google.maps.drawing.DrawingManager({
+ drawingMode: startDrawingMode,
+ drawingControl: shape===null,
+ drawingControlOptions: {
+ position: google.maps.ControlPosition.TOP_RIGHT,
+ drawingModes: [shape_type]
+ },
+ polylineOptions: shapeOptions,
+ polygonOptions: shapeOptions
+ });
+
+ //settings for custom drawing controls
+ var drawingControlDiv = document.createElement('div');
+ var DrawingControl = new drawingControl(drawingControlDiv, map, spremenljivka);
+ drawingControlDiv.index = 1;
+ map.controls[google.maps.ControlPosition.TOP_RIGHT].push(drawingControlDiv);
+ //at start, there is no shape, so no need to show delete button
+ DrawingControl.style.display = (shape!==null && !viewMode) ? 'inline-block' : 'none';
+
+ if(shape!==null){
+ shape.type = shape_type;
+ createBoundsFromPath( shape.getPath() , spremenljivka );
+ map.fitBounds(bounds[spremenljivka]);
+ afterShapeCompleteSettings(drawingManager, DrawingControl, shape, spremenljivka, map);
+ }
+
+ //listener when user colpetes shape
+ google.maps.event.addListener(drawingManager, shape_type+'complete', function(shape) {
+ shape.type = shape_type;
+ afterShapeCompleteSettings(drawingManager, DrawingControl, shape, spremenljivka, map);
+ });
+
+ drawingManager.setMap(map);
+}
+
+/**
+ * Sets all kind of settings after shape is complete
+ *
+ * @param {type} drawingManager - google's drawingManager
+ * @param {type} DrawingControl - button for removing a shape
+ * @param {google's shape} shape - polyline or polygon if already exists
+ * @param {type} spremenljivka - id spremenljivke
+ * @param {type} map - google map on which we are drawing shape
+ * @returns {undefined}
+ */
+function afterShapeCompleteSettings(drawingManager, DrawingControl, shape, spremenljivka, map){
+ //hide controls
+ drawingManager.setOptions({
+ drawingControl: false
+ });
+ //stop drawing
+ drawingManager.setDrawingMode(null);
+ //show delete button
+ DrawingControl.style.display = 'inline-block';
+
+ // Setup the click event listener for delete button
+ DrawingControl.addEventListener('click', function() {
+ clearAndMakeDrawableAgain(spremenljivka, shape, DrawingControl, drawingManager);
+ });
+
+ shapeInputHandler(shape, spremenljivka);
+
+ //hide warning info for ending a shape
+ var end_info_warning = document.getElementById("end_shape_info_"+spremenljivka);
+ end_info_warning.style.display = "none";
+
+ /**
+ * Liteners when editing a shape
+ */
+ //when editing end or start point
+ google.maps.event.addListener(shape.getPath(), 'set_at', function(index, obj) {
+ shapeInputHandler(shape, spremenljivka);
+ });
+ //when inserting new point (break old one)
+ google.maps.event.addListener(shape.getPath(), 'insert_at', function(index, obj) {
+ shapeInputHandler(shape, spremenljivka);
+ });
+ //when deleting a point -> undo
+ google.maps.event.addListener(shape.getPath(), 'remove_at', function(index, obj) {
+ shapeInputHandler(shape, spremenljivka);
+ });
+
+ setDeleteMenu(shape, map, spremenljivka, DrawingControl, drawingManager)
+}
+
+/**
+ * Sets rightclick and dblclick listeners to open delete menu
+ * @param {type} shape - shape to set listeners on
+ * @param {type} map - map on which to hover menu (shape's map)
+ * @param {type} spremenljivka - id of variable
+ * @param {type} drawingManager - google's drawingManager
+ * @param {type} DrawingControl - button for removing a shape
+ * @returns {undefined}
+ */
+function setDeleteMenu(shape, map, spremenljivka, DrawingControl, drawingManager) {
+ google.maps.event.addListener(shape, 'rightclick', function (e) {
+ // Check if click was on a vertex control point
+ if (e.vertex == undefined) {
+ return;
+ }
+ //removeVertexVM(spremenljivka, shape, e.vertex);
+ deleteMenu.open(map, shape, e.vertex, spremenljivka, DrawingControl, drawingManager);
+ });
+ google.maps.event.addListener(shape, 'dblclick', function (e) {
+ // Check if click was on a vertex control point
+ if (e.vertex == undefined) {
+ return;
+ }
+ //removeVertexVM(spremenljivka, shape, e.vertex);
+ deleteMenu.open(map, shape, e.vertex, spremenljivka, DrawingControl, drawingManager);
+ });
+}
+
+/**
+ * Ce obstajajo podatki v bazi izrisi info shapes
+ * Kreirajo se markerji, shranjeni v bazi.
+ * @param spremenljivka int id spremenljivke
+ * @param map_data JSON Object
+ */
+function map_data_fill_info_shapes(spremenljivka, map_data) {
+ //because of viewing a filled survey at data section
+ var fillMode = (document.getElementById("map_"+spremenljivka) !== null);
+
+ //pridobi mapo spremenljivke
+ var map;
+ if(fillMode)
+ map = document.getElementById("map_"+spremenljivka).gMap;
+ else
+ map = document.getElementById("map_canvas_all").gMap;
+
+
+ var shapeOption = polylineOptions(map);
+
+ for (var i=0; i<map_data.length; i++)
+ {
+ var color = mapShapeColors[i % mapShapeColors.length];
+
+ //set and show the shape
+ shapeOption.path = map_data[i].path;
+ shapeOption.strokeColor = '#'+color;
+ shapeOption.strokeColorOrg = '#'+color;
+ shapeOption.editable = false;
+ var shape = new google.maps.Polyline(shapeOption);
+
+ //Create a div element for container.
+ var container = document.createElement("div");
+ //margin, da se pri italic ne odreze zadja crka
+ container.style.cssText = 'margin-right:1px';
+
+ //Create a label for title
+ var Title = document.createElement("label");
+ Title.style.cssText = "font-size:1em;";
+ Title.innerHTML = '<b>' + map_data[i].address + '</b>';
+ container.appendChild(Title);
+
+ shape.ifnowin = container;
+ shape.address = map_data[i].address;
+ var infow = new google.maps.InfoWindow();
+
+ google.maps.event.addListener(shape, 'mouseover', function(ev) {
+ this.setOptions({strokeWeight: 6, zIndex: 2});
+ //open infowindow if title exists
+ if(this.address){
+ infow.setContent(this.ifnowin);
+ infow.setPosition(ev.latLng);
+ infow.open(map);
+ }
+ });
+ google.maps.event.addListener(shape, 'mouseout', function() {
+ this.setOptions({strokeWeight: 4, zIndex: 1});
+ infow.close();
+ });
+ }
+}
+
+/**
+ * Clears the map, deletes all inputs, hides "Clear" button and sets drawing mode on
+ * @param {type} spremenljivka - id spremenljivke
+ * @param {google's shape} shape - polyline or polygon
+ * @param {type} drawingManager - google's drawingManager
+ * @param {type} DrawingControl - button for removing a shape
+ * @returns {undefined}
+ */
+function clearAndMakeDrawableAgain(spremenljivka, shape, DrawingControl, drawingManager){
+ //remove shape
+ shape.setMap(null);
+ //remove all hidden inputs of a shape
+ deleteAllShapeInputs(spremenljivka);
+ //hide delete button
+ DrawingControl.style.display = 'none';
+ //show drawing controls
+ drawingManager.setOptions({
+ drawingControl: true
+ });
+
+ //start drawing
+ drawingManager.setDrawingMode(shape.type);
+
+ //show warning info for ending a shape
+ var end_info_warning = document.getElementById("end_shape_info_"+spremenljivka);
+ end_info_warning.style.display = "inline-block";
+}
+
+/**
+ * Removes a vertex/point of shape and if it after last it clears the map
+ * and sets drawing mode on again
+ * @param {type} spremenljivka - id spremenljivke
+ * @param {google's shape} shape - polyline or polygon if already exists
+ * @param {type} vertex - vertex or point which was selected
+ * @param {type} drawingManager - google's drawingManager
+ * @param {type} DrawingControl - button for removing a shape
+ * @returns {undefined}
+ */
+/*function removeVertex(spremenljivka, shape, vertex, DrawingControl, drawingManager) {
+ if (!shape || vertex == undefined)
+ return;
+
+ shape.getPath().removeAt(vertex);
+
+ if(shape.getPath().length < 2){
+ clearAndMakeDrawableAgain(spremenljivka, shape, DrawingControl, drawingManager);
+ }
+}*/
+
+/**
+ * Handle hidden input - remove old, create new
+ * @param {google's shape} shape - polyline or polygon
+ * @param {int} spremenljivka - id spremenljivke
+ * @returns {undefined}
+ */
+function shapeInputHandler(shape, spremenljivka){
+ deleteAllShapeInputs(spremenljivka);
+ createAllShapeInputs( shape.getPath(), spremenljivka );
+}
+
+/**
+ * create hidden inputs of all points of shape
+ * @param {type} path shape.getPath()
+ * @param {int} spremenljivka - id spremenljivke
+ */
+function createAllShapeInputs( path , spremenljivka ) {
+ var pathArray = path.getArray();
+ for( var i = 0, n = pathArray.length; i < n; i++ ) {
+ var latLng = pathArray[i];
+ createShapeInput(spremenljivka, { lat: latLng.lat(), lng: latLng.lng() }, i+1);
+ }
+}
+
+/**
+ * create hidden input of shape data
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @param {type} vertices - array of lat and lng
+ * @param {type} index - order of point
+ * @returns {undefined}
+ */
+function createShapeInput(spremenljivka, vertices, index) {
+ //najdi element za drzanje variabel
+ var $variable_holder = $("#spremenljivka_" + spremenljivka + "_variabla");
+
+ //kreiraj input s statičnimi podatki markerja
+ var $shapeInput = $("<input>", {name: "vrednost_" + spremenljivka + "[]",
+ type: "hidden", class: "shape_input",
+ value: index + "|" + vertices.lat + "|" + vertices.lng});
+ $variable_holder.append($shapeInput);
+}
+
+/**
+ * delete all hidden inputs of shape
+ * @param {type} spremenljivka - id spremenljivke
+ */
+function deleteAllShapeInputs(spremenljivka) {
+ //brisi vse inpute s staticnimi podatki shape
+ $('#spremenljivka_' + spremenljivka + '_variabla').find('input.shape_input').remove();
+}
+
+/**
+ * Ce obstajajo podatki v bazi (rec. uporabnik klikne 'Prejsnja stran').
+ * Kreira se shape, shranjena v bazi.
+ * @param spremenljivka int id spremenljivke
+ * @param map_data JSON Object
+ * @param shape_type - string - type of shape 'polyline' or 'polygon'
+ */
+function map_data_fill_shape(spremenljivka, map_data, shape_type){
+ //because of viewing a filled survey at data section
+ var fillMode = (document.getElementById("map_"+spremenljivka) !== null);
+
+ //pridobi mapo spremenljivke
+ var map;
+ if(fillMode)
+ map = document.getElementById("map_"+spremenljivka).gMap;
+ else
+ map = document.getElementById("map_canvas_all").gMap;
+
+ var shapeOption = shape_type === 'polyline' ? polylineOptions(map) : polygonOptions(map);
+
+ //for respondents, fill a map
+ if(fillMode){
+ //set and show the shape
+ shapeOption.path = map_data;
+ var shape = shape_type === 'polyline' ?
+ new google.maps.Polyline(shapeOption) : new google.maps.Polygon(shapeOption);
+
+ //alsways viewMode = false, except at insight into survey at data
+ //if not viewMode, create shape inputs and start drawing
+ if(!viewMode){
+ //create hidden inputs of shape
+ createAllShapeInputs( shape.getPath() , spremenljivka );
+
+ //set all data for shape drawing
+ drawShape(spremenljivka, shape, shape_type);
+ }
+ //if viewMode, just create and fit bounds
+ else{
+ //set bounds
+ createBoundsFromPath( shape.getPath() , spremenljivka );
+ map.fitBounds(bounds[spremenljivka]);
+ }
+ }
+ //for admins, show shapes
+ else{
+ var keys = Object.keys(map_data);
+
+ for (var i=0; i<keys.length; i++)
+ {
+ var color = mapShapeColors[i % mapShapeColors.length];
+
+ //set and show the shape
+ shapeOption.path = map_data[keys[i]];
+ shapeOption.strokeColor = '#'+color;
+ shapeOption.strokeColorOrg = '#'+color;
+ var shape = shape_type === 'polyline' ?
+ new google.maps.Polyline(shapeOption) : new google.maps.Polygon(shapeOption);
+
+ google.maps.event.addListener(shape, 'mouseover', function() { this.setOptions({strokeWeight: 6, strokeColor: 'black', zIndex: 2}); });
+ google.maps.event.addListener(shape, 'mouseout', function() { this.setOptions({strokeWeight: 4, strokeColor: this.strokeColorOrg , zIndex: 1}); });
+
+ //set bounds
+ createBoundsFromPath( shape.getPath() , 'all' );
+ map.fitBounds(bounds['all']);
+ }
+ }
+}
+
+/**
+ * Polyline options holder
+ * @param map google map, to put polyline in it
+ * @returns {polylineOptions.PolylineAnonym$6}
+ */
+function polylineOptions(map){
+ return {
+ strokeColor: 'black',
+ strokeColorOrg: 'black',
+ strokeWeight: 4,
+ clickable: true,
+ editable: !viewMode,
+ zIndex: 1,
+ map: map
+ };
+}
+
+/**
+ * Polygon options holder
+ * @param map google map, to put polygon in it
+ * @returns {polygonOptions.PolygonAnonym$6}
+ */
+function polygonOptions(map){
+ return {
+ strokeColor: 'black',
+ strokeColorOrg: 'black',
+ strokeWeight: 4,
+ clickable: true,
+ editable: !viewMode,
+ zIndex: 1,
+ map: map
+ };
+} \ No newline at end of file
diff --git a/main/survey/js/Maps/UserLocation.js b/main/survey/js/Maps/UserLocation.js
new file mode 100644
index 0000000..89620be
--- /dev/null
+++ b/main/survey/js/Maps/UserLocation.js
@@ -0,0 +1,94 @@
+// Author: Uroš Podkrižnik (17.12.2015)
+// Tip vprasanja = 26
+
+// USER LOCATION
+// Skripta, ki najde lokacijo uporabnika
+
+/**
+ * funkcija za zacetek procedure ya ugotavljanje lokacije userja
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @returns {undefined}
+ */
+function userLocation(spremenljivka) {
+ // ali browser podpira pridobivanje lokacije uporabnika
+ if (navigator.geolocation) {
+
+ var options = {
+ enableHighAccuracy: true,
+ timeout: 0,
+ maximumAge: Infinity
+ };
+
+ navigator.geolocation.getCurrentPosition(
+ function (position) {
+ //pozicija v latitude in longitude, ki jo najde
+ var pos = {
+ lat: position.coords.latitude,
+ lng: position.coords.longitude
+ };
+
+ //accuracy of position
+ //console.log('More or less meters ' + position.coords.accuracy);
+
+ //klice proceduro, kjer se naprej operira s koordinatami
+ userLocationProceduraF(pos, spremenljivka);
+ }, function (error) {
+ var warning = $('#warning_geo_'+spremenljivka);
+
+ if(error){
+ switch(error.code) {
+ case error.PERMISSION_DENIED:
+ warning.html(lang['srv_resevanje_user_denied_geo_map']);
+ break;
+ case error.POSITION_UNAVAILABLE:
+ warning.html(lang['srv_resevanje_position_unavailable_geo_map']);
+ break;
+ case error.TIMEOUT:
+ warning.html(lang['srv_resevanje_timeout_geo_map']);
+ break;
+ case error.UNKNOWN_ERROR:
+ warning.html(lang['srv_resevanje_unknown_error_geo_map']);
+ break;
+ }
+ }
+ else
+ warning.html(lang['srv_resevanje_browser_not_support_geo_map']);
+
+ warning.show();
+ }
+ );
+ } else {
+ // Browser doesn't support Geolocation
+ handleLocationError(false);
+ }
+}
+
+/**
+ * procedura, ki se izvede, ko API najde lokacijo userja
+ * @param {type} pos - koordinate - objekt {lat: ???, lng: ???}
+ * @param {type} spremenljivka - int - id spremenljivke
+ * @returns {undefined}
+ */
+function userLocationProceduraF(pos, spremenljivka) {
+ //za omejitev max markerjev
+ if(ml_sprem.indexOf(spremenljivka) > -1 || max_mark[spremenljivka]-st_markerjev[spremenljivka] != 0){
+ //pretvori iz koordinat v naslov in nastavi label v infowindow
+ GeocodingF(pos, function (data) {
+ //ce ne vrne null - je nasel naslov
+ if (data != null) {
+ //kreira marker na lokaciji
+ for (key in usrLoc_sprem) {
+ //Param fromSearchBox is true because of possible duplicate at multilocation with userloction ON,
+ //if user goes to previous page.
+ //In very rare occasions this may couse bad UX in case:
+ //user has clicked on location with address 'Undefined road', then userlocation returns
+ //address as 'Undefined road' - in this case, marker will not be created from userlocation.
+ createMarker(usrLoc_sprem[key], data.formatted_address, pos, true);
+ }
+ } else {
+ //odpre se okno, ce je prislo do napake - null - (mozen je tudi prekratek delay med geocoding requesti)
+ alert(lang['srv_resevanje_alert_location_not_found_map']);
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/main/survey/js/custom_column_label_respondent.js b/main/survey/js/custom_column_label_respondent.js
new file mode 100644
index 0000000..87e15f6
--- /dev/null
+++ b/main/survey/js/custom_column_label_respondent.js
@@ -0,0 +1,98 @@
+var zagnano = [];
+function change_custom_column_label_respondent(size, spremenljivka, value){
+
+ //console.log("Izbrana možnost: "+value+" spremenljivka: "+spremenljivka+" size: "+size);
+ //console.log("Zagnano za spremenljivko: "+spremenljivka+" je: "+zagnano[spremenljivka]);
+
+ if (zagnano[spremenljivka] === undefined) { //ce se ureditev label respondentov ni se izvedlo
+
+ zagnano[spremenljivka]=1;
+
+ if(value == 2){ //ce je trenutna moznost prilagajanja "le koncne"
+ var i = 0;
+ if(size%2 == 0){ //ce je parno stevilo, spoji polovico label na vsako skupino label
+ var colspan_calc_1 = colspan_calc_2 = size / 2;
+ }else if(size%2 != 0){ //ce ni parno stevilo, spoji prvi skupini label eno celico vec kot pri drugi skupini label
+ var colspan_calc_1 = (size / 2) + 0.5;
+ var colspan_calc_2 = (size / 2) - 0.5;
+ }
+
+ $('#spremenljivka_'+spremenljivka+' table.grid_table > thead > tr > td.category').each(function(){ //preleti labele
+
+ //var test = $(this).text();
+ //console.log("Test: "+test);
+ i = i + 1;
+ //console.log("I-ti tekst: "+i);
+
+ if(i != 1 && i != size){ //ce ni prva ali zadnja labela oz. vmesnim labelam,
+ //console.log("v IFu: "+i);
+ $(this).children().text(""); //odstrani tekst
+ $(this).remove(); //odstrani celico
+ }
+ if(i == 1){ //ce je prva labela,
+ $(this).attr('colspan', colspan_calc_1); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: left'); //tekst koncne skupine label poravnaj levo
+ $(this).removeClass('alignLeft'); //odstrani levo poravnavo
+ }
+ if(i == size){ //ce je zadnja labela,
+ $(this).attr('colspan', colspan_calc_2); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: right'); //tekst koncne skupine label poravnaj desno
+ $(this).removeClass('alignLeft'); //odstrani levo poravnavo
+ }
+ });
+
+ $('#spremenljivka_'+spremenljivka+' table.grid_table > tbody > tr > td.category').each(function(){ //preleti vse radio buttone
+ $(this).removeClass('alignLeft'); //in odstrani levo poravnavo
+ });
+
+ }else if(value == 3){ //ce je trenutna moznost prilagajanja "koncne in vmesna"
+ var i = 0;
+
+
+ if(size % 3 == 0){ //ce je velikost deljiva s 3, spoji vsako tretjino label
+ var colspan_calc_1 = colspan_calc_2 = colspan_calc_3 = size / 3;
+ var middle = 1 + size / 3;
+ }else if(size % 3 == 1){ //ce pri deljenju z 3 je ostanek 1
+ var colspan_calc_1 = colspan_calc_2 = parseInt(size / 3);
+ var colspan_calc_3 = parseInt(size / 3) + 1;
+ var middle = 1 + Math.ceil(size / 3);
+ }else if(size % 3 == 2){ //ce pri deljenju z 3 je ostanek 2
+ var colspan_calc_1 = colspan_calc_2 = 1 + parseInt(size / 3);
+ var colspan_calc_3 = parseInt(size / 3);
+ var middle = 2 + parseInt(size / 3);
+ }
+
+ $('#spremenljivka_'+spremenljivka+' table.grid_table > thead > tr > td.category').each(function(){ //preleti labele
+
+ i = i + 1;
+
+ if(i != 1 && i != size && i != middle){ //ce ni prva ali zadnja labela oz. vmesnim labelam,
+ $(this).children().text(""); //odstrani tekst
+ $(this).remove(); //odstrani celico
+ }
+ if(i == 1){ //ce je prva labela,
+ $(this).attr('colspan', colspan_calc_1); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: left'); //tekst koncne skupine label poravnaj levo
+ $(this).removeClass('alignLeft'); //odstrani levo poravnavo
+ }
+ if(i == size){ //ce je zadnja labela,
+ $(this).attr('colspan', colspan_calc_2); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: right'); //tekst koncne skupine label poravnaj desno
+ $(this).removeClass('alignLeft'); //odstrani levo poravnavo
+ }
+ if(i == middle){ //ce je vmesna labela,
+ $(this).attr('colspan', colspan_calc_3); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: center'); //tekst koncne skupine label poravnaj sredinsko
+ $(this).removeClass('alignLeft'); //odstrani levo poravnavo
+ }
+ });
+
+ $('#spremenljivka_'+spremenljivka+' table.grid_table > tbody > tr > td.category').each(function(){ //preleti vse radio buttone
+ $(this).removeClass('alignLeft'); //in odstrani levo poravnavo
+ });
+ }
+ else if(value == 4){ //hanging
+
+ }
+ }
+} \ No newline at end of file
diff --git a/main/survey/js/customizeImageView4Respondent.js b/main/survey/js/customizeImageView4Respondent.js
new file mode 100644
index 0000000..2b2c2d3
--- /dev/null
+++ b/main/survey/js/customizeImageView4Respondent.js
@@ -0,0 +1,355 @@
+//funkcije za gladko delovanje prikazovanja visjih blokov odgovorov @ rangiranje (razvrščanja) (tip = 17)
+
+
+function customizeImageView4Respondent(tip, spremenljivka, vre_id, ajax, anketa, site_url, usr_id, other, mobile, quick_view, preview_spremenljivka){
+
+ if(quick_view || preview_spremenljivka){ //ce je le predogled
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).draggable( "option", "disabled", true ); //disable-anje drag and drop
+ }
+
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta **************************************************
+ var default_cat_height = 15;
+ var final_height = 0;
+ //var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ var content = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ content = content.replace(/<img[^>]*>/gi,""); //odstranit tekst med img tag-i
+
+ var cat_text_length = content.length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ //console.log('Število znakov v kategoriji: '+cat_text_length);
+
+ var num_of_br = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' br').length; //hrani stevilo br oz. ročnih vnosov novih vrstic
+ //console.log('Število br v kategoriji: '+num_of_br);
+
+ var num_imgs = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').length; //hrani stevilo img v interesiranem div-u
+ //console.log('Število slik v kategoriji: '+num_imgs);
+
+ var max_cat_text_length = 30; //hrani max stevilo dolzine teksta za eno vrstico
+
+ var oneLineHeight = 20;
+
+ if( (cat_text_length > max_cat_text_length) ){//ce je tekst daljsi od 30 znakov
+ var kvocient = Math.ceil(cat_text_length/max_cat_text_length);
+ final_height = final_height + kvocient*oneLineHeight;
+ }
+
+ if (num_imgs != 0){ // ce imamo sliko
+
+ var img_height = 0;
+ //var max_width = $('.ranking').width();
+ var max_width = 230;
+ var img = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img');
+ var img_width = img.width();
+ //console.log("img_width: "+img_width);
+
+ var img_height = img.height();
+ //console.log("img_height: "+img_height);
+
+ if (img_width > max_width){
+ img_height = (img_height / img_width) * max_width;
+ img.css({width: max_width});
+ img.css({height: img_height});
+ //$('#vre_id_'+vre_id).css({height: height});
+ //console.log("Vecji od max width");
+ }
+
+ //ureditev mobilne različice prikazovanja slik znotraj kategorij odgovorov
+/* if (mobile == 1){ //ce je mobilnik
+ img_height = (img_height / img_width) * 100;
+ img_width = 100;
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').attr('style', 'margin: auto !important'); //dodaj atribut
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').css({'height':img_height,'width':img_width}); //ustrezno spremeni visino in sirino slike
+ } */
+ //ureditev mobilne različice prikazovanja - konec
+
+ //console.log("img_height: "+img_height);
+ if(img_height > 25){ //ce je visina slike vecja od default visine kategorije
+ final_height = final_height + img_height;
+ }
+
+
+
+ //ureditev visine variable_holder, ki je znotraj okvirja !!!!!!!!!!
+ //$('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(final_height + img_height)+'px'});
+ }
+
+ if(num_of_br != 0){ //ce imamo vnesene rocne skoke v novo vrstico </br>
+ var br_height = num_of_br*oneLineHeight;
+ final_height = final_height + br_height;
+ }
+
+ if (final_height != 0){
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).css({'height':final_height}); //dodaj style atributu še novo višino za levi blok
+ }
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta - konec********************************************
+
+ //ureditev visine celotnega vprasanja****************************************************************************************************
+
+ //dynamic_question_height_ranking(spremenljivka, num_grids);
+
+ //ureditev visine celotnega vprasanja - konec*******************************************************************************************
+}
+
+
+
+//function customizeImageView4Respondent(tip, spremenljivka, vre_id, ajax, anketa, site_url, usr_id, other, mobile, num_grids, quick_view, preview_spremenljivka){
+function customizeImageView4RespondentOld(tip, spremenljivka, vre_id, ajax, anketa, site_url, usr_id, other, mobile, quick_view, preview_spremenljivka){
+ var top_cat = -1;
+ var left_cat = -1;
+ if (mobile == 0 || mobile == 2){
+ top_cat = -6;
+ left_cat = -6;
+ }
+
+ if(quick_view || preview_spremenljivka){ //ce je le predogled
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).draggable( "option", "disabled", true ); //disable-anje drag and drop
+ }
+
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta **************************************************
+ var default_cat_height = 15;
+ var final_height = 0;
+ //var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ var cat_text_length = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html().length; //hrani stevilo znakov, ki so vpisani v trenutni kategoriji odgovora
+ //console.log('Število znakov v kategoriji: '+cat_text_length);
+
+ var num_of_br = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' br').length; //hrani stevilo br oz. ročnih vnosov novih vrstic
+ //console.log('Število br v kategoriji: '+num_of_br);
+
+ var num_imgs = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').length; //hrani stevilo img v interesiranem div-u
+ //console.log('Število slik v kategoriji: '+num_imgs);
+
+ var max_cat_text_length = 30; //hrani max stevilo dolzine teksta do katerega ni potrebno samodejno dodati <br>
+
+
+ if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs == 0) ){//ce je tekst daljsi od 30 znakov, nima breakov ali slik dodaj <br>
+ //if( (cat_text_length > max_cat_text_length) ){//ce je tekst daljsi od 35 znakov dodaj <br>
+ //console.log('Tekst je daljši od '+max_cat_text_length+' znakov');
+ //var txt2 = txt1.slice(0, 3) + "bar" + txt1.slice(3);
+ //var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).text();
+/* var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ //console.log(txt);
+ var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt); */
+ final_height = final_height + default_cat_height + 25;
+ final_height = (cat_text_length/max_cat_text_length)*30;
+ //console.log(final_height);
+ }
+ /* else if( (cat_text_length > max_cat_text_length) && (num_of_br == 0) && (num_imgs != 0) ){//ce je tekst daljsi od 35 znakov, nima breakov, ima pa sliko dodaj <br>
+
+ var txt = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html();
+ console.log(txt);
+ var n_img_start = txt.search("<img"); //var n = str.search("W3Schools"); //hrani index, kjer se začne html za sliko
+ var n_img_end = txt.indexOf(">");
+ console.log(n_img_start);
+ console.log(n_img_end);
+ //var txt_alt = txt.slice(0, max_cat_text_length) + "<br>" + txt.slice(max_cat_text_length);
+ //console.log(txt_alt);
+ //$('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).html(txt_alt);
+ //final_height = final_height + default_cat_height + 25;
+ //console.log(final_height);
+
+ } */
+
+
+ if (num_imgs != 0){ // ce imamo sliko
+
+ var img_height = 0;
+ //var max_width = $('.ranking').width();
+ var max_width = 230;
+ var img = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img');
+ var img_width = img.width();
+ //console.log("img_width: "+img_width);
+
+ var img_height = img.height();
+ //console.log("img_height: "+img_height);
+
+ if (img_width > max_width){
+ img_height = (img_height / img_width) * max_width;
+ img.css({width: max_width});
+ img.css({height: img_height});
+ //$('#vre_id_'+vre_id).css({height: height});
+ //console.log("Vecji od max width");
+ }
+
+ //ureditev mobilne različice prikazovanja slik znotraj kategorij odgovorov
+/* if (mobile == 1){ //ce je mobilnik
+ img_height = (img_height / img_width) * 100;
+ img_width = 100;
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').attr('style', 'margin: auto !important'); //dodaj atribut
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img').css({'height':img_height,'width':img_width}); //ustrezno spremeni visino in sirino slike
+ } */
+ //ureditev mobilne različice prikazovanja - konec
+
+ //console.log("img_height: "+img_height);
+ if(img_height > 25){ //ce je visina slike vecja od default visine kategorije
+ final_height = final_height + img_height;
+ }
+
+
+
+ //ureditev visine variable_holder, ki je znotraj okvirja !!!!!!!!!!
+ //$('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').css({'height':(final_height + img_height)+'px'});
+ }
+ if(num_of_br != 0){
+ var br_height = num_of_br*25;
+
+ if (num_imgs == 0){
+ final_height = final_height + default_cat_height + br_height;
+ }
+ else{
+ final_height = final_height + br_height;
+ }
+
+
+ //console.log(final_height);
+ if( (img_height < 25) && (img_height != 0) ){
+ final_height = final_height + img_height;
+ }
+ }
+ if (final_height != 0){
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).css({'height':final_height}); //dodaj style atributu še novo višino za levi blok
+ }
+ //ureditev visine kategorije (div) glede na prisotnost slike ali vecvrsticnega teksta - konec********************************************
+
+ //ureditev visine celotnega vprasanja****************************************************************************************************
+
+ //dynamic_question_height_ranking(spremenljivka, num_grids);
+
+ //ureditev visine celotnega vprasanja - konec*******************************************************************************************
+}
+
+//funkcija, ki ureja visina celotnega vprasanja glede na skupno visino kategorij v okvirjih
+function question_height_ranking(spremenljivka){
+ var final_height_kategorije_left = final_height_kategorije_right = final_height = tmp_height_kategorije_left = tmp_height_kategorije_right = naslov_height = 0;
+ var i = 1;
+ var j = 1;
+
+ var default_var_height_now = $('#spremenljivka_'+spremenljivka).height();
+
+ $('#half_'+spremenljivka).children('div').each(function(){ //preleti leve kategorije
+ //tmp_height_kategorije_left = $(this).height() + 10;
+ tmp_height_kategorije_left = $(this).outerHeight( true );
+ //console.log("tmp_height_kategorije_left "+i+": "+tmp_height_kategorije_left);
+ i++;
+ final_height_kategorije_left = final_height_kategorije_left + tmp_height_kategorije_left;
+ });
+
+ $('#half2_'+spremenljivka).children('div').each(function(){ //preleti desne kategorije
+ //tmp_height_kategorije_right = $(this).height() + 10;
+ tmp_height_kategorije_right = $(this).outerHeight( true );
+ //console.log("tmp_height_kategorije_right "+j+": "+tmp_height_kategorije_right);
+ j++;
+ final_height_kategorije_right = final_height_kategorije_right + tmp_height_kategorije_right;
+ });
+
+ if(final_height_kategorije_left > final_height_kategorije_right){
+ final_height_kategorije = final_height_kategorije_left;
+ }else{
+ final_height_kategorije = final_height_kategorije_right;
+ }
+
+ //console.log("final_height_kategorij: "+final_height_kategorije);
+
+ naslov_height = $('#spremenljivka_'+spremenljivka+' .naslov').height();
+ //console.log("naslov_height: "+naslov_height);
+
+ final_height = naslov_height + final_height_kategorije + 120;
+
+ //ureditev pozicije komentarjev
+ if($('#spremenljivka_'+spremenljivka+' .comment').length > 0) { //ali je kakšen komentar pri vprasanju z razvrscanjem?
+ //$('#prestavljanje_'+spremenljivka).height(final_height);
+ //final_height = final_height + 200; //koncni visini vprasanja dodamo se default visino komentarja
+ }
+ //ureditev pozicije komentarjev - konec
+
+
+ if(final_height > default_var_height_now){ //ce je nova visina vecja od default zacetne
+ $('#spremenljivka_'+spremenljivka).height(final_height);
+ //console.log(final_height);
+ //$('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(final_height + 25);
+ $('#spremenljivka_'+spremenljivka+' div.variable_holder.clr').height(final_height - naslov_height + 10);
+ }
+ //console.log("default_var_height_now: "+default_var_height_now);
+ //console.log("final_height: "+final_height);
+
+}
+
+
+
+function frame_height_ranking (ui, spremenljivka){
+ var trenutna_visina_prenesenega = ui.item.height();
+ //console.log(trenutna_visina_prenesenega);
+ var trenutni_okvir = $('#half2_'+spremenljivka);
+ var stevilo_prisotnih = trenutni_okvir.children('div').length;
+ //console.log(stevilo_prisotnih);
+ var i = 0;
+ trenutni_okvir.siblings().children('li').children('div').each(function(){ //preleti prazne okvirje
+ i = i + 1;
+ if(stevilo_prisotnih == i){
+ $(this).height(trenutna_visina_prenesenega);
+ //console.log(i);
+ }
+ });
+}
+
+function frame_height_ranking_premikanje_dyn (ui, spremenljivka){
+
+ var trenutna_visina_prenesenega = ui.item.height();
+ var trenutni_okvir = $('#sortzone_'+spremenljivka);
+ var stevilo_prisotnih = trenutni_okvir.children('div').length;
+ var iscem = 'vrednost_';
+ var tmp = ui.item.attr('id');
+ //var pos = tmp.search(iscem);
+ //var vre_id = tmp.slice(pos);
+ var vre_id = tmp.slice(tmp.search(iscem));
+ vre_id = vre_id.replace(iscem, '');
+ //console.log("Trenutni indeks: "+ui.item.index());
+ var sortedID = trenutni_okvir.sortable( "toArray" ); //trenutni vrstni red odgovorov v polje
+
+ var i = 0;
+ trenutni_okvir.siblings().children('li').children('div').each(function(){ //preleti okvirje
+ var visina = $('#'+sortedID[i]).height(); //visina i-tega odgovora
+ //console.log("Visina odgovora "+i+" : "+$('#'+sortedID[i]).height());
+ $(this).height(visina); //visina trenutnega okvirja naj bo enaka visini ustreznega odgovora
+ i = i + 1;
+ });
+}
+
+function frame_height_ranking_premikanje (spremenljivka, vre_id, vrstni_red){
+ var trenutna_visina_prenesenega = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).height();
+ var i = 0;
+ $('#sortzone_'+spremenljivka).siblings().children('li').children('div').each(function(){ //preleti prazne okvirje
+ i = i + 1;
+ if(vrstni_red == i){
+ $(this).height(trenutna_visina_prenesenega);
+ //console.log(i);
+ }
+ });
+}
+
+
+//************ za pravilno velikost slik
+//*********** funkcija za resize slik, ko so te vecje od max_width
+function ranking_image_resize(spremenljivka, vre_id){
+ //console.log("ranking_image_resize");
+ //var max_width = 220;
+ var max_width = $('.ranking').width();
+
+ //spremenljivka_4582_vrednost_24243
+
+ var img = $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id+' img');
+ var num_imgs = img.length; //hrani stevilo img v interesiranem div-u
+ if(num_imgs != 0){
+ var width = img.width();
+ var height = img.height();
+ if (width > max_width){
+ height = (height / width) * max_width;
+ img.css({width: max_width}); //sirina slike
+ img.css({height: height}); //visina slike
+ $('#spremenljivka_'+spremenljivka+'_vrednost_'+vre_id).css({height: height}); //visina okvirja
+ }
+ }
+}
+//*********** konec - funkcija za resize slik, ko so te vecje od max_width
+
+//*************************************** za pravilno velikost slik - konec \ No newline at end of file
diff --git a/main/survey/js/dhtmlgoodies_calendar.js b/main/survey/js/dhtmlgoodies_calendar.js
new file mode 100644
index 0000000..09d732b
--- /dev/null
+++ b/main/survey/js/dhtmlgoodies_calendar.js
@@ -0,0 +1,1518 @@
+/************************************************************************************************************
+JS Calendar
+Copyright (C) September 2006 DTHMLGoodies.com, Alf Magne Kalleland
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
+written by Alf Magne Kalleland.
+
+Alf Magne Kalleland, 2006
+Owner of DHTMLgoodies.com
+
+************************************************************************************************************/
+
+/* Update log:
+(C) www.dhtmlgoodies.com, September 2005
+
+Version 1.2, November 8th - 2005 - Added <iframe> background in IE
+Version 1.3, November 12th - 2005 - Fixed top bar position in Opera 7
+Version 1.4, December 28th - 2005 - Support for Spanish and Portuguese
+Version 1.5, January 18th - 2006 - Fixed problem with next-previous buttons after a month has been selected from dropdown
+Version 1.6, February 22nd - 2006 - Added variable which holds the path to images.
+ Format todays date at the bottom by use of the todayStringFormat variable
+ Pick todays date by clicking on todays date at the bottom of the calendar
+Version 2.0 May, 25th - 2006 - Added support for time(hour and minutes) and changing year and hour when holding mouse over + and - options. (i.e. instead of click)
+Version 2.1 July, 2nd - 2006 - Added support for more date formats(example: d.m.yyyy, i.e. one letter day and month).
+
+// Modifications by Gregg Buntin
+Version 2.1.1 8/9/2007 gfb - Add switch to turn off Year Span Selection
+ This allows me to only have this year & next year in the drop down
+
+Version 2.1.2 8/30/2007 gfb - Add switch to start week on Sunday
+ Add switch to turn off week number display
+ Fix bug when using on an HTTPS page
+
+*/
+var turnOffYearSpan = false; // true = Only show This Year and Next, false = show +/- 5 years
+var weekStartsOnSunday = false; // true = Start the week on Sunday, false = start the week on Monday
+var showWeekNumber = true; // true = show week number, false = do not show week number
+
+var languageCode = 'sl'; // Possible values: en,ge,no,nl,es,pt-br,fr,sl
+ // en = english, ge = german, no = norwegian,nl = dutch, es = spanish, pt-br = portuguese, fr = french, da = danish, hu = hungarian(Use UTF-8 doctype for hungarian)
+
+
+var calendar_display_time = true;
+
+// Format of current day at the bottom of the calendar
+// [todayString] = the value of todayString
+// [dayString] = day of week (examle: mon, tue, wed...)
+// [UCFdayString] = day of week (examle: Mon, Tue, Wed...) ( First letter in uppercase)
+// [day] = Day of month, 1..31
+// [monthString] = Name of current month
+// [year] = Current year
+var todayStringFormat = '[todayString] [UCFdayString]. [day]. [monthString] [year]';
+var pathToImages = 'images/'; // Relative to your HTML file
+
+var speedOfSelectBoxSliding = 200; // Milliseconds between changing year and hour when holding mouse over "-" and "+" - lower value = faster
+var intervalSelectBox_minutes = 5; // Minute select box - interval between each option (5 = default)
+
+var calendar_offsetTop = -100; // Offset - calendar placement - You probably have to modify this value if you're not using a strict doctype
+var calendar_offsetLeft = 50; // Offset - calendar placement - You probably have to modify this value if you're not using a strict doctype
+var calendarDiv = false;
+
+var MSIE = false;
+var Opera = false;
+if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0)MSIE=true;
+if(navigator.userAgent.indexOf('Opera')>=0)Opera=true;
+
+
+switch(languageCode){
+ case "en": /* English */
+ var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
+ var monthArrayShort = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
+ var dayArray = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];
+ var weekString = 'Week';
+ var todayString = '';
+ break;
+ case "ge": /* German */
+ var monthArray = ['Januar','Februar','M�rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];
+ var monthArrayShort = ['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'];
+ var dayArray = ['Mon','Die','Mit','Don','Fre','Sam','Son'];
+ var weekString = 'Woche';
+ var todayString = 'Heute';
+ break;
+ case "no": /* Norwegian */
+ var monthArray = ['Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember'];
+ var monthArrayShort = ['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Des'];
+ var dayArray = ['Man','Tir','Ons','Tor','Fre','L&oslash;r','S&oslash;n'];
+ var weekString = 'Uke';
+ var todayString = 'Dagen i dag er';
+ break;
+ case "nl": /* Dutch */
+ var monthArray = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'];
+ var monthArrayShort = ['Jan','Feb','Mar','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'];
+ var dayArray = ['Ma','Di','Wo','Do','Vr','Za','Zo'];
+ var weekString = 'Week';
+ var todayString = 'Vandaag';
+ break;
+ case "es": /* Spanish */
+ var monthArray = ['Enero','Febrero','Marzo','April','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'];
+ var monthArrayShort =['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];
+ var dayArray = ['Lun','Mar','Mie','Jue','Vie','Sab','Dom'];
+ var weekString = 'Semana';
+ var todayString = 'Hoy es';
+ break;
+ case "pt-br": /* Brazilian portuguese (pt-br) */
+ var monthArray = ['Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'];
+ var monthArrayShort = ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'];
+ var dayArray = ['Seg','Ter','Qua','Qui','Sex','S&aacute;b','Dom'];
+ var weekString = 'Sem.';
+ var todayString = 'Hoje &eacute;';
+ break;
+ case "fr": /* French */
+ var monthArray = ['Janvier','F�vrier','Mars','Avril','Mai','Juin','Juillet','Ao�t','Septembre','Octobre','Novembre','D�cembre'];
+ var monthArrayShort = ['Jan','Fev','Mar','Avr','Mai','Jun','Jul','Aou','Sep','Oct','Nov','Dec'];
+ var dayArray = ['Lun','Mar','Mer','Jeu','Ven','Sam','Dim'];
+ var weekString = 'Sem';
+ var todayString = "Aujourd'hui";
+ break;
+ case "da": /*Danish*/
+ var monthArray = ['januar','februar','marts','april','maj','juni','juli','august','september','oktober','november','december'];
+ var monthArrayShort = ['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec'];
+ var dayArray = ['man','tirs','ons','tors','fre','l&oslash;r','s&oslash;n'];
+ var weekString = 'Uge';
+ var todayString = 'I dag er den';
+ break;
+ case "hu": /* Hungarian - Remember to use UTF-8 encoding, i.e. the <meta> tag */
+ var monthArray = ['JanuĂĄr','FebruĂĄr','MĂĄrcius','ďż˝?prilis','MĂĄjus','JĂşnius','JĂşlius','Augusztus','Szeptember','OktĂłber','November','December'];
+ var monthArrayShort = ['Jan','Feb','MĂĄrc','ďż˝?pr','MĂĄj','JĂşn','JĂşl','Aug','Szep','Okt','Nov','Dec'];
+ var dayArray = ['HĂŠ','Ke','Sze','Cs','PĂŠ','Szo','Vas'];
+ var weekString = 'HĂŠt';
+ var todayString = 'Mai nap';
+ break;
+ case "it": /* Italian*/
+ var monthArray = ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'];
+ var monthArrayShort = ['Gen','Feb','Mar','Apr','Mag','Giu','Lugl','Ago','Set','Ott','Nov','Dic'];
+ var dayArray = ['Lun',';Mar','Mer','Gio','Ven','Sab','Dom'];
+ var weekString = 'Settimana';
+ var todayString = 'Oggi &egrave; il';
+ break;
+ case "sv": /* Swedish */
+ var monthArray = ['Januari','Februari','Mars','April','Maj','Juni','Juli','Augusti','September','Oktober','November','December'];
+ var monthArrayShort = ['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Aug','Sep','Okt','Nov','Dec'];
+ var dayArray = ['M&aring;n','Tis','Ons','Tor','Fre','L&ouml;r','S&ouml;n'];
+ var weekString = 'Vecka';
+ var todayString = 'Idag &auml;r det den';
+ break;
+ case "cz": /* Czech */
+ var monthArray = ['leden','&#250;nor','b&#345;ezen','duben','kv&#283;ten','&#269;erven','&#269;ervenec','srpen','z&#225;&#345;&#237;','&#345;&#237;jen','listopad','prosinec'];
+ var monthArrayShort = ['led','&#250;n','b&#345;','dub','kv&#283;','&#269;er','&#269;er-ec','srp','z&#225;&#345;','&#345;&#237;j','list','pros'];
+ var dayArray = ['Pon','&#218;t','St','&#268;t','P&#225;','So','Ne'];
+ var weekString = 't&#253;den';
+ var todayString = '';
+ break;
+ case "sl": /* Slovenian */
+ var monthArray = ['Januar','Februar','Marec','April','Maj','Junij','Julij','Avgust','September','Oktober','November','December'];
+ var monthArrayShort = ['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Avg','Sep','Okt','Nov','Dec'];
+ var dayArray = ['Pon','Tor','Sre','&#x10C;et','Pet','Sob','Ned'];
+ var weekString = 'Teden';
+ var todayString = 'Danes je:&nbsp;';
+ break;
+}
+
+if (weekStartsOnSunday) {
+ var tempDayName = dayArray[6];
+ for(var theIx = 6; theIx > 0; theIx--) {
+ dayArray[theIx] = dayArray[theIx-1];
+ }
+ dayArray[0] = tempDayName;
+}
+
+
+
+var daysInMonthArray = [31,28,31,30,31,30,31,31,30,31,30,31];
+var currentMonth;
+var currentYear;
+var currentHour;
+var currentMinute;
+var calendarContentDiv;
+var returnDateTo;
+var returnFormat;
+var activeSelectBoxMonth;
+var activeSelectBoxYear;
+var activeSelectBoxHour;
+var activeSelectBoxMinute;
+
+var iframeObj = false;
+//// fix for EI frame problem on time dropdowns 09/30/2006
+var iframeObj2 =false;
+function EIS_FIX_EI1(where2fixit)
+{
+
+ if(!iframeObj2)return;
+ iframeObj2.style.display = 'block';
+ iframeObj2.style.height =document.getElementById(where2fixit).offsetHeight+1;
+ iframeObj2.style.width=document.getElementById(where2fixit).offsetWidth;
+ iframeObj2.style.left=getleftPos(document.getElementById(where2fixit))+1-calendar_offsetLeft;
+ iframeObj2.style.top=getTopPos(document.getElementById(where2fixit))-document.getElementById(where2fixit).offsetHeight-calendar_offsetTop;
+}
+
+function EIS_Hide_Frame()
+{ if(iframeObj2)iframeObj2.style.display = 'none';}
+//// fix for EI frame problem on time dropdowns 09/30/2006
+var returnDateToYear;
+var returnDateToMonth;
+var returnDateToDay;
+var returnDateToHour;
+var returnDateToMinute;
+
+var inputYear;
+var inputMonth;
+var inputDay;
+var inputHour;
+var inputMinute;
+var calendarDisplayTime = false;
+
+var selectBoxHighlightColor = '#D60808'; // Highlight color of select boxes
+var selectBoxRolloverBgColor = '#E2EBED'; // Background color on drop down lists(rollover)
+
+var selectBoxMovementInProgress = false;
+var activeSelectBox = false;
+
+function cancelCalendarEvent()
+{
+ return false;
+}
+function isLeapYear(inputYear)
+{
+ if(inputYear%400==0||(inputYear%4==0&&inputYear%100!=0)) return true;
+ return false;
+
+}
+var activeSelectBoxMonth = false;
+var activeSelectBoxDirection = false;
+
+function highlightMonthYear()
+{
+ if(activeSelectBoxMonth)activeSelectBoxMonth.className='';
+ activeSelectBox = this;
+
+
+ if(this.className=='monthYearActive'){
+ this.className='';
+ }else{
+ this.className = 'monthYearActive';
+ activeSelectBoxMonth = this;
+ }
+
+ if(this.innerHTML.indexOf('-')>=0 || this.innerHTML.indexOf('+')>=0){
+ if(this.className=='monthYearActive')
+ selectBoxMovementInProgress = true;
+ else
+ selectBoxMovementInProgress = false;
+ if(this.innerHTML.indexOf('-')>=0)activeSelectBoxDirection = -1; else activeSelectBoxDirection = 1;
+
+ }else selectBoxMovementInProgress = false;
+
+}
+
+function showMonthDropDown()
+{
+ if(document.getElementById('monthDropDown').style.display=='block'){
+ document.getElementById('monthDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ }else{
+ document.getElementById('monthDropDown').style.display='block';
+ document.getElementById('yearDropDown').style.display='none';
+ document.getElementById('hourDropDown').style.display='none';
+ document.getElementById('minuteDropDown').style.display='none';
+ if (MSIE)
+ {
+ EIS_FIX_EI1('monthDropDown');
+ }
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+
+ }
+}
+
+function showYearDropDown()
+{
+ if(document.getElementById('yearDropDown').style.display=='block'){
+ document.getElementById('yearDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ }else{
+ document.getElementById('yearDropDown').style.display='block';
+ document.getElementById('monthDropDown').style.display='none';
+ document.getElementById('hourDropDown').style.display='none';
+ document.getElementById('minuteDropDown').style.display='none';
+ if (MSIE)
+ { EIS_FIX_EI1('yearDropDown'); }
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+
+ }
+
+}
+function showHourDropDown()
+{
+ if(document.getElementById('hourDropDown').style.display=='block'){
+ document.getElementById('hourDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ }else{
+ document.getElementById('hourDropDown').style.display='block';
+ document.getElementById('monthDropDown').style.display='none';
+ document.getElementById('yearDropDown').style.display='none';
+ document.getElementById('minuteDropDown').style.display='none';
+ if (MSIE)
+ { EIS_FIX_EI1('hourDropDown');}
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ }
+
+}
+function showMinuteDropDown()
+{
+ if(document.getElementById('minuteDropDown').style.display=='block'){
+ document.getElementById('minuteDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ }else{
+ document.getElementById('minuteDropDown').style.display='block';
+ document.getElementById('monthDropDown').style.display='none';
+ document.getElementById('yearDropDown').style.display='none';
+ document.getElementById('hourDropDown').style.display='none';
+ if (MSIE)
+ { EIS_FIX_EI1('minuteDropDown');}
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ }
+
+}
+
+function selectMonth()
+{
+ document.getElementById('calendar_month_txt').innerHTML = this.innerHTML
+ currentMonth = this.id.replace(/[^\d]/g,'');
+
+ document.getElementById('monthDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ for(var no=0;no<monthArray.length;no++){
+ document.getElementById('monthDiv_'+no).style.color='';
+ }
+ this.style.color = selectBoxHighlightColor;
+ activeSelectBoxMonth = this;
+ writeCalendarContent();
+
+}
+
+function selectHour()
+{
+ document.getElementById('calendar_hour_txt').innerHTML = this.innerHTML
+ currentHour = this.innerHTML.replace(/[^\d]/g,'');
+ document.getElementById('hourDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ if(activeSelectBoxHour){
+ activeSelectBoxHour.style.color='';
+ }
+ activeSelectBoxHour=this;
+ this.style.color = selectBoxHighlightColor;
+}
+
+function selectMinute()
+{
+ document.getElementById('calendar_minute_txt').innerHTML = this.innerHTML
+ currentMinute = this.innerHTML.replace(/[^\d]/g,'');
+ document.getElementById('minuteDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ if(activeSelectBoxMinute){
+ activeSelectBoxMinute.style.color='';
+ }
+ activeSelectBoxMinute=this;
+ this.style.color = selectBoxHighlightColor;
+}
+
+
+function selectYear()
+{
+ document.getElementById('calendar_year_txt').innerHTML = this.innerHTML
+ currentYear = this.innerHTML.replace(/[^\d]/g,'');
+ document.getElementById('yearDropDown').style.display='none';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();
+ if(activeSelectBoxYear){
+ activeSelectBoxYear.style.color='';
+ }
+ activeSelectBoxYear=this;
+ this.style.color = selectBoxHighlightColor;
+ writeCalendarContent();
+
+}
+
+function switchMonth()
+{
+ if(this.src.indexOf('left')>=0){
+ currentMonth=currentMonth-1;;
+ if(currentMonth<0){
+ currentMonth=11;
+ currentYear=currentYear-1;
+ }
+ }else{
+ currentMonth=currentMonth+1;;
+ if(currentMonth>11){
+ currentMonth=0;
+ currentYear=currentYear/1+1;
+ }
+ }
+
+ writeCalendarContent();
+
+
+}
+
+function createMonthDiv(){
+ var div = document.createElement('DIV');
+ div.className='monthYearPicker';
+ div.id = 'monthPicker';
+
+ for(var no=0;no<monthArray.length;no++){
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = monthArray[no];
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = highlightMonthYear;
+ subDiv.onclick = selectMonth;
+ subDiv.id = 'monthDiv_' + no;
+ subDiv.style.width = '56px';
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+ if(currentMonth && currentMonth==no){
+ subDiv.style.color = selectBoxHighlightColor;
+ activeSelectBoxMonth = subDiv;
+ }
+
+ }
+ return div;
+
+}
+
+function changeSelectBoxYear(e,inputObj)
+{
+ if(!inputObj)inputObj =this;
+ var yearItems = inputObj.parentNode.getElementsByTagName('DIV');
+ if(inputObj.innerHTML.indexOf('-')>=0){
+ var startYear = yearItems[1].innerHTML/1 -1;
+ if(activeSelectBoxYear){
+ activeSelectBoxYear.style.color='';
+ }
+ }else{
+ var startYear = yearItems[1].innerHTML/1 +1;
+ if(activeSelectBoxYear){
+ activeSelectBoxYear.style.color='';
+
+ }
+ }
+
+ for(var no=1;no<yearItems.length-1;no++){
+ yearItems[no].innerHTML = startYear+no-1;
+ yearItems[no].id = 'yearDiv' + (startYear/1+no/1-1);
+
+ }
+ if(activeSelectBoxYear){
+ activeSelectBoxYear.style.color='';
+ if(document.getElementById('yearDiv'+currentYear)){
+ activeSelectBoxYear = document.getElementById('yearDiv'+currentYear);
+ activeSelectBoxYear.style.color=selectBoxHighlightColor;;
+ }
+ }
+}
+function changeSelectBoxHour(e,inputObj)
+{
+ if(!inputObj)inputObj = this;
+
+ var hourItems = inputObj.parentNode.getElementsByTagName('DIV');
+ if(inputObj.innerHTML.indexOf('-')>=0){
+ var startHour = hourItems[1].innerHTML/1 -1;
+ if(startHour<0)startHour=0;
+ if(activeSelectBoxHour){
+ activeSelectBoxHour.style.color='';
+ }
+ }else{
+ var startHour = hourItems[1].innerHTML/1 +1;
+ if(startHour>14)startHour = 14;
+ if(activeSelectBoxHour){
+ activeSelectBoxHour.style.color='';
+
+ }
+ }
+ var prefix = '';
+ for(var no=1;no<hourItems.length-1;no++){
+ if((startHour/1 + no/1) < 11)prefix = '0'; else prefix = '';
+ hourItems[no].innerHTML = prefix + (startHour+no-1);
+
+ hourItems[no].id = 'hourDiv' + (startHour/1+no/1-1);
+
+ }
+ if(activeSelectBoxHour){
+ activeSelectBoxHour.style.color='';
+ if(document.getElementById('hourDiv'+currentHour)){
+ activeSelectBoxHour = document.getElementById('hourDiv'+currentHour);
+ activeSelectBoxHour.style.color=selectBoxHighlightColor;;
+ }
+ }
+}
+
+function updateYearDiv()
+{
+ var yearSpan = 5;
+ if (turnOffYearSpan) {
+ yearSpan = 0;
+ }
+ var div = document.getElementById('yearDropDown');
+ var yearItems = div.getElementsByTagName('DIV');
+ for(var no=1;no<yearItems.length-1;no++){
+ yearItems[no].innerHTML = currentYear/1 -yearSpan + no;
+ if(currentYear==(currentYear/1 -yearSpan + no)){
+ yearItems[no].style.color = selectBoxHighlightColor;
+ activeSelectBoxYear = yearItems[no];
+ }else{
+ yearItems[no].style.color = '';
+ }
+ }
+}
+
+function updateMonthDiv()
+{
+ for(no=0;no<12;no++){
+ document.getElementById('monthDiv_' + no).style.color = '';
+ }
+ document.getElementById('monthDiv_' + currentMonth).style.color = selectBoxHighlightColor;
+ activeSelectBoxMonth = document.getElementById('monthDiv_' + currentMonth);
+}
+
+
+function updateHourDiv()
+{
+ var div = document.getElementById('hourDropDown');
+ var hourItems = div.getElementsByTagName('DIV');
+
+ var addHours = 0;
+ if((currentHour/1 -6 + 1)<0){
+ addHours = (currentHour/1 -6 + 1)*-1;
+ }
+ for(var no=1;no<hourItems.length-1;no++){
+ var prefix='';
+ if((currentHour/1 -6 + no + addHours) < 10)prefix='0';
+ hourItems[no].innerHTML = prefix + (currentHour/1 -6 + no + addHours);
+ if(currentHour==(currentHour/1 -6 + no)){
+ hourItems[no].style.color = selectBoxHighlightColor;
+ activeSelectBoxHour = hourItems[no];
+ }else{
+ hourItems[no].style.color = '';
+ }
+ }
+}
+
+function updateMinuteDiv()
+{
+ for(no=0;no<60;no+=intervalSelectBox_minutes){
+ var prefix = '';
+ if(no<10)prefix = '0';
+
+ document.getElementById('minuteDiv_' + prefix + no).style.color = '';
+ }
+ if(document.getElementById('minuteDiv_' + currentMinute)){
+ document.getElementById('minuteDiv_' + currentMinute).style.color = selectBoxHighlightColor;
+ activeSelectBoxMinute = document.getElementById('minuteDiv_' + currentMinute);
+ }
+}
+
+
+
+function createYearDiv()
+{
+
+ if(!document.getElementById('yearDropDown')){
+ var div = document.createElement('DIV');
+ div.className='monthYearPicker';
+ }else{
+ var div = document.getElementById('yearDropDown');
+ var subDivs = div.getElementsByTagName('DIV');
+ for(var no=0;no<subDivs.length;no++){
+ subDivs[no].parentNode.removeChild(subDivs[no]);
+ }
+ }
+
+
+ var d = new Date();
+ if(currentYear){
+ d.setFullYear(currentYear);
+ }
+
+ var startYear = d.getFullYear()/1 - 5;
+
+ var yearSpan = 10;
+ if (! turnOffYearSpan) {
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = '&nbsp;&nbsp;- ';
+ subDiv.onclick = changeSelectBoxYear;
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = function(){ selectBoxMovementInProgress = false;};
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+ } else {
+ startYear = d.getFullYear()/1 - 0;
+ yearSpan = 2;
+ }
+
+ for(var no=startYear;no<(startYear+yearSpan);no++){
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = no;
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = highlightMonthYear;
+ subDiv.onclick = selectYear;
+ subDiv.id = 'yearDiv' + no;
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+ if(currentYear && currentYear==no){
+ subDiv.style.color = selectBoxHighlightColor;
+ activeSelectBoxYear = subDiv;
+ }
+ }
+ if (! turnOffYearSpan) {
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = '&nbsp;&nbsp;+ ';
+ subDiv.onclick = changeSelectBoxYear;
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = function(){ selectBoxMovementInProgress = false;};
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+ }
+ return div;
+}
+
+/* This function creates the hour div at the bottom bar */
+
+function slideCalendarSelectBox()
+{
+ if(selectBoxMovementInProgress){
+ if(activeSelectBox.parentNode.id=='hourDropDown'){
+ changeSelectBoxHour(false,activeSelectBox);
+ }
+ if(activeSelectBox.parentNode.id=='yearDropDown'){
+ changeSelectBoxYear(false,activeSelectBox);
+ }
+
+ }
+ setTimeout('slideCalendarSelectBox()',speedOfSelectBoxSliding);
+
+}
+
+function createHourDiv()
+{
+ if(!document.getElementById('hourDropDown')){
+ var div = document.createElement('DIV');
+ div.className='monthYearPicker';
+ }else{
+ var div = document.getElementById('hourDropDown');
+ var subDivs = div.getElementsByTagName('DIV');
+ for(var no=0;no<subDivs.length;no++){
+ subDivs[no].parentNode.removeChild(subDivs[no]);
+ }
+ }
+
+ if(!currentHour)currentHour=0;
+ var startHour = currentHour/1;
+ if(startHour>14)startHour=14;
+
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = '&nbsp;&nbsp;- ';
+ subDiv.onclick = changeSelectBoxHour;
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = function(){ selectBoxMovementInProgress = false;};
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+
+ for(var no=startHour;no<startHour+10;no++){
+ var prefix = '';
+ if(no/1<10)prefix='0';
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = prefix + no;
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = highlightMonthYear;
+ subDiv.onclick = selectHour;
+ subDiv.id = 'hourDiv' + no;
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+ if(currentYear && currentYear==no){
+ subDiv.style.color = selectBoxHighlightColor;
+ activeSelectBoxYear = subDiv;
+ }
+ }
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = '&nbsp;&nbsp;+ ';
+ subDiv.onclick = changeSelectBoxHour;
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = function(){ selectBoxMovementInProgress = false;};
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+
+ return div;
+}
+/* This function creates the minute div at the bottom bar */
+
+function createMinuteDiv()
+{
+ if(!document.getElementById('minuteDropDown')){
+ var div = document.createElement('DIV');
+ div.className='monthYearPicker';
+ }else{
+ var div = document.getElementById('minuteDropDown');
+ var subDivs = div.getElementsByTagName('DIV');
+ for(var no=0;no<subDivs.length;no++){
+ subDivs[no].parentNode.removeChild(subDivs[no]);
+ }
+ }
+ var startMinute = 0;
+ var prefix = '';
+ for(var no=startMinute;no<60;no+=intervalSelectBox_minutes){
+
+ if(no<10)prefix='0'; else prefix = '';
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = prefix + no;
+ subDiv.onmouseover = highlightMonthYear;
+ subDiv.onmouseout = highlightMonthYear;
+ subDiv.onclick = selectMinute;
+ subDiv.id = 'minuteDiv_' + prefix + no;
+ subDiv.onselectstart = cancelCalendarEvent;
+ div.appendChild(subDiv);
+ if(currentYear && currentYear==no){
+ subDiv.style.color = selectBoxHighlightColor;
+ activeSelectBoxYear = subDiv;
+ }
+ }
+ return div;
+}
+
+function highlightSelect()
+{
+
+ if(this.className=='selectBoxTime'){
+ this.className = 'selectBoxTimeOver';
+ this.getElementsByTagName('IMG')[0].src = pathToImages + 'down_time_over.gif';
+ }else if(this.className=='selectBoxTimeOver'){
+ this.className = 'selectBoxTime';
+ this.getElementsByTagName('IMG')[0].src = pathToImages + 'down_time.gif';
+ }
+
+ if(this.className=='selectBox'){
+ this.className = 'selectBoxOver';
+ this.getElementsByTagName('IMG')[0].src = pathToImages + 'down_over.gif';
+ }else if(this.className=='selectBoxOver'){
+ this.className = 'selectBox';
+ this.getElementsByTagName('IMG')[0].src = pathToImages + 'down.gif';
+ }
+
+}
+
+function highlightArrow()
+{
+ if(this.src.indexOf('over')>=0){
+ if(this.src.indexOf('left')>=0)this.src = pathToImages + 'left.gif';
+ if(this.src.indexOf('right')>=0)this.src = pathToImages + 'right.gif';
+ }else{
+ if(this.src.indexOf('left')>=0)this.src = pathToImages + 'left_over.gif';
+ if(this.src.indexOf('right')>=0)this.src = pathToImages + 'right_over.gif';
+ }
+}
+
+function highlightClose()
+{
+ if(this.src.indexOf('over')>=0){
+ this.src = pathToImages + 'close.gif';
+ }else{
+ this.src = pathToImages + 'close_over.gif';
+ }
+
+}
+
+function closeCalendar(){
+
+ document.getElementById('yearDropDown').style.display='none';
+ document.getElementById('monthDropDown').style.display='none';
+ document.getElementById('hourDropDown').style.display='none';
+ document.getElementById('minuteDropDown').style.display='none';
+
+ calendarDiv.style.display='none';
+ if(iframeObj){
+ iframeObj.style.display='none';
+ //// //// fix for EI frame problem on time dropdowns 09/30/2006
+ EIS_Hide_Frame();}
+ if(activeSelectBoxMonth)activeSelectBoxMonth.className='';
+ if(activeSelectBoxYear)activeSelectBoxYear.className='';
+
+
+}
+
+function writeTopBar()
+{
+
+ var topBar = document.createElement('DIV');
+ topBar.className = 'topBar';
+ topBar.id = 'topBar';
+ calendarDiv.appendChild(topBar);
+
+ // Left arrow
+ var leftDiv = document.createElement('DIV');
+ leftDiv.style.marginRight = '1px';
+ var img = document.createElement('IMG');
+ img.src = pathToImages + 'left.gif';
+ img.onmouseover = highlightArrow;
+ img.onclick = switchMonth;
+ img.onmouseout = highlightArrow;
+ leftDiv.appendChild(img);
+ topBar.appendChild(leftDiv);
+ if(Opera)leftDiv.style.width = '16px';
+
+ // Right arrow
+ var rightDiv = document.createElement('DIV');
+ rightDiv.style.marginRight = '1px';
+ var img = document.createElement('IMG');
+ img.src = pathToImages + 'right.gif';
+ img.onclick = switchMonth;
+ img.onmouseover = highlightArrow;
+ img.onmouseout = highlightArrow;
+ rightDiv.appendChild(img);
+ if(Opera)rightDiv.style.width = '16px';
+ topBar.appendChild(rightDiv);
+
+
+ // Month selector
+ var monthDiv = document.createElement('DIV');
+ monthDiv.id = 'monthSelect';
+ monthDiv.onmouseover = highlightSelect;
+ monthDiv.onmouseout = highlightSelect;
+ monthDiv.onclick = showMonthDropDown;
+ var span = document.createElement('SPAN');
+ span.innerHTML = monthArray[currentMonth];
+ span.id = 'calendar_month_txt';
+ monthDiv.appendChild(span);
+
+ var img = document.createElement('IMG');
+ img.src = pathToImages + 'down.gif';
+ img.style.position = 'absolute';
+ img.style.right = '0px';
+ monthDiv.appendChild(img);
+ monthDiv.className = 'selectBox';
+ if(Opera){
+ img.style.cssText = 'float:right;position:relative';
+ img.style.position = 'relative';
+ img.style.styleFloat = 'right';
+ }
+ topBar.appendChild(monthDiv);
+
+ var monthPicker = createMonthDiv();
+ monthPicker.style.left = '37px';
+ monthPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px';
+ monthPicker.style.width ='60px';
+ monthPicker.id = 'monthDropDown';
+
+ calendarDiv.appendChild(monthPicker);
+
+ // Year selector
+ var yearDiv = document.createElement('DIV');
+ yearDiv.onmouseover = highlightSelect;
+ yearDiv.onmouseout = highlightSelect;
+ yearDiv.onclick = showYearDropDown;
+ var span = document.createElement('SPAN');
+ span.innerHTML = currentYear;
+ span.id = 'calendar_year_txt';
+ yearDiv.appendChild(span);
+ topBar.appendChild(yearDiv);
+
+ var img = document.createElement('IMG');
+ img.src = pathToImages + 'down.gif';
+ yearDiv.appendChild(img);
+ yearDiv.className = 'selectBox';
+
+ if(Opera){
+ yearDiv.style.width = '50px';
+ img.style.cssText = 'float:right';
+ img.style.position = 'relative';
+ img.style.styleFloat = 'right';
+ }
+
+ var yearPicker = createYearDiv();
+ yearPicker.style.left = '113px';
+ yearPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px';
+ yearPicker.style.width = '35px';
+ yearPicker.id = 'yearDropDown';
+ calendarDiv.appendChild(yearPicker);
+
+
+ var img = document.createElement('IMG');
+ img.src = pathToImages + 'close.gif';
+ img.style.styleFloat = 'right';
+ img.onmouseover = highlightClose;
+ img.onmouseout = highlightClose;
+ img.onclick = closeCalendar;
+ topBar.appendChild(img);
+ if(!document.all){
+ img.style.position = 'absolute';
+ img.style.right = '2px';
+ }
+
+
+
+}
+
+function writeCalendarContent()
+{
+ var calendarContentDivExists = true;
+ if(!calendarContentDiv){
+ calendarContentDiv = document.createElement('DIV');
+ calendarDiv.appendChild(calendarContentDiv);
+ calendarContentDivExists = false;
+ }
+ currentMonth = currentMonth/1;
+ var d = new Date();
+
+ d.setFullYear(currentYear);
+ d.setDate(1);
+ d.setMonth(currentMonth);
+
+ var dayStartOfMonth = d.getDay();
+ if (! weekStartsOnSunday) {
+ if(dayStartOfMonth==0)dayStartOfMonth=7;
+ dayStartOfMonth--;
+ }
+
+ document.getElementById('calendar_year_txt').innerHTML = currentYear;
+ document.getElementById('calendar_month_txt').innerHTML = monthArray[currentMonth];
+ document.getElementById('calendar_hour_txt').innerHTML = currentHour;
+ document.getElementById('calendar_minute_txt').innerHTML = currentMinute;
+
+ var existingTable = calendarContentDiv.getElementsByTagName('TABLE');
+ if(existingTable.length>0){
+ calendarContentDiv.removeChild(existingTable[0]);
+ }
+
+ var calTable = document.createElement('TABLE');
+ calTable.width = '100%';
+ calTable.cellSpacing = '0';
+ calendarContentDiv.appendChild(calTable);
+
+
+
+
+ var calTBody = document.createElement('TBODY');
+ calTable.appendChild(calTBody);
+ var row = calTBody.insertRow(-1);
+ row.className = 'calendar_week_row';
+ if (showWeekNumber) {
+ var cell = row.insertCell(-1);
+ cell.innerHTML = weekString;
+ cell.className = 'calendar_week_column';
+ cell.style.backgroundColor = selectBoxRolloverBgColor;
+ }
+
+ for(var no=0;no<dayArray.length;no++){
+ var cell = row.insertCell(-1);
+ cell.innerHTML = dayArray[no];
+ }
+
+ var row = calTBody.insertRow(-1);
+
+ if (showWeekNumber) {
+ var cell = row.insertCell(-1);
+ cell.className = 'calendar_week_column';
+ cell.style.backgroundColor = selectBoxRolloverBgColor;
+ var week = getWeek(currentYear,currentMonth,1);
+ cell.innerHTML = week; // Week
+ }
+ for(var no=0;no<dayStartOfMonth;no++){
+ var cell = row.insertCell(-1);
+ cell.innerHTML = '&nbsp;';
+ }
+
+ var colCounter = dayStartOfMonth;
+ var daysInMonth = daysInMonthArray[currentMonth];
+ if(daysInMonth==28){
+ if(isLeapYear(currentYear))daysInMonth=29;
+ }
+
+ for(var no=1;no<=daysInMonth;no++){
+ d.setDate(no-1);
+ if(colCounter>0 && colCounter%7==0){
+ var row = calTBody.insertRow(-1);
+ if (showWeekNumber) {
+ var cell = row.insertCell(-1);
+ cell.className = 'calendar_week_column';
+ var week = getWeek(currentYear,currentMonth,no);
+ cell.innerHTML = week; // Week
+ cell.style.backgroundColor = selectBoxRolloverBgColor;
+ }
+ }
+ var cell = row.insertCell(-1);
+ if(currentYear==inputYear && currentMonth == inputMonth && no==inputDay){
+ cell.className='activeDay';
+ }
+ cell.innerHTML = no;
+ cell.onclick = pickDate;
+ colCounter++;
+ }
+
+
+ if(!document.all){
+ if(calendarContentDiv.offsetHeight)
+ document.getElementById('topBar').style.top = calendarContentDiv.offsetHeight + document.getElementById('timeBar').offsetHeight + document.getElementById('topBar').offsetHeight -1 + 'px';
+ else{
+ document.getElementById('topBar').style.top = '';
+ document.getElementById('topBar').style.bottom = '0px';
+ }
+
+ }
+
+ if(iframeObj){
+ if(!calendarContentDivExists)setTimeout('resizeIframe()',350);else setTimeout('resizeIframe()',10);
+ }
+
+
+
+
+}
+
+function resizeIframe()
+{
+ iframeObj.style.width = calendarDiv.offsetWidth + 'px';
+ iframeObj.style.height = calendarDiv.offsetHeight + 'px' ;
+
+
+}
+
+function pickTodaysDate()
+{
+ var d = new Date();
+ currentMonth = d.getMonth();
+ currentYear = d.getFullYear();
+ pickDate(false,d.getDate());
+
+}
+
+function pickDate(e,inputDay)
+{
+ var month = currentMonth/1 +1;
+ if(month<10)month = '0' + month;
+ var day;
+ if(!inputDay && this)day = this.innerHTML; else day = inputDay;
+
+ if(day/1<10)day = '0' + day;
+ if(returnFormat){
+ returnFormat = returnFormat.replace('dd',day);
+ returnFormat = returnFormat.replace('mm',month);
+ returnFormat = returnFormat.replace('yyyy',currentYear);
+ returnFormat = returnFormat.replace('hh',currentHour);
+ returnFormat = returnFormat.replace('ii',currentMinute);
+ returnFormat = returnFormat.replace('d',day/1);
+ returnFormat = returnFormat.replace('m',month/1);
+
+ returnDateTo.value = returnFormat;
+ try{
+ returnDateTo.onchange();
+ }catch(e){
+
+ }
+ }else{
+ for(var no=0;no<returnDateToYear.options.length;no++){
+ if(returnDateToYear.options[no].value==currentYear){
+ returnDateToYear.selectedIndex=no;
+ break;
+ }
+ }
+ for(var no=0;no<returnDateToMonth.options.length;no++){
+ if(returnDateToMonth.options[no].value==parseInt(month)){
+ returnDateToMonth.selectedIndex=no;
+ break;
+ }
+ }
+ for(var no=0;no<returnDateToDay.options.length;no++){
+ if(returnDateToDay.options[no].value==parseInt(day)){
+ returnDateToDay.selectedIndex=no;
+ break;
+ }
+ }
+ if(calendarDisplayTime){
+ for(var no=0;no<returnDateToHour.options.length;no++){
+ if(returnDateToHour.options[no].value==parseInt(currentHour)){
+ returnDateToHour.selectedIndex=no;
+ break;
+ }
+ }
+ for(var no=0;no<returnDateToMinute.options.length;no++){
+ if(returnDateToMinute.options[no].value==parseInt(currentMinute)){
+ returnDateToMinute.selectedIndex=no;
+ break;
+ }
+ }
+ }
+ }
+ closeCalendar();
+
+}
+
+// This function is from http://www.codeproject.com/csharp/gregorianwknum.asp
+// Only changed the month add
+function getWeek(year,month,day){
+ if (! weekStartsOnSunday) {
+ day = (day/1);
+ } else {
+ day = (day/1)+1;
+ }
+ year = year /1;
+ month = month/1 + 1; //use 1-12
+ var a = Math.floor((14-(month))/12);
+ var y = year+4800-a;
+ var m = (month)+(12*a)-3;
+ var jd = day + Math.floor(((153*m)+2)/5) +
+ (365*y) + Math.floor(y/4) - Math.floor(y/100) +
+ Math.floor(y/400) - 32045; // (gregorian calendar)
+ var d4 = (jd+31741-(jd%7))%146097%36524%1461;
+ var L = Math.floor(d4/1460);
+ var d1 = ((d4-L)%365)+L;
+ NumberOfWeek = Math.floor(d1/7) + 1;
+ return NumberOfWeek;
+}
+
+function writeTimeBar()
+{
+ var timeBar = document.createElement('DIV');
+ timeBar.id = 'timeBar';
+ timeBar.className = 'timeBar';
+
+ var subDiv = document.createElement('DIV');
+ subDiv.innerHTML = 'Time:';
+ //timeBar.appendChild(subDiv);
+
+ // Year selector
+ var hourDiv = document.createElement('DIV');
+ hourDiv.onmouseover = highlightSelect;
+ hourDiv.onmouseout = highlightSelect;
+ hourDiv.onclick = showHourDropDown;
+ hourDiv.style.width = '30px';
+ var span = document.createElement('SPAN');
+ span.innerHTML = currentHour;
+ span.id = 'calendar_hour_txt';
+ hourDiv.appendChild(span);
+ timeBar.appendChild(hourDiv);
+
+ var img = document.createElement('IMG');
+ img.src = pathToImages + 'down_time.gif';
+ hourDiv.appendChild(img);
+ hourDiv.className = 'selectBoxTime';
+
+ if(Opera){
+ hourDiv.style.width = '30px';
+ img.style.cssText = 'float:right';
+ img.style.position = 'relative';
+ img.style.styleFloat = 'right';
+ }
+
+ var hourPicker = createHourDiv();
+ hourPicker.style.left = '130px';
+ //hourPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px';
+ hourPicker.style.width = '35px';
+ hourPicker.id = 'hourDropDown';
+ calendarDiv.appendChild(hourPicker);
+
+ // Add Minute picker
+
+ // Year selector
+ var minuteDiv = document.createElement('DIV');
+ minuteDiv.onmouseover = highlightSelect;
+ minuteDiv.onmouseout = highlightSelect;
+ minuteDiv.onclick = showMinuteDropDown;
+ minuteDiv.style.width = '30px';
+ var span = document.createElement('SPAN');
+ span.innerHTML = currentMinute;
+
+ span.id = 'calendar_minute_txt';
+ minuteDiv.appendChild(span);
+ timeBar.appendChild(minuteDiv);
+
+ var img = document.createElement('IMG');
+ img.src = pathToImages + 'down_time.gif';
+ minuteDiv.appendChild(img);
+ minuteDiv.className = 'selectBoxTime';
+
+ if(Opera){
+ minuteDiv.style.width = '30px';
+ img.style.cssText = 'float:right';
+ img.style.position = 'relative';
+ img.style.styleFloat = 'right';
+ }
+
+ var minutePicker = createMinuteDiv();
+ minutePicker.style.left = '167px';
+ //minutePicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px';
+ minutePicker.style.width = '35px';
+ minutePicker.id = 'minuteDropDown';
+ calendarDiv.appendChild(minutePicker);
+
+
+ return timeBar;
+
+}
+
+function writeBottomBar()
+{
+ var d = new Date();
+ var bottomBar = document.createElement('DIV');
+
+ bottomBar.id = 'bottomBar';
+
+ bottomBar.style.cursor = 'pointer';
+ bottomBar.className = 'todaysDate';
+ // var todayStringFormat = '[todayString] [dayString] [day] [monthString] [year]'; ;;
+
+ var subDiv = document.createElement('DIV');
+ subDiv.onclick = pickTodaysDate;
+ subDiv.id = 'todaysDateString';
+ subDiv.style.width = (calendarDiv.offsetWidth - 95) + 'px';
+ var day = d.getDay();
+ if (! weekStartsOnSunday) {
+ if(day==0)day = 7;
+ day--;
+ }
+
+ var bottomString = todayStringFormat;
+ bottomString = bottomString.replace('[monthString]',monthArrayShort[d.getMonth()]);
+ bottomString = bottomString.replace('[day]',d.getDate());
+ bottomString = bottomString.replace('[year]',d.getFullYear());
+ bottomString = bottomString.replace('[dayString]',dayArray[day].toLowerCase());
+ bottomString = bottomString.replace('[UCFdayString]',dayArray[day]);
+ bottomString = bottomString.replace('[todayString]',todayString);
+
+
+ subDiv.innerHTML = todayString + ': ' + d.getDate() + '. ' + monthArrayShort[d.getMonth()] + ', ' + d.getFullYear() ;
+ subDiv.innerHTML = bottomString ;
+ bottomBar.appendChild(subDiv);
+
+ var timeDiv = writeTimeBar();
+ bottomBar.appendChild(timeDiv);
+
+ calendarDiv.appendChild(bottomBar);
+
+
+
+}
+function getTopPos(inputObj)
+{
+
+ var returnValue = inputObj.offsetTop + inputObj.offsetHeight;
+ while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
+ return returnValue + calendar_offsetTop;
+}
+
+function getleftPos(inputObj)
+{
+ var returnValue = inputObj.offsetLeft;
+ while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
+ return returnValue + calendar_offsetLeft;
+}
+
+function positionCalendar(inputObj)
+{
+ calendarDiv.style.left = getleftPos(inputObj) + 'px';
+ calendarDiv.style.top = getTopPos(inputObj) - calendarDiv.style.height + 'px';
+ if(iframeObj){
+ iframeObj.style.left = calendarDiv.style.left;
+ iframeObj.style.top = calendarDiv.style.top;
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ iframeObj2.style.left = calendarDiv.style.left;
+ iframeObj2.style.top = calendarDiv.style.top;
+ }
+
+}
+
+function initCalendar()
+{
+ if(MSIE){
+ iframeObj = document.createElement('IFRAME');
+ iframeObj.style.filter = 'alpha(opacity=0)';
+ iframeObj.style.position = 'absolute';
+ iframeObj.border='0px';
+ iframeObj.style.border = '0px';
+ iframeObj.style.backgroundColor = '#FF0000';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ iframeObj2 = document.createElement('IFRAME');
+ iframeObj2.style.position = 'absolute';
+ iframeObj2.border='0px';
+ iframeObj2.style.border = '0px';
+ iframeObj2.style.height = '1px';
+ iframeObj2.style.width = '1px';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ // Added fixed for HTTPS
+ iframeObj2.src = 'blank.html';
+ iframeObj.src = 'blank.html';
+ document.body.appendChild(iframeObj2); // gfb move this down AFTER the .src is set
+ document.body.appendChild(iframeObj);
+ }
+
+ calendarDiv = document.createElement('DIV');
+ calendarDiv.id = 'calendarDiv';
+ calendarDiv.style.zIndex = 1000;
+ slideCalendarSelectBox();
+
+ document.body.appendChild(calendarDiv);
+ writeBottomBar();
+ writeTopBar();
+
+
+
+ if(!currentYear){
+ var d = new Date();
+ currentMonth = d.getMonth();
+ currentYear = d.getFullYear();
+ }
+ writeCalendarContent();
+
+
+
+}
+
+function setTimeProperties()
+{
+ if(!calendarDisplayTime){
+ document.getElementById('timeBar').style.display='none';
+ document.getElementById('timeBar').style.visibility='hidden';
+ document.getElementById('todaysDateString').style.width = '100%';
+
+
+ }else{
+ document.getElementById('timeBar').style.display='block';
+ document.getElementById('timeBar').style.visibility='visible';
+ document.getElementById('hourDropDown').style.top = document.getElementById('calendar_minute_txt').parentNode.offsetHeight + calendarContentDiv.offsetHeight + document.getElementById('topBar').offsetHeight + 'px';
+ document.getElementById('minuteDropDown').style.top = document.getElementById('calendar_minute_txt').parentNode.offsetHeight + calendarContentDiv.offsetHeight + document.getElementById('topBar').offsetHeight + 'px';
+ document.getElementById('minuteDropDown').style.right = '50px';
+ document.getElementById('hourDropDown').style.right = '50px';
+ document.getElementById('todaysDateString').style.width = '115px';
+ }
+}
+
+function calendarSortItems(a,b)
+{
+ return a/1 - b/1;
+}
+
+
+function displayCalendar(inputField,format,buttonObj,displayTime,timeInput)
+{
+ if(displayTime)calendarDisplayTime=true; else calendarDisplayTime = false;
+
+ if(inputField.value.length>6){ //dates must have at least 6 digits...
+ if(!inputField.value.match(/^[0-9]*?$/gi)){
+
+ var items = inputField.value.split(/[^0-9]/gi);
+ var positionArray = new Object();
+ positionArray.m = format.indexOf('mm');
+ if(positionArray.m==-1)positionArray.m = format.indexOf('m');
+ positionArray.d = format.indexOf('dd');
+ if(positionArray.d==-1)positionArray.d = format.indexOf('d');
+ positionArray.y = format.indexOf('yyyy');
+ positionArray.h = format.indexOf('hh');
+ positionArray.i = format.indexOf('ii');
+
+
+ this.initialHour = '00';
+ this.initialMinute = '00';
+ var elements = ['y','m','d','h','i'];
+ var properties = ['currentYear','currentMonth','inputDay','currentHour','currentMinute'];
+ var propertyLength = [4,2,2,2,2];
+ for(var i=0;i<elements.length;i++) {
+ if(positionArray[elements[i]]>=0) {
+ window[properties[i]] = inputField.value.substr(positionArray[elements[i]],propertyLength[i])/1;
+ }
+ }
+
+ currentMonth--;
+ }else{
+ var monthPos = format.indexOf('mm');
+ currentMonth = inputField.value.substr(monthPos,2)/1 -1;
+ var yearPos = format.indexOf('yyyy');
+ currentYear = inputField.value.substr(yearPos,4);
+ var dayPos = format.indexOf('dd');
+ tmpDay = inputField.value.substr(dayPos,2);
+
+ var hourPos = format.indexOf('hh');
+ if(hourPos>=0){
+ tmpHour = inputField.value.substr(hourPos,2);
+ currentHour = tmpHour;
+ }else{
+ currentHour = '00';
+ }
+ var minutePos = format.indexOf('ii');
+ if(minutePos>=0){
+ tmpMinute = inputField.value.substr(minutePos,2);
+ currentMinute = tmpMinute;
+ }else{
+ currentMinute = '00';
+ }
+ }
+ }else{
+ var d = new Date();
+ currentMonth = d.getMonth();
+ currentYear = d.getFullYear();
+ currentHour = '08';
+ currentMinute = '00';
+ inputDay = d.getDate()/1;
+ }
+
+ inputYear = currentYear;
+ inputMonth = currentMonth;
+
+
+ if(!calendarDiv){
+ initCalendar();
+ }else{
+ if(calendarDiv.style.display=='block'){
+ closeCalendar();
+ return false;
+ }
+ writeCalendarContent();
+ }
+
+
+
+ returnFormat = format;
+ returnDateTo = inputField;
+ positionCalendar(buttonObj);
+ calendarDiv.style.visibility = 'visible';
+ calendarDiv.style.display = 'block';
+ if(iframeObj){
+ iframeObj.style.display = '';
+ iframeObj.style.height = '140px';
+ iframeObj.style.width = '195px';
+ iframeObj2.style.display = '';
+ iframeObj2.style.height = '140px';
+ iframeObj2.style.width = '195px';
+ }
+
+ setTimeProperties();
+ updateYearDiv();
+ updateMonthDiv();
+ updateMinuteDiv();
+ updateHourDiv();
+
+}
+
+function displayCalendarSelectBox(yearInput,monthInput,dayInput,hourInput,minuteInput,buttonObj)
+{
+ if(!hourInput)calendarDisplayTime=false; else calendarDisplayTime = true;
+
+ currentMonth = monthInput.options[monthInput.selectedIndex].value/1-1;
+ currentYear = yearInput.options[yearInput.selectedIndex].value;
+ if(hourInput){
+ currentHour = hourInput.options[hourInput.selectedIndex].value;
+ inputHour = currentHour/1;
+ }
+ if(minuteInput){
+ currentMinute = minuteInput.options[minuteInput.selectedIndex].value;
+ inputMinute = currentMinute/1;
+ }
+
+ inputYear = yearInput.options[yearInput.selectedIndex].value;
+ inputMonth = monthInput.options[monthInput.selectedIndex].value/1 - 1;
+ inputDay = dayInput.options[dayInput.selectedIndex].value/1;
+
+ if(!calendarDiv){
+ initCalendar();
+ }else{
+ writeCalendarContent();
+ }
+
+
+
+ returnDateToYear = yearInput;
+ returnDateToMonth = monthInput;
+ returnDateToDay = dayInput;
+ returnDateToHour = hourInput;
+ returnDateToMinute = minuteInput;
+
+
+
+
+ returnFormat = false;
+ returnDateTo = false;
+ positionCalendar(buttonObj);
+ calendarDiv.style.visibility = 'visible';
+ calendarDiv.style.display = 'block';
+ if(iframeObj){
+ iframeObj.style.display = '';
+ iframeObj.style.height = calendarDiv.offsetHeight + 'px';
+ iframeObj.style.width = calendarDiv.offsetWidth + 'px';
+ //// fix for EI frame problem on time dropdowns 09/30/2006
+ iframeObj2.style.display = '';
+ iframeObj2.style.height = calendarDiv.offsetHeight + 'px';
+ iframeObj2.style.width = calendarDiv.offsetWidth + 'px'
+ }
+ setTimeProperties();
+ updateYearDiv();
+ updateMonthDiv();
+ updateHourDiv();
+ updateMinuteDiv();
+
+}
diff --git a/main/survey/js/script.js b/main/survey/js/script.js
new file mode 100644
index 0000000..dc30154
--- /dev/null
+++ b/main/survey/js/script.js
@@ -0,0 +1,1971 @@
+// preveri - sesteje vrednosti spremenljivke za kalkulacijo
+function checkCalculation (spremenljivka, vrednost, grid, tip, calcMissing) {
+
+ var value = 0;
+
+ if (tip == 1) { // radio
+
+ value = parseInt( $('input[name=vrednost_'+spremenljivka+']:checked').attr('data-calculation') );
+
+ } else if (tip == 2) { // checkbox
+
+ var chbx = $('input#spremenljivka_'+spremenljivka+'_vrednost_'+vrednost+'');
+ if ( chbx.is(':checked') )
+ value = parseInt( chbx.attr('data-calculation') );
+ else
+ value = 0;
+
+ // ce ni izbran noben checkbox, potem je tudi kalkulacija -1
+ if ( $('input[name^=vrednost_'+spremenljivka+']:checked').length == 0) value = NaN;
+
+ } else if (tip == 3) { // dropdown
+
+ value = parseInt( $('select[name=vrednost_'+spremenljivka+'] option:selected').attr('data-calculation') );
+
+ } else if (tip == 6) { // multigrid
+
+ value = parseInt( $('input[name=vrednost_'+vrednost+(grid==1?'_part_2':'')+']:checked').attr('data-calculation') ); // obicen
+ if (isNaN(value)) value = parseInt( $('select[name=vrednost_'+vrednost+']').val() ); // roleta
+
+ } else if (tip == 8) {
+
+ var date = $('input#vrednost_'+spremenljivka).val();
+ date = date.split('.');
+ date = new Date(date[2], date[1]-1, date[0]); // zakaj se mesci zacnejo z 0?
+ value = Math.ceil( date.getTime() / (1000*60*60*24) );
+
+ } else if (tip == 7) { // number
+
+ value = parseFloat( $('input#spremenljivka_'+spremenljivka+'_vrednost_'+(parseInt(grid)+1)).val() );
+
+ } else if (tip == 16) { // multicheckbox
+
+ var chbx = $('input#vrednost_'+vrednost+'_grid_'+grid);
+ if ( chbx.is(':checked') )
+ value = parseInt( chbx.attr('data-calculation') );
+ else
+ value = 0;
+
+ // ce ni izbran noben checkbox v vrstici, potem je tudi kalkulacija -1
+ if ( $('input[name^=vrednost_'+vrednost+'_grid_]:checked').length == 0) value = NaN;
+
+ } else if (tip == 20) { // multinumber
+
+ value = parseInt( $('input#vrednost_'+vrednost+'_grid_'+grid).val() );
+
+ } else if (tip == 18) { // vsota
+
+ value = parseInt( $('input[name=spremenljivka_'+spremenljivka+'_vrednost_'+vrednost+']').val() );
+
+ } else if (tip == 17) { // ranking
+
+ if ( $('#half2_'+spremenljivka).length > 0 ) { // prestavljanje
+ var arr = $('#half2_'+spremenljivka).sortable('toArray');
+ } else if ( $('#sortzone_'+spremenljivka).length > 0 ) { // premikanje
+ var arr = $('#sortzone_'+spremenljivka).sortable('toArray');
+ } else { // ostevilcevanje
+ var arr = null;
+ value = $('input[name=spremenljivka_'+spremenljivka+'_vrednost_'+vrednost+']').val();
+ }
+
+ // prestavljanje in premikanje
+ if (arr != null) {
+ for (i=0; i<arr.length; i++) {
+ if ( arr[i] == 'ranking_'+vrednost || arr[i] == 'handle_'+vrednost )
+ value = i+1;
+ }
+
+ if (value == 0) value = NaN;
+ }
+
+ } else if (tip == 22) { // calculation
+
+ value = parseFloat( $('input#vrednost_'+spremenljivka).val() );
+
+ }
+
+
+ // Odvisno kako imamo nastavljeno v kalkulaciji da obravnavamo missinge
+ // ce je kateri od odgovorov missing, se steje kot 0
+ if(calcMissing == 1 && isNaN(value)){
+ value = 0;
+ }
+ // ce je kateri od odgovorov missing, je tudi cela kalkulacija missing (-88)
+ else if(isNaN(value)){
+ value = NaN;
+ }
+
+
+ return value;
+}
+
+// preveri number field, cela - stevilo celih mest, dec - stevilo decimalnih mest
+function checkNumber (field, cela, dec) {
+
+ var val = field.value;
+ var okval = '';
+ var decimal = false;
+ var separator = false;
+
+ for (var i=0; i<val.length; i++) {
+
+ if (val.charAt(i) != ' ' && val.charAt(i) >= 0 && val.charAt(i) <= 9) {
+
+ if (!decimal) {
+
+ if (cela > 0) {
+ okval = okval + val.charAt(i);
+ cela = cela - 1;
+ }
+
+ } else {
+
+ if (dec > 0) {
+ okval = okval + val.charAt(i);
+ dec = dec - 1;
+ }
+
+ }
+
+ } else if (val.charAt(i) == '.' || val.charAt(i) == ',') {
+
+ if (i == 0 || dec == 0)
+ break;
+
+ if (!separator)
+ okval = okval + '.';
+
+ separator = true;
+ decimal = true;
+
+ } else if (i == 0 && val.charAt(i) == '-') {
+ okval = okval + '-';
+ }
+ }
+
+ if (val != okval)
+ field.value = okval;
+
+}
+
+function convertDate(date){
+
+ var dateParts = date.split('.');
+ var newDate = dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0];
+
+ return newDate;
+}
+
+function calcSum (spremenljivka, counter, limit) {
+
+ var sum = 0;
+ var def = true;
+
+ for(var i=0; i<counter; i++){
+ var id = 'spremenljivka_' + spremenljivka + '_sestevanec_' + i;
+
+ if ( document.getElementById(id).parentNode.style.display != "none" )
+ if (parseFloat(document.getElementById(id).value) > 0) {
+ sum += parseFloat(document.getElementById(id).value);
+ def = false;
+ }
+ }
+
+ var id = 'spremenljivka_' + spremenljivka + '_vsota';
+ document.getElementById(id).value = sum;
+ $('#'+id).removeClass("def");
+ if (def) $('#'+id).addClass("def");
+}
+
+var radio_list = new Array(); // seznam obkljukanih radio buttnov (kamor spadajo tudi multigrid radii)
+var radio_vals = new Array(); // value za skupino radio buttnov iz radio_list (kater je dejansko obkljukan)
+
+
+// preveri, ce je bil radio obkljukan in v primeru, da smo se enkrat kliknili nanj, ga odkljuka
+function checkChecked (radio) {
+ // najprej preverimo ce je trenutni radio checked (in ga v tem primeru odkljuka)
+ for (var i=0; i<radio_list.length; i++) {
+ if (radio_list[i] == radio.name && radio_vals[i] == radio.value) {
+ radio_list.splice(i, 1);
+ radio_vals.splice(i, 1);
+ radio.checked = false;
+ return;
+ }
+ }
+
+ // ni checked, torej ga bomo dodali na seznam
+ // najprej preverimo ce je bil ze izbran kater drug iz skupine
+ for (var i=0; i<radio_list.length; i++) {
+ if (radio_list[i] == radio.name) {
+ radio_vals[i] = radio.value;
+ return;
+ }
+ }
+
+ // checkan je bil prvi v skupini, tko da ga mormo na novo dodat
+ radio_list[radio_list.length] = radio.name;
+ radio_vals[radio_vals.length] = radio.value;
+
+}
+
+// Nastavi razred parentu da je odkljukan (da lahko odkljukanim textom nastavljamo css)
+// mm - multi grid on mobile
+// mmt - multi grid table on mobile
+function setCheckedClass(element, type, ifId){
+ var id = element.value;
+
+
+ // Mobile vprasanje
+ if(type == 'mm'){
+ if(element.checked) {
+ $('[for="vrednost_' + ifId + '_grid_' + id + '"]').parent().siblings().removeClass('checked');
+ $('[for="vrednost_' + ifId + '_grid_' + id + '"]').parent().addClass('checked');
+ }
+ else{
+ $('[for="vrednost_' + ifId + '_grid_' + id + '"]').parent().removeClass('checked');
+ }
+ }
+ // Mobile tabela
+ else if(type == 'mmt'){
+
+ if(element.checked) {
+
+ // Posebej obravnavamo missinge
+ if($(element).parent().hasClass("missing")){
+ $('#vrednost_if_' + ifId).find('.grid_mobile_variable').removeClass('checked');
+ $('#vrednost_if_' + ifId).find('.visual-radio-scale').removeClass('checked');
+
+ $('#grid_missing_value_' + ifId + '_grid_' + id).parent().parent().addClass('checked');
+ }
+ else{
+ // Pri checkboxu ne ugasnemo ostalih
+ if(!$('#vrednost_if_' + ifId).parent().hasClass('checkbox')){
+ $('#vrednost_if_' + ifId).find('.grid_mobile_variable').removeClass('checked');
+ $('#vrednost_if_' + ifId).find('.visual-radio-scale').removeClass('checked');
+ }
+
+ $('#vrednost_' + ifId + '_grid_' + id).parent().parent().addClass('checked');
+ }
+ }
+ else{
+ // Posebej obravnavamo missinge
+ if($(element).parent().hasClass("missing")){
+ $('#grid_missing_value_' + ifId + '_grid_' + id).parent().parent().removeClass('checked');
+ }
+ else{
+ $('#vrednost_' + ifId + '_grid_' + id).parent().parent().removeClass('checked');
+ }
+ }
+ }
+ // Mobile dvojna tabela
+ else if(type == 'mmt6-3-1' || type == 'mmt6-3-2'){
+
+ // Drugi del dvojne tabele
+ if(type == 'mmt6-3-2'){
+ if(element.checked) {
+
+ // Pri checkboxu ne ugasnemo ostalih
+ if(!$('#vrednost_if_' + ifId).parent().hasClass('checkbox')){
+ $('#vrednost_if_' + ifId).find('.grid_mobile_variables.part_2').find('.grid_mobile_variable').removeClass('checked');
+ }
+
+ $('#vrednost_' + ifId + '_grid_' + id + '_part_2').parent().parent().addClass('checked');
+ }
+ else{
+ $('#vrednost_' + ifId + '_grid_' + id + '_part_2').parent().parent().removeClass('checked');
+ }
+ }
+ else{
+ if(element.checked) {
+
+ // Pri checkboxu ne ugasnemo ostalih
+ if(!$('#vrednost_if_' + ifId).parent().hasClass('checkbox')){
+ $('#vrednost_if_' + ifId).find('.grid_mobile_variables.part_1').find('.grid_mobile_variable').removeClass('checked');
+ }
+
+ $('#vrednost_' + ifId + '_grid_' + id).parent().parent().addClass('checked');
+ }
+ else{
+ $('#vrednost_' + ifId + '_grid_' + id).parent().parent().removeClass('checked');
+ }
+ }
+
+
+ }
+ else {
+ if(ifId) {
+ id = ifId;
+
+ if (element.checked) {
+ if(type != 16 && type != '6-3-1' && type != '6-3-2')
+ $('#vrednost_if_' + id).find('td').removeClass('checked'); //vse ostale checkboxe odstranimo
+
+ // Dvojni grid
+ if(type == '6-3-1')
+ $('#vrednost_if_' + id).find('input:not([name$="_part_2"])').closest('td').removeClass('checked');
+ else if(type == '6-3-2')
+ $('#vrednost_if_' + id).find('input[name$="_part_2"]').closest('td').removeClass('checked');
+
+ $(element).closest('td').addClass('checked');
+ }
+ else {
+ $(element).closest('td').removeClass('checked');
+ }
+ }
+
+ if (element.checked) {
+ $("#vrednost_if_" + id).addClass('checked');
+ }
+ else {
+ $("#vrednost_if_" + id).removeClass('checked');
+ }
+
+ // za radio gumbe se ugasnemo ostale
+ if(type == 1){
+
+ var name = $(element).attr('name');
+ var idVprasanja = name.substring(9); //dobimo ID vprasanja
+
+ //Image HotSpot: za brisanje obmocja
+ //identifier za sliko na katero se veze mapa z obmocji
+ var image1 = $('#hotspot_'+idVprasanja+'_image');
+
+ $("input[name="+name+"]").each(function(){
+ var loop_id = this.value;
+ id = element.value;
+
+ if(loop_id != id){
+ $("#vrednost_if_" + loop_id).removeClass('checked');
+ $('#spremenljivka_'+idVprasanja+'_vrednost_'+loop_id).closest('td').removeClass('checked');
+
+ //Image HotSpot: brisemo obmocja iz slike
+ image1.mapster('set', false, loop_id); //spucaj trenutno obmocje iz slike
+ }
+ });
+ }
+ }
+}
+
+function customRadioSelect(idElementa, value){
+ //najprej odstranimo class="obarvan" i
+ $('#vrednost_if_'+idElementa).siblings().removeClass('obarvan');
+
+ //pobarvamo ustrezno število elementov pred izbranim odgovorom
+ var trenutniElement = 'vrednost_if_'+idElementa;
+ while(trenutniElement){
+ trenutniElement = $('#'+trenutniElement).addClass('obarvan').prev().attr('id');
+ }
+}
+
+function customRadioTableSelect(idElementa, value){
+ //najprej odstranimo class="obarvan" i
+ $('#vrednost_if_'+idElementa+' .custom_radio_picture').removeClass('obarvan');
+
+ //pobarvamo ustrezno število elementov pred izbranim odgovorom
+ for(var i=value; i > 0; i--){
+ $('label[for="vrednost_'+idElementa+'_grid_'+i+'"]').parent().addClass('obarvan');
+ }
+}
+function customRadioTableSelectMobile(idElementa, value){
+ //najprej odstranimo class="obarvan" i
+ $('#vrednost_if_'+idElementa+' .custom_radio_picture').removeClass('obarvan');
+
+ //pobarvamo ustrezno število elementov pred izbranim odgovorom
+ for(var i=value; i > 0; i--){
+ $('label[for="vrednost_'+idElementa+'_grid_'+i+'"]').find('.custom_radio_picture').addClass('obarvan');
+ }
+}
+
+
+function checkboxLimit (spremenljivka, vrednost, checkbox_limit) {
+
+ obj = document.forms['vnos'].elements['vrednost_'+spremenljivka+'[]'];
+ var len = obj.length;
+ var count = 0;
+
+ for (i=0; i<len; i++)
+ if (obj[i].checked)
+ count++;
+
+ if (count > checkbox_limit){
+ document.getElementById('spremenljivka_'+spremenljivka+'_vrednost_'+vrednost).checked = false;
+ alert(lang_srv_remind_checkbox_max_violated_hard);
+ }
+
+}
+
+function checkboxLimitTextbox (spremenljivka, vrednost, checkbox_limit) {
+
+ obj = document.forms['vnos'].elements['vrednost_'+spremenljivka+'[]'];
+ var len = obj.length;
+ var count = 0;
+
+ for (i=0; i<len; i++)
+ if (obj[i].checked)
+ count++;
+
+ if (count > checkbox_limit){
+ document.getElementById('spremenljivka_'+spremenljivka+'_vrednost_'+vrednost).checked = false;
+ document.getElementById('spremenljivka_'+spremenljivka+'_textfield_'+vrednost).blur();
+ }
+}
+
+function addFormField(spremenljivka) {
+ var id = document.getElementById("counter").value;
+ $("#divTxt" + spremenljivka).append("<div id='row" + id + "' class='sn_name'><input type='text' value='' size=40 name='spremenljivka_" + spremenljivka + "[]' id='txt" + id + "' onblur='checkName(" + spremenljivka + ", this); checkBranching();' /> <a href='#' onClick='removeFormField(\"#row" + id + "\"); return false;'><span class=\"faicon delete\"></span></a></div>");
+
+ id = (id - 1) + 2;
+ document.getElementById("counter").value = id;
+}
+
+function removeFormField(id) {
+ $(id).remove();
+}
+
+
+// drop pri SN podpori
+function accept_droppable (child, parent) {
+ $('#' + child).load('ajax.php?a=accept_droppable', {child: child, parent: parent, anketa: srv_meta_anketa_id});
+}
+
+// drop pri ranking vprasanju (tip n>k)
+function accept_ranking (child, parent, spremenljivka, usr_id) {
+ $('#' + child).load('ajax.php?a=accept_ranking', {child: child, parent: parent, spremenljivka: spremenljivka, usr_id: usr_id, anketa: srv_meta_anketa_id});
+}
+
+
+//SN design ??
+function dodaj_ime (spremenljivka, ime){
+ $('#imena_'+spremenljivka).load('ajax.php?a=dodaj_ime', {spremenljivka: spremenljivka, ime: ime, anketa: srv_meta_anketa_id});
+}
+
+//SN design 3
+function edit_size (spremenljivka, size) {
+
+ var new_fields = '';
+
+ for(var i=1; i<=size; i++){
+
+ new_fields += '<div id="row'+i+'" class="sn_name"><input type="text" name="spremenljivka_'+spremenljivka+'[]" id="txt'+i+'" size="40" onblur="checkName(\''+spremenljivka+'\', this); checkBranching();"></div>';
+ }
+ $('#imena_'+spremenljivka).html(new_fields);
+}
+
+function checkName (spremenljivka, polje){
+
+ var field = polje.value;
+ var imena = ['o\u010De','mati','mama','ata','h\u010Di','h\u010Der','sin','brat','sestra','teta','stric','bratranec','sestri\u010Dna','svak','svakinja','ta\u0161\u010Da','tast','dedek','babica','prijatelj','prijatelji','prijateljica','kolegi','kolega','kolegica','sosed','soseda','znanec','znanka','dru\u017Eina','noben','noben drug','nih\u010De','ni\u010D','sodelavec','sodelavka'];
+
+ var index = imena.indexOf(field);
+ if(index != -1){
+ polje.value = '';
+ alert('Opozorilo: napa\u010Den vpis\r\n\r\nPonovno vpi\u0161ite ime in za\u010Detnico priimka');
+ }
+ //$('#right_'+spremenljivka).load('ajax.php?a=check_name', {spremenljivka: spremenljivka, field: field});
+}
+
+
+function checkRankingNum (field, max, spremenljivka, count){
+
+ var val = field.value;
+ var ok = true;
+ var temp;
+
+ for(var i=0; i<count; i++){
+ var id = 'spremenljivka_' + spremenljivka + '_ranking_cifre_' + i;
+ temp = document.getElementById(id).value;
+ if((temp == val) && (field.id != id)){
+ ok = false;
+ break;
+ }
+ }
+
+ if(!ok && val != ''){
+ alert(lang_srv_alert_number_exists);
+ field.value = '';
+ }
+
+
+ if(val > max){
+ alert(lang_srv_alert_number_toobig);
+ field.value = '';
+ }
+}
+
+//preverjamo ce smo dosegli stevilo vnosov
+function checkRankingCount (field, max, spremenljivka, count){
+
+ var val = field.value;
+ var counter = 0;
+
+ for(var i=0; i<count; i++){
+ var id = 'spremenljivka_' + spremenljivka + '_ranking_cifre_' + i;
+ temp = document.getElementById(id).value;
+ if(temp != ''){
+ counter++;
+ }
+ }
+
+ for(var i=0; i<count; i++){
+ var id = 'spremenljivka_' + spremenljivka + '_ranking_cifre_' + i;
+ temp = document.getElementById(id).value;
+ if( (temp == '') && (counter == max) ){
+ document.getElementById(id).disabled = true;
+ }
+ else{
+ document.getElementById(id).disabled = false;
+ }
+ }
+
+}
+
+
+// za missing vrednosti za checkboxe in radio (disejbla ostale možne odgovore če je izbran missing)
+function checkMissing (__this) {
+
+ // polovimo id vrednosti
+ var vrednost_id = $(__this).val();
+ var spremenljivka_id = $(__this).attr('id');
+ spremenljivka_id = spremenljivka_id.replace("missing_value_spremenljivka_", "");
+ spremenljivka_id = spremenljivka_id.replace("_vrednost_"+vrednost_id+"", "");
+
+ //Image HotSpot: za brisanje obmocja
+ //identifier za sliko na katero se veze mapa z obmocji
+ var image1 = $('#hotspot_'+spremenljivka_id+'_image');
+
+ // preštejemo koliko missingov je izbranih
+ var missing_selected = $("input[id^=missing_value_spremenljivka_"+spremenljivka_id+"]:checked").length;
+
+ // izbran je lahko samo 1 missing naenkrat
+ if (missing_selected > 1) {
+ $('#mv_cal_on_'+spremenljivka_id).addClass('hidden');
+ $('#mv_cal_off_'+spremenljivka_id).removeClass('hidden');
+ $("input[id^=missing_value_spremenljivka_"+spremenljivka_id+"]:checked").each(function (index, value) {
+ if ( $(value).val() == vrednost_id) {
+ //kliknjen missing je trenutni v loopu
+ } else {
+ //kliknjen missing ni trenutni v loopu - ga disejblamo
+ $(value).attr('checked',false);
+ }
+ });
+ }
+
+ // disejbamo ali enejblamo vnosna polja
+ if (missing_selected > 0) {
+ $('#mv_cal_on_'+spremenljivka_id).hide();
+ $('#mv_cal_off_'+spremenljivka_id).show();
+
+ // diesjblamo vse ostale opcije za vrstico in deselectiramo
+ $("input[id^=spremenljivka_"+spremenljivka_id+"]").each(function (index, value) {
+
+ var el_type = $(value).attr('type'); // tip elementa ki ga disejblamo
+ $(this).attr('disabled', true); // disejblamo
+ // checkboxe še vgasnemo
+ if (el_type == 'checkbox') {
+ $(this).attr('checked', false); // checkboxe ugasnemo
+ //Image HotSpot: brisemo obmocja iz slike
+ image1.mapster('set', false, $(this).val()); //spucaj trenutno obmocje iz slike
+ }
+ if (el_type == 'text') {
+ $(this).val(''); // pobrisemo tekst
+ $(this).addClass('disabled'); // posivimo
+ }
+ });
+
+ $("div#spremenljivka_"+spremenljivka_id+".tip_8 input[type=text]").val('').attr('disabled', true).addClass('disabled');
+
+ // Posebej se disejblamo textarea
+ $("textarea[id^=spremenljivka_"+spremenljivka_id+"]").each(function (index, value) {
+ $(this).attr('disabled', true); // disejblamo
+ $(this).val(''); // pobrisemo tekst
+ $(this).addClass('disabled'); // posivimo
+ });
+
+ } else {
+ //preverimo ali je kateri checkbox čekiran
+ $('#mv_cal_off_'+spremenljivka_id).hide();
+ $('#mv_cal_on_'+spremenljivka_id).show();
+
+ // enejblamo vse ostale opcije za vrstico
+ $("input[id^=spremenljivka_"+spremenljivka_id+"]").each(function (index, value) {
+ var el_type = $(value).attr('type'); // tip elementa ki ga enejblamo
+ $(this).attr('disabled', false); //enejblamo
+ if (el_type == 'text') {
+ $(this).removeClass('disabled'); // osvetlimo
+ }
+
+ });
+
+ $("div#spremenljivka_"+spremenljivka_id+".tip_8 input[type=text]").val('').attr('disabled', false).removeClass('disabled');
+
+ // Posebej se enablamo textarea
+ $("textarea[id^=spremenljivka_"+spremenljivka_id+"]").each(function (index, value) {
+ $(this).attr('disabled', false); //enejblamo
+ $(this).removeClass('disabled'); // osvetlimo
+ });
+ }
+
+}
+
+// za missing vrednosti za tabelarične odgovore
+function checkTableMissing (__this) {
+
+ // polovimo id vrednosti
+ var grid_id = $(__this).val();
+ var vrednost_id = $(__this).attr('id');
+ vrednost_id = vrednost_id.replace("grid_missing_value_", "");
+ vrednost_id = vrednost_id.replace("_grid_"+grid_id, "");
+
+ // preštejemo koliko missingov je izbranih
+ var missing_selected = $("input[id^=grid_missing_value_"+vrednost_id+"_grid_]:checked").length;
+ // izbran je lahko samo 1 missing naenkraz
+ if (missing_selected > 1) {
+ $("input[id^=grid_missing_value_"+vrednost_id+"_grid_]:checked").each(function (index, value) {
+ if ($(value).attr('id') == 'grid_missing_value_'+vrednost_id+'_grid_'+grid_id) {
+ //kliknjen missing je trenutni v loopu
+ } else {
+ //kliknjen missing ni trenutni v loopu - ga disejblamo
+ $(value).attr('checked',false);
+ }
+ });
+ }
+
+ // disejbamo ali enejblamo vnosna polja
+ if (missing_selected > 0) {
+ // diesjblamo vse ostale opcije za vrstico in deselectiramo
+ $("input[id^=vrednost_"+vrednost_id+"_grid_], textarea[id^=vrednost_"+vrednost_id+"_grid_],").each(function (index, value) {
+ var el_type = $(value).attr('type'); // tip elementa ki ga disejblamo
+
+ //TOLE PRI GRIDU Z RADIOBUTTNI NI POTREBNO?
+ if (el_type != 'radio') {
+ $(this).attr('disabled', true); // disejblamo
+ }
+
+ // checkboxe še vgasnemo
+ if (el_type == 'checkbox') {
+ $(this).attr('checked', false); // checkboxe ugasnemo
+ }
+ if (el_type == 'text' || $(value).is('textarea')) {
+ $(this).val(''); // pobrisemo tekst
+ $(this).addClass('disabled'); // posivimo
+ }
+
+ });
+ // diesjblamo še polje drugo
+ $("input[name^=textfield_"+vrednost_id+"], textarea[name^=textfield_"+vrednost_id+"]").each(function (index, value) {
+ $(this).attr('disabled', true); // disejblamo
+ $(this).addClass('disabled'); // posivimo
+ $(this).val(''); // pobrišemo tekst
+ });
+
+ } else {
+ //preverimo ali je kateri checkbox čekiran
+
+ // enejblamo vse ostale opcije za vrstico
+ $("input[id^=vrednost_"+vrednost_id+"_grid_], textarea[id^=vrednost_"+vrednost_id+"_grid_]").each(function (index, value) {
+ var el_type = $(value).attr('type'); // tip elementa ki ga enejblamo
+ $(this).attr('disabled', false); //enejblamo
+ if (el_type == 'text' || $(value).is('textarea')) {
+ $(this).removeClass('disabled'); // osvetlimo
+ }
+
+ });
+ // enejblamo še polje drugo
+ $("input[name^=textfield_"+vrednost_id+"], textarea[name^=textfield_"+vrednost_id+"]").each(function (index, value) {
+ $(this).removeClass('disabled'); // osvetlimo
+ $(this).attr('disabled', false); // enejblamo
+ });
+ }
+
+}
+
+function checkBranchingDate() {
+ checkBranching();
+}
+
+
+// preklop statistike pri glasovanjih - razvrscanje po spolu
+function stat_spol (spremenljivka, spol){
+ $('#spremenljivka_statistika').load('../main/survey/ajax.php?a=spol', {spremenljivka: spremenljivka, spol: spol, anketa: srv_meta_anketa_id});
+}
+
+
+function getBodyHeight() {
+ var height;
+ var scrollHeight;
+ var offsetHeight;
+
+ if (document.height) {
+ height = document.height;
+ } else if (document.body) {
+ if (document.body.scrollHeight) {
+ height = scrollHeight = document.body.scrollHeight;
+ }
+ if (document.body.offsetHeight) {
+ height = offsetHeight = document.body.offsetHeight;
+ }
+ if (scrollHeight && offsetHeight) {
+ height = Math.max(scrollHeight, offsetHeight);
+ }
+ }
+ return height;
+}
+
+function slide_timer_pause_ON() {
+ is_paused_slideshow = true;
+ $("#btn_pause_on").hide();
+ $("#btn_pause_off").show();
+}
+function slide_timer_pause_OFF() {
+ is_paused_slideshow = false;
+ $("#btn_pause_off").hide();
+ $("#btn_pause_on").show();
+
+}
+
+
+// Premik vrstice pri dinamicnih multigridih
+function rowSlide(spremenljivka, row, next) {
+
+ // Dobimo stevilo vrstic
+ var count = $('#dynamic_multigrid_'+spremenljivka).val();
+
+ // Dobimo trenutno prikazanega
+ var current = 0;
+ for(var i=1; i<=count; i++){
+ if($('.'+spremenljivka+'_gridRow_'+i).is(':visible')){
+ current = i;
+ break;
+ }
+ }
+
+ // preverimo ce lahko preklopimo na naslednjo (zaradi ifov)
+ if( $('.'+spremenljivka+'_gridRow_'+next).hasClass('if_hide') ){
+
+ // Ce premikamo naprej poiscemo do konca
+ if( parseInt(next) > parseInt(row) ){
+ for(var i=parseInt(next); i<=count; i++){
+ if( !$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide') ){
+ next = i;
+ break;
+ }
+ else if(i == count){
+ next = undefined;
+ }
+ }
+ }
+ // Ce premikamo nazaj poiscemo do zacetka
+ else{
+ for(var i=parseInt(next); i>0; i--){
+ if( !$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide') ){
+ next = i;
+ break;
+ }
+ else if(i == 1){
+ next = undefined;
+ }
+ }
+ }
+ }
+
+ if(next != undefined){
+
+ // Nastavimo containerju height - drugace pri fade-out skoci na vrh
+ var height = $('#spremenljivka_'+spremenljivka).height();
+ //$('#spremenljivka_'+spremenljivka).height(height); // Ugasnjeno, ker drugace ohrani staro visino in lahko pride pri slidu do prekrivanja na dnu
+
+ $('.'+spremenljivka+'_gridRow_'+row).fadeOut("medium", function() {$('.'+spremenljivka+'_gridRow_'+next).fadeIn("medium");});
+
+ if($('.'+spremenljivka+'_gridRowArrows_'+row).length > 0)
+ $('.'+spremenljivka+'_gridRowArrows_'+row).fadeOut("medium", function() {$('.'+spremenljivka+'_gridRowArrows_'+next).fadeIn("medium");});
+
+ current = next;
+ }
+
+ // Popravimo puscice in counter
+ //dynamicMultigridFixArrows(current, count, spremenljivka);
+ dynamicMultigridFixAllArrows(spremenljivka);
+
+ // Popravimo da vemo da smo ze prej premikali
+ $('#dynamic_multigrid_'+spremenljivka+'_load').val('0');
+}
+
+// Prikaz/skrivanje vrstic v dinamicnih multigridih zaradi if-ov
+function dynamicMultigridSwitchIf(show, id, spremenljivka){
+
+ var row = $('#vrednost_if_'+id).attr('seq');
+
+ // Dobimo stevilo vrstic
+ var count = $('#dynamic_multigrid_'+spremenljivka).val();
+
+ // Dobimo trenutno prikazanega
+ var current = 0;
+ for(var i=1; i<=count; i++){
+ if($('.'+spremenljivka+'_gridRow_'+i).is(':visible')){
+ current = i;
+ break;
+ }
+ }
+
+ // Prikazemo vrstico v dinamicnem mg zaradi ifa
+ if(show == 1){
+ $('#vrednost_if_'+id).removeClass('if_hide');
+
+ // Ce ni noben element viden prikazemo vklopljenega
+ if(current == 0){
+ $('.'+spremenljivka+'_gridRow_'+row).show();
+
+ if($('.'+spremenljivka+'_gridRowArrows_'+row).length > 0)
+ $('.'+spremenljivka+'_gridRowArrows_'+row).show();
+
+ current = row;
+ }
+ // Ce je viden kasnejsi kot trenuten ki bi moral biti prikazan (ker je prvi v ifu, drugi pa ne), premaknemo nazaj (samo ce gre za novo nalaganje strani - ce gre za rowSlide pa ne)
+ else if(current > row && $('#dynamic_multigrid_'+spremenljivka+'_load').val() == '1'){
+ rowSlide(spremenljivka, current, row);
+ }
+ }
+
+ // Skrijemo vrstico v dinamicnem mg zaradi ifa
+ else{
+ $('#vrednost_if_'+id).addClass('if_hide');
+
+ // Ce smo izklopili trenutno prikazanega
+ if(row == current){
+
+ for(var i=1; i<=count; i++){
+ if( !$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide') ){
+ next = i;
+ break;
+ }
+ else if(i == count){
+ next = undefined;
+ }
+ }
+
+ // Preklopimo na prvega ki ga lahko prikazemo
+ if(next != undefined){
+ $('.'+spremenljivka+'_gridRow_'+row).fadeOut("medium", function() {$('.'+spremenljivka+'_gridRow_'+next).fadeIn("medium");});
+
+ if($('.'+spremenljivka+'_gridRowArrows_'+row).length > 0)
+ $('.'+spremenljivka+'_gridRowArrows_'+row).fadeOut("medium", function() {$('.'+spremenljivka+'_gridRowArrows_'+next).fadeIn("medium");});
+
+ current = next;
+ }
+ // Ce smo izklopili prikazanega in so vsi ostali skriti
+ else{
+ $('.'+spremenljivka+'_gridRow_'+row).fadeOut("medium");
+
+ if($('.'+spremenljivka+'_gridRowArrows_'+row).length > 0)
+ $('.'+spremenljivka+'_gridRowArrows_'+row).fadeOut("medium");
+ }
+ }
+ }
+
+ // Popravimo puscice in counter
+ //dynamicMultigridFixArrows(current, count, spremenljivka);
+ dynamicMultigridFixAllArrows(spremenljivka);
+}
+
+function dynamicMultigridFixArrows(current, count, spremenljivka){
+
+ // Preverimo ce imamo elemente pred in za, ki jih ne skrivamo z if-i in jih prestejemo
+ var show_back = false;
+ var show_forward = false;
+ var count_valid = 0;
+ var count_before = 1;
+ for(var i=1; i<=count; i++){
+
+ if(!$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide') && i<current){
+ show_back = true;
+ count_before++;
+ }
+ else if(!$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide') && i>current)
+ show_forward = true;
+
+ if(!$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide'))
+ count_valid++;
+ }
+
+
+ if($('.'+spremenljivka+'_gridRowArrows_'+current).length > 0){
+
+ // Popravimo puscico nazaj
+ if(show_back)
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_back').show();
+ else
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_back').hide();
+
+ // Popravimo puscico naprej
+ if(show_forward)
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_forward').show();
+ else
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_forward').hide();
+
+ // Popravimo counter
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('#dynamic_count').html(count_before + ' / ' + count_valid);
+ }
+ else{
+ // Popravimo puscico nazaj
+ if(show_back)
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_back').show();
+ else
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_back').hide();
+
+ // Popravimo puscico naprej
+ if(show_forward)
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_forward').show();
+ else
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_forward').hide();
+
+ // Popravimo counter
+ $('.'+spremenljivka+'_gridRow_'+current).find('#dynamic_count').html(count_before + ' / ' + count_valid);
+ }
+}
+
+// Gremo cez vse bloke in vsakemu popravimo paginacijo in puscice
+function dynamicMultigridFixAllArrows(spremenljivka){
+
+ // Dobimo stevilo vrstic
+ var count = $('#dynamic_multigrid_'+spremenljivka).val();
+
+ $('.'+spremenljivka+'_gridRow').each(function(){
+
+ var current = $(this).attr('seq');
+
+ // Preverimo ce imamo elemente pred in za, ki jih ne skrivamo z if-i in jih prestejemo
+ var show_back = false;
+ var show_forward = false;
+ var count_valid = 0;
+ var count_before = 1;
+ var visible_sequences = new Array();
+ for(var i=1; i<=count; i++){
+
+ if(!$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide') && i<current){
+ show_back = true;
+ count_before++;
+ }
+ else if(!$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide') && i>current)
+ show_forward = true;
+
+ if(!$('.'+spremenljivka+'_gridRow_'+i).hasClass('if_hide')){
+ visible_sequences[i] = true;
+ count_valid++;
+ }
+ else{
+ visible_sequences[i] = false;
+ }
+ }
+
+ // Pri paginaciji skrijemo stevilke, ki so skrite zaradi if-a in prestevilcimo
+ var cnt = 1;
+ for (i=1; i<visible_sequences.length+1; i++){
+
+ if(visible_sequences[i] == false){
+ $(this).find('.sequence_number_' + i).hide();
+ }
+ else{
+ $(this).find('.sequence_number_' + i).show();
+ $(this).find('.sequence_number_' + i).html(cnt);
+ cnt++;
+ }
+ }
+
+
+ if($('.'+spremenljivka+'_gridRowArrows_'+current).length > 0){
+
+ // Popravimo puscico nazaj
+ if(show_back)
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_back').show();
+ else
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_back').hide();
+
+ // Popravimo puscico naprej
+ if(show_forward)
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_forward').show();
+ else
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('.arrow_forward').hide();
+
+ // Popravimo counter
+ $('.'+spremenljivka+'_gridRowArrows_'+current).find('#dynamic_count').html(count_before + ' / ' + count_valid);
+ }
+ else{
+ // Popravimo puscico nazaj
+ if(show_back)
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_back').show();
+ else
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_back').hide();
+
+ // Popravimo puscico naprej
+ if(show_forward)
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_forward').show();
+ else
+ $('.'+spremenljivka+'_gridRow_'+current).find('.arrow_forward').hide();
+
+ // Popravimo counter
+ $('.'+spremenljivka+'_gridRow_'+current).find('#dynamic_count').html(count_before + ' / ' + count_valid);
+ }
+ });
+}
+
+
+// Razpiranje mobilnih tabel
+function mobileMultigridExpandable(){
+
+ // Pri kliku na naslov podvprasanja razpremo/zapremo podvprasanje
+ $(".grid_mobile_title").click(function(){
+
+ // Double gridi imajo zaenkrat to izklopljeno
+ if(!$(this).parent().parent().hasClass("double")){
+
+ // Dobimo pripadajoc div z vsemi vrednostmi
+ $(this).parent().find(".grid_mobile_variables").toggle("fast", function(){
+ mobileMultigridExpandableArrow(this);
+ });
+ }
+ });
+
+ // Posebna obravnava radio tabel (avtomatsko razpiranje in pomikanje)
+ mobileMultigridExpandableRadio();
+}
+// Razpiranje mobilnih tabel pri radio tabelah
+function mobileMultigridExpandableRadio(){
+
+ // Na zacetku skrijemo vedno vse razen prvega
+ $(".grid_mobile.radio:not(.double)").find("div.grid_mobile_variables:not(:first)").hide(function(){
+ mobileMultigridExpandableArrow(this);
+ });
+
+ // Obrnemo puscico za razpiranje
+ $(".grid_mobile.radio:not(.double)").find("div.grid_mobile_variables:not(:first)").parent().find(".mobile_expanding_arrow").toggleClass("arrow_down").toggleClass("arrow_up");
+
+ // Pokazemo div z rezultatom
+ $(".grid_mobile.radio:not(.double)").find("div.grid_mobile_variables:not(:first)").parent().find(".grid_mobile_result").show();
+
+ // Pri kliku na radio zapremo in razpremo naslednji segment
+ $("input[type=\"radio\"]").click(function(){
+
+ // Ce gre za radio znotraj tabele
+ if($(this).closest(".grid_mobile_variables").length > 0 && !$(this).closest(".grid_mobile_variables").parent().parent().hasClass("double")){
+
+ var podvprasanje_current = $(this).closest(".grid_mobile_variables");
+ var podvprasanje_next = $(podvprasanje_current).parent().next().find(".grid_mobile_variables");
+
+ // Zapremo trenutno podvprasanje
+ $(podvprasanje_current).hide("fast", function(){
+ mobileMultigridExpandableArrow(this);
+ });
+
+ // Razpremo naslednje vprasanje ce obstaja
+ $(podvprasanje_next).show("fast", function(){
+ mobileMultigridExpandableArrow(this);
+ });
+
+ // Zascrollamo do naslednjega podvprasanja
+ $("html, body").animate({
+ scrollTop: $(podvprasanje_current).offset().top
+ }, 300, "swing");
+ }
+ });
+}
+// Razpiranje mobilnih tabel - zamenjava puscice
+function mobileMultigridExpandableArrow(el){
+
+ var arrow = $(el).parent().find(".mobile_expanding_arrow");
+ $(arrow).toggleClass("arrow_down").toggleClass("arrow_up");
+
+ mobileMultigridExpandableData(arrow);
+}
+// Prikazemo/skrijemo text odgovora pod naslovom
+function mobileMultigridExpandableData(arrow){
+
+ var result = $(arrow).parent().parent().find(".grid_mobile_result");
+
+ // Dobimo text oznacenega radia in ga zapisemo v result div
+ var text = $(arrow).parent().parent().find("input[type=radio]:checked").parent().parent().find(".grid_mobile_variable_title").text();
+ $(result).text(text);
+
+ // Glede na puscico prikazemo oz. skrijemo result div
+ if($(arrow).hasClass("arrow_down")){
+ $(result).show('fast');
+ }
+ else{
+ $(result).hide('fast');
+ }
+
+}
+
+// Razpiranje vprasanj v bloku - init
+function questionsExpandable(){
+
+ // Skrijemo vsebino vseh vprasanj razen prvega
+ $('.expendable_block .variable_holder:not(:visible:first)').hide();
+
+ // Dodamo pointer in puscico na naslov vprasanj
+ $('.expendable_block .naslov').addClass('pointer');
+ $('.expendable_block .naslov:not(:visible:first)').append('<span class="faicon arrow_down question_expanding_arrow"></span>');
+ $('.expendable_block .naslov:visible:first').append('<span class="faicon arrow_up question_expanding_arrow"></span>');
+
+ // Dodamo se padding na text da ne prekriva puscice
+ $('.expendable_block .naslov p').css("padding-right", "35px");
+
+
+ // Loop cez vse v bloku in zapisemo rezultat v naslov ce je izbran (zaenkrat samo radio)
+ $('.expendable_block').each(function() {
+ questionExpandableData(this);
+ });
+
+
+ // Klik na naslov - podvprasanje razpremo/zapremo
+ $('.expendable_block .naslov').click(function(){
+
+ var spremenljivka = $(this).closest('.spremenljivka');
+ questionExpandableToggle(spremenljivka);
+ });
+
+
+ // Pri kliku na radio gremo na naslednje
+ $(".expendable_block input[type=radio]").click(function(){
+
+ var spremenljivka = $(this).closest('.spremenljivka');
+ var spremenljivka_next = $(spremenljivka).nextAll(":visible").first().find(".variable_holder:hidden:first").closest('.spremenljivka');
+
+ if($(spremenljivka).hasClass("tip_1") && $(spremenljivka).hasClass("expendable_block")){
+
+ // Zapremo trenutnega
+ questionExpandableToggle(spremenljivka);
+
+ // Odpremo naslednjega
+ questionExpandableToggle(spremenljivka_next);
+
+ // Zascrollamo do naslednjega vprasanja
+ $("html, body").animate({
+ scrollTop: $(spremenljivka).find('.variable_holder').offset().top
+ }, 300, "swing");
+ }
+ });
+
+ // Pri bluru text vprasanja gremo na naslednje
+ $(".expendable_block input[type=text]").blur(function(){
+
+ var spremenljivka = $(this).closest('.spremenljivka');
+ var spremenljivka_next = $(spremenljivka).nextAll(":visible").first().find(".variable_holder:hidden:first").closest('.spremenljivka');
+
+ if($(spremenljivka).hasClass("tip_21") && $(spremenljivka).hasClass("expendable_block")){
+
+ // Zapremo trenutnega
+ questionExpandableToggle(spremenljivka);
+
+ // Odpremo naslednjega
+ questionExpandableToggle(spremenljivka_next);
+
+ // Zascrollamo do naslednjega vprasanja
+ $("html, body").animate({
+ scrollTop: $(spremenljivka).find('.variable_holder').offset().top
+ }, 300, "swing");
+ }
+ });
+}
+// Razpiranje vprašanj v bloku - razpiranje/zapiranje posameznega vprasanja
+function questionExpandableToggle(spremenljivka){
+
+ // Vprasanje razpremo / zapremo
+ $(spremenljivka).find('.variable_holder').slideToggle(function(){
+
+ // Obrnemo puscico
+ $(spremenljivka).find('.question_expanding_arrow').toggleClass("arrow_up arrow_down");
+
+ // Po potrebi prikazemo/skrijemo rezultat v naslovu
+ questionExpandableData(spremenljivka);
+ });
+}
+// Prikazemo/skrijemo text odgovora pod naslovom
+function questionExpandableData(spremenljivka){
+
+ // Text prikazujemo samo za radio tip, ki ima kaksno vrednost oznaceno
+ if($(spremenljivka).hasClass('tip_1') && $(spremenljivka).find(".variabla.checked").length){
+
+ // Ce je vprasanje zaprto prikazemo text
+ if($(spremenljivka).find(".variable_holder").is(':hidden')){
+
+ // Extractamo samo text vrednosti (brez radio gumba)
+ var label = $(spremenljivka).find(".variabla.checked label").clone();
+ $(label).find('input').remove();
+ $(label).find('.enka-checkbox-radio').remove();
+
+ var result = $(label).text();
+
+ // Dodamo text v naslov
+ $(spremenljivka).find('.naslov').append('<p class="expendable_block_result" style="display:none;">' + result + '</p>');
+ $(spremenljivka).find('.expendable_block_result').show('fast');
+ }
+ // Ce je vprasanje zaprto skrijemo text
+ else{
+ $(spremenljivka).find('.expendable_block_result').hide('fast', function(){
+ $(spremenljivka).find('.expendable_block_result').remove();
+ });
+ }
+ }
+}
+
+
+function continue_later (site_url, lang_id) {
+
+ if ( $('#continue_later').length ) {
+
+ $('#continue_later').remove();
+
+ } else {
+ $.post(site_url+'main/survey/ajax.php?a=continue_later&language='+lang_id, {anketa: srv_meta_anketa_id, url: window.location.href}, function (data) {
+
+ $('#continue_later').remove();
+ $('#container h1').after( data );
+
+ });
+ }
+}
+
+function continue_later_send (site_url, lang_id) {
+
+ url = $('#url').val();
+ email = $('#email').val();
+
+ $.post(site_url+'main/survey/ajax.php?a=continue_later_send&language='+lang_id, {anketa: srv_meta_anketa_id, url:url, email:email}, function (data) {
+
+ $('#continue_later').remove();
+
+ });
+
+}
+
+function preview_popup_close () {
+
+ $('#preview-holder, #preview_switch').fadeOut('medium');
+
+ $('#preview-window').addClass('closed');
+
+ $('.preview_icon_open').show();
+ $('.preview_icon_close').hide();
+
+ localStorage.preview_popup = 1;
+}
+
+function preview_popup_open () {
+
+ $('#preview-holder, #preview_switch').fadeIn('medium');
+
+ $('#preview-window').removeClass('closed');
+
+ $('.preview_icon_open').hide();
+ $('.preview_icon_close').show();
+
+ localStorage.preview_popup = 0;
+}
+
+function inicialke () {
+
+ $('form[name=vnos]').append('<input type="hidden" name="inicialke" value="">');
+
+ if (localStorage.inicialke) {
+ $('#inicialke').val(localStorage.inicialke);
+ $('form[name=vnos] input[name=inicialke]').val(localStorage.inicialke);
+ }
+
+ $('#inicialke').bind('keyup', function (e) {
+ localStorage.inicialke = e.target.value;
+ $('form[name=vnos] input[name=inicialke]').val(localStorage.inicialke);
+ });
+
+}
+
+/**
+ *preveri, ce so vpisane inicialke
+ */
+function check_inicialke () {
+
+ if ( $('#inicialke').val() != '' ) {
+ return true;
+ }
+
+ var _return = true;
+ $('div.question_comment textarea').each(function (key, elm) {
+ if ( $(elm).val() != '' ) {
+ _return = false;
+ }
+ });
+
+ return _return;
+}
+
+function init_comments_save () {
+
+ var comments = {};
+ if (localStorage.comments) comments = JSON.parse( localStorage.comments );
+
+ return function () {
+ for (id in comments) {
+ $('textarea#'+id).val( comments[id] );
+ }
+
+ // ko vpisemo besedilo ga shranimo
+ $('textarea[id^=question_comment]').bind('change', function (e) {
+ comments[ $(e.target).attr('id') ] = $(e.target).val();
+ localStorage.comments = JSON.stringify(comments);
+ });
+
+ // ob submitanju forma (in shranjevanju v bazo) pobrisemo iz storaga
+ $('form[name=vnos]').submit(function () {
+ $('textarea[id^=question_comment]').each(function () {
+ delete comments[ $(this).attr('id') ];
+ localStorage.comments = JSON.stringify(comments);
+ });
+ });
+
+ }();
+}
+
+// respondent se strinja z uporabo piskotkov
+function cookie_ok () {
+
+ $.post(srv_site_url+'main/survey/ajax.php?a=cookie_ok', {anketa: srv_meta_anketa_id}, function (data) {
+ window.location.reload();
+ });
+
+ return false;
+}
+
+function cookie_check() {
+
+ if ( $('#cookie_alert').css('display') == 'block' ) {
+ alert(lang['srv_cookie_continue_alert']);
+ return false;
+ }
+
+ $('#container form').submit();
+}
+
+function privacy_check() {
+
+ if ( $('#privacy_box').length ) {
+ if ( ! $('#privacy_box:checked').length ) {
+ $('#privacy_box').parent().addClass('required');
+ return false;
+ }
+ }
+
+ $('#container form').submit();
+}
+
+// max vrstni_red spremenljivke do katere smo prisli, da vemo zaradi validacije
+var max_vrstni_red = 0;
+$(function () {
+ $('.spremenljivka').on('click', function (e) {
+
+ //Uros dodal if - pri gogle maps ce se infowindow (nad markerjem) zapre (klikne na X), vrne spodnji if false
+ if($(e.target).closest('.spremenljivka')[0]){
+ var vrstni_red = parseInt( $(e.target).closest('.spremenljivka')[0].getAttribute('data-vrstni_red') );
+ if (vrstni_red > max_vrstni_red)
+ max_vrstni_red = vrstni_red;
+ }
+ });
+});
+
+function activateCehckboxImages($what) {
+ // zloopamo skozi vse odgovore in če vsebujejo sliko in imajo izbran checkbox naredimo okvir okoli slike
+ $what.closest('div.variable_holder').find('div.variabla label:has(img):has(input:checkbox)').each(function(index) {
+ $cb = $(this).find('input:checkbox');
+ $img = $(this).find('img');
+ if ($cb.is(':checked')) {
+ $img.addClass('imageselected');
+ } else {
+ $img.removeClass('imageselected');
+ }
+ });
+ // zloopamo skozi vse odgovore in če vsebujejo sliko in imajo izbran radio naredimo okvir okoli slike
+ $what.closest('div.variable_holder').find('div.variabla label:has(img):has(input:radio)').each(function(index) {
+ $rd= $(this).find('input:radio');
+ $img = $(this).find('img');
+ if ($rd.is(':checked')) {
+ $img.addClass('imageselected');
+ } else {
+ $img.removeClass('imageselected');
+ }
+ });
+}
+
+//omeji izbire v Select box le na eno moznost
+function omejiSelectBox(spremenljivka){
+
+ //console.log('Sem v funkciji omejiSelectBox');
+
+ var elem_now; //belezi id trenutne izbire
+ var elem_before; //belezi id prejsnje izbire
+ var klik = 0; //belezi, ali je bil select že poklikan
+
+ //$('#vrednost_<?=$spremenljivka?> option:selected').each(function(){
+ $('#vrednost_'+spremenljivka+' option:selected').each(function(){
+ elem_now = $(this);
+ if (!klik){
+ elem_before = elem_now.val();
+ klik = 1;
+ }
+
+ var count = $('#vrednost_'+spremenljivka+' option:selected').length; //koliko izbir je izbranih
+ //console.log('Izbranih je: '+count);
+
+ if(elem_now.val() == elem_before){ //ce sta id trenutne in prejsnje izbire enaka
+ //console.log("Ista izbira kot prej!");
+ //elem_now.prop("selected", true);
+ }else{ //ce id trenutne in prejsnje izbire sta enaka
+ //console.log("Sta različna!");
+ if(count > 1){ //ce je vec izbir izbranih
+ elem_now.prop('selected', false); //odstrani izbiro na trenutno izbrani izbiri
+ }
+ elem_before = elem_now.val(); //prejsnja izbira je trenutna
+ }
+ });
+ //});
+}
+
+//omeji izbire v Select box le na eno moznost pri Multigrid
+function omejiSelectBoxMulti(spremenljivka, id){
+
+ //console.log('Sem v funkciji omejiSelectBox');
+
+ var elem_now; //belezi id trenutne izbire
+ var elem_before; //belezi id prejsnje izbire
+ var klik = 0; //belezi, ali je bil select že poklikan
+
+ //$('#vrednost_<?=$spremenljivka?> option:selected').each(function(){
+ $('#vrednost_'+spremenljivka+'_'+id+' option:selected').each(function(){
+ elem_now = $(this);
+ if (!klik){
+ elem_before = elem_now.val();
+ klik = 1;
+ }
+
+ var count = $('#vrednost_'+spremenljivka+'_'+id+' option:selected').length; //koliko izbir je izbranih
+ //console.log('Izbranih je: '+count);
+
+ if(elem_now.val() == elem_before){ //ce sta id trenutne in prejsnje izbire enaka
+ //console.log("Ista izbira kot prej!");
+ //elem_now.prop("selected", true);
+ }else{ //ce id trenutne in prejsnje izbire sta enaka
+ //console.log("Sta različna!");
+ if(count > 1){ //ce je vec izbir izbranih
+ elem_now.prop('selected', false); //odstrani izbiro na trenutno izbrani izbiri
+ }
+ elem_before = elem_now.val(); //prejsnja izbira je trenutna
+ }
+ });
+ //});
+
+}
+
+//ob kliku na isto izbiro v select box se izbira odstrani kot pri radiobuttonih
+var elem_now = []; //belezi id trenutne izbire v select box
+var elem_before = []; //belezi id prejsnje izbire v select box
+var klik = []; //belezi, ali je bil select box že poklikan
+
+function clickSelectBox(spremenljivka, limit){
+ var count = $('#vrednost_'+spremenljivka+' option:selected').length; //koliko izbir je izbranih
+ var allOptions = [];
+ var selectedOptions = [];
+ /* console.log("count: "+count);*/
+ //console.log("limit: "+limit);
+
+ $('#vrednost_'+spremenljivka+' option:selected').each(function(){
+ elem_now[spremenljivka] = $(this);
+ selectedOptions.push(elem_now[spremenljivka].val()); //v polje dodaj izbrano moznost
+ //console.log('Trenutno izbran: '+elem_now[spremenljivka].val()+'');
+ //console.log('Klik: '+klik[spremenljivka]+'');
+ if ((!klik[spremenljivka] && (elem_before[spremenljivka] != elem_now[spremenljivka].val())) ||(!klik[spremenljivka] && (elem_before[spremenljivka] == elem_now[spremenljivka].val()))){
+ elem_before[spremenljivka] = elem_now[spremenljivka].val();
+ klik[spremenljivka] = 1;
+ }
+ else if(klik[spremenljivka] && (elem_before[spremenljivka] != elem_now[spremenljivka].val())){
+ elem_before[spremenljivka] = elem_now[spremenljivka].val();
+ }
+ else if(count == 1 && klik[spremenljivka] && (elem_before[spremenljivka] == elem_now[spremenljivka].val())){
+ //console.log('Sta enaka');
+ elem_now[spremenljivka].prop('selected', false);
+ klik[spremenljivka] = 0;
+ }
+ });
+
+
+ //if(count > limit){ //ce je stevilo izbranih moznosti vecje od limita
+ if(count>=limit && limit!=0){ //ce je stevilo izbranih moznosti vecje od limita
+ //zabelezi vse moznosti
+ $('#vrednost_'+spremenljivka+' option').each(function(){
+ allOptions.push($(this).val()); //v polje dodaj moznost
+ });
+
+ for(var i=0;i<count;i++){
+ for(var j=0;j<allOptions.length;j++){
+ if(allOptions[j] == selectedOptions[i]){ //ce med vsemi moznostmi je trenutna moznost enaka eni od izbranih moznosti
+ allOptions.splice(j,1); //odstrani moznost iz polja
+ }
+ }
+ }
+
+ for(var i=0;i<allOptions.length;i++){
+ //console.log("Spucane moznosti: "+allOptions[i]); //pokazi vse moznost
+ $('#vrednost_if_'+allOptions[i]).prop("disabled", true); //disable ne izbrane moznosti
+ }
+ allOptions = [];
+ }else{ //ce stevilo izbranih moznosti ni vecje od limita
+ //zabelezi vse moznosti
+ $('#vrednost_'+spremenljivka+' option').each(function(){
+ allOptions.push($(this).val()); //v polje dodaj moznost
+ });
+ for(var i=0;i<allOptions.length;i++){
+ $('#vrednost_if_'+allOptions[i]).prop("disabled", false); //disable ne izbrane moznosti
+ }
+ }
+}
+
+//ob kliku na isto izbiro v select box, kjer je več možnih odgovorov, se izbira odstrani kot pri radiobuttonih
+function clickSelectBoxMulti(spremenljivka, id){
+ var spremenljivka_id = spremenljivka+id;
+ var count = $('#vrednost_'+spremenljivka+'_'+id+' option:selected').length; //koliko izbir je izbranih
+ $('#vrednost_'+spremenljivka+'_'+id+' option:selected').each(function(){
+ elem_now[spremenljivka_id] = $(this);
+ //console.log('Trenutno izbran: '+elem_now[spremenljivka_id].val()+'');
+ //console.log('Klik: '+klik[spremenljivka_id]+'');
+ if ((!klik[spremenljivka_id] && (elem_before[spremenljivka_id] != elem_now[spremenljivka_id].val())) ||(!klik[spremenljivka_id] && (elem_before[spremenljivka_id] == elem_now[spremenljivka_id].val()))){
+ elem_before[spremenljivka_id] = elem_now[spremenljivka_id].val();
+ klik[spremenljivka_id] = 1;
+ //console.log('Prvi if');
+ }
+ else if(klik[spremenljivka_id] && (elem_before[spremenljivka_id] != elem_now[spremenljivka_id].val())){
+ elem_before[spremenljivka_id] = elem_now[spremenljivka_id].val();
+ //console.log('Drugi if');
+ }
+ else if(count == 1 && klik[spremenljivka_id] && (elem_before[spremenljivka_id] == elem_now[spremenljivka_id].val())){
+ //console.log('Sta enaka');
+ elem_now[spremenljivka_id].prop('selected', false);
+ klik[spremenljivka_id] = 0;
+ }
+ });
+}
+
+//ob kliku na isto izbiro v select box v kombinirani tabeli se izbira odstrani kot pri radiobuttonih
+function clickSelectBoxMultiCombo(spremenljivka, id, grid){
+ var spremenljivka_id = spremenljivka+id+grid;
+ var count = $('#multi_'+spremenljivka+'_'+id+'_grid_'+grid+' option:selected').length; //koliko izbir je izbranih
+ $('#multi_'+spremenljivka+'_'+id+'_grid_'+grid+' option:selected').each(function(){
+ elem_now[spremenljivka_id] = $(this);
+ //console.log('Trenutno izbran: '+elem_now[spremenljivka_id].val()+'');
+ // console.log('Klik: '+klik[spremenljivka_id]+'');
+ if ((!klik[spremenljivka_id] && (elem_before[spremenljivka_id] != elem_now[spremenljivka_id].val())) ||(!klik[spremenljivka_id] && (elem_before[spremenljivka_id] == elem_now[spremenljivka_id].val()))){
+ elem_before[spremenljivka_id] = elem_now[spremenljivka_id].val();
+ klik[spremenljivka_id] = 1;
+ }
+ else if(klik[spremenljivka_id] && (elem_before[spremenljivka_id] != elem_now[spremenljivka_id].val())){
+ elem_before[spremenljivka_id] = elem_now[spremenljivka_id].val();
+ }
+ else if(count == 1 && klik[spremenljivka_id] && (elem_before[spremenljivka_id] == elem_now[spremenljivka_id].val())){
+ //console.log('Sta enaka');
+ elem_now[spremenljivka_id].prop('selected', false);
+ klik[spremenljivka_id] = 0;
+ }
+ });
+}
+
+// Popravimo crte med vprasanji ce imamo blok s horizontalnim izrisom vprasanj
+function blockHorizontalLine(spr_id){
+
+ $('.spremenljivka.horizontal_block').each(function() {
+ if(!$(this).prev().hasClass('horizontal_block') && !$(this).prev().hasClass('lineOnly') && !$(this).prev().hasClass('tip_5')){
+ $(this).before('<div class="spremenljivka lineOnly"></div>');
+ }
+ if(!$(this).next().hasClass('horizontal_block') && !$(this).next().hasClass('clr') && !$(this).next().hasClass('tip_5')){
+ $(this).after('<div class="clr"></div>');
+ }
+ });
+}
+
+
+var randomization_inside_block = {};
+function blockRandomizeQuestions(parent_block_id, order, usr_id, spr_count){
+
+ // Dobimo array z random vrstnim redom (seedan z usr_id)
+ var question_ids = JSON.parse(order);
+
+ // Preverimo ce smo ze izvedli randomizacijo
+ if(randomization_inside_block[parent_block_id] != true){
+
+ // Najprej wrappamo vsa vprasanja v en div da ga lahko na koncu pobrisemo
+ $('.spremenljivka.block_child_' + parent_block_id).wrapAll("<div id='block_id_" + parent_block_id + "'></div>");
+
+ var new_content = '';
+ var counter = 0;
+ question_ids.forEach(function(el){
+
+ // Stejemo da prikazemo samo omejeno stevilo vprasanj (ce imamo vklopljeno nastavitev)
+ if(counter < spr_count){
+ // Ce element ne obstaja na strani zakljucimo funkcijo
+ if(!$('#spremenljivka_' + el).length)
+ return;
+
+ // Dodamo blok v novo vsebino
+ new_content += $('#spremenljivka_' + el)[0].outerHTML;
+
+ counter++;
+ }
+ });
+
+ // Pripnemo novo vsebino in pobrisemo staro
+ $("#block_id_" + parent_block_id).after(new_content);
+ $("#block_id_" + parent_block_id).remove();
+
+ // Zabelezimo da smo izvedli randomizacijo za blok
+ randomization_inside_block[parent_block_id] = true;
+
+ // Porezemo elemente, ce imamo omejeno stevilo vprasanj
+ question_ids = question_ids.slice(0, spr_count);
+ var order_limited = JSON.stringify(question_ids);
+
+ // Shranimo vrstni red v bazo
+ $.post(srv_site_url+'main/survey/ajax.php?a=save_randomization_order', {anketa: srv_meta_anketa_id, parent_block_id: parent_block_id, order: order_limited, randomization_type: 'spremenljivke', usr_id: usr_id});
+ }
+}
+function blockRandomizeBlocks(parent_block_id, order, usr_id){
+
+ // Dobimo array z random vrstnim redom (seedan z usr_id)
+ var blocks_ids = JSON.parse(order);
+
+ // Preverimo ce smo ze izvedli randomizacijo
+ if(randomization_inside_block[parent_block_id] != true){
+
+ // Najprej wrapamo vprasanja v en div
+ var new_content = '';
+ blocks_ids.forEach(function(el){
+
+ // Ce element ne obstaja na strani zakljucimo funkcijo
+ if(!$('.spremenljivka.block_child_' + el).length)
+ return;
+
+ // Wrapamo vsa vprasanja znotraj posameznega notranjega bloka
+ $('.spremenljivka.block_child_' + el).wrapAll( "<div id='block_id_" + el + "' class='block block_child_" + parent_block_id + "'></div>");
+
+ // Dodamo blok v novo vsebino
+ new_content += $('#block_id_' + el).html();
+ });
+
+ // Wrappamo bloke v parent blok
+ $('.block.block_child_' + parent_block_id).wrapAll("<div id='block_id_" + parent_block_id + "'></div>");
+
+ // Pripnemo novo vsebino in pobrisemo staro
+ $("#block_id_" + parent_block_id).after(new_content);
+ $("#block_id_" + parent_block_id).remove();
+
+ // Zabelezimo da smo izvedli randomizacijo za blok
+ randomization_inside_block[parent_block_id] = true;
+
+ // Shranimo vrstni red v bazo
+ $.post(srv_site_url+'main/survey/ajax.php?a=save_randomization_order', {anketa: srv_meta_anketa_id, parent_block_id: parent_block_id, order: order, randomization_type: 'bloki', usr_id: usr_id});
+ }
+}
+
+//************************ trak @ diferencial
+var elem_now_trak = []; //belezi id trenutne izbire v select box
+var elem_before_trak = []; //belezi id prejsnje izbire v select box
+var klik_trak = []; //belezi, ali je bil select box že poklikan
+
+//funkcija za oznacevanje izbranega odgovora na traku
+function trak_change_bg(this_s, diferencial_trak, spremenljivka, missing){
+ if (diferencial_trak){ //ce je trak vklopljen
+ //console.log(this_s.id);
+
+ if (missing == 0){ //ce ni missing radio button
+ var children = $(this_s).find('input[type=radio]').attr('id'); //id kliknjenega radio button-a
+ var vre_id = $(this_s).find('input[type=radio]').attr('vre_id'); //id kliknjenega radio button-a
+
+ setCheckedClass($('#'+children)[0], null, vre_id);
+ }else{
+ var children = this_s.id;
+ var vre_id = $('#'+children).attr('vre_id');
+ }
+
+ //console.log($('#'+children).val());
+
+ elem_now_trak[spremenljivka] = children;
+
+ $('#vrednost_if_'+vre_id).children().removeClass('trak_container_bg'); //odstrani barvo ozadja za oznacen odgovor
+
+ $('#'+children).attr('checked','checked'); //oznaci ustrezni radio button
+
+ var trak = "trak_tbl_" + vre_id + "_" + $('#'+children).val();
+
+ if ( !klik_trak[spremenljivka] && (elem_now_trak[spremenljivka] != elem_before_trak[spremenljivka]) ){
+ $('#'+trak).addClass('trak_container_bg'); //preuredi ozadje z želeno barvo
+ klik_trak[spremenljivka] = 1;
+ }else if ( klik_trak[spremenljivka] && (elem_now_trak[spremenljivka] != elem_before_trak[spremenljivka]) ){
+ $('#'+trak).addClass('trak_container_bg'); //preuredi ozadje z želeno barvo
+ }else if ( klik_trak[spremenljivka] && (elem_now_trak[spremenljivka] == elem_before_trak[spremenljivka]) ){
+ $('#variabla_'+vre_id).children().removeClass('trak_container_bg'); //odstrani barvo ozadja za oznacen odgovor
+ klik_trak[spremenljivka] = 0;
+ $('#'+children).attr('checked', false); //odstrani oznacitev ustreznega radio button
+ }else if ( !klik_trak[spremenljivka] && (elem_now_trak[spremenljivka] == elem_before_trak[spremenljivka]) ){
+ $('#'+trak).addClass('trak_container_bg'); //preuredi ozadje z želeno barvo
+ klik_trak[spremenljivka] = 1;
+ }
+ elem_before_trak[spremenljivka] = elem_now_trak[spremenljivka];
+ }
+}
+
+//globalni spremenljivki za elektronski podpis
+var podpisposlan = [];
+var optionsPodpis = [];
+
+
+// klik na "vec" pri text vprasanju in nastavitvi prikaz prejsnjih odgovorov
+function show_prevAnswers_all (spremenljivka) {
+
+ $('#text_prevAnswers_popup_' + spremenljivka).load(srv_site_url+'main/survey/ajax.php?a=show_prevAnswers_all', {spremenljivka: spremenljivka, anketa: srv_meta_anketa_id}, function(){
+ $('#fade').fadeTo('fast', 0.5, function(){
+ $('#text_prevAnswers_popup_' + spremenljivka).fadeIn("fast");
+ });
+ });
+}
+
+function hide_prevAnswers_all(spremenljivka){
+
+ $('#fade').fadeOut();
+ $('#text_prevAnswers_popup_' + spremenljivka).hide();
+}
+
+// gdpr popup "podrobnosti zbiranja podatkov"
+function show_gdpr_about(lang_id) {
+
+ $('#popup').addClass('gdpr_about');
+
+ $('#popup').load(srv_site_url+'main/survey/ajax.php?a=show_gdpr_about&language='+lang_id, {anketa: srv_meta_anketa_id}, function(){
+ $('#fade').fadeTo('fast', 0.5, function(){
+ $('#popup').fadeIn("fast");
+ });
+ });
+}
+
+function hide_gdpr_about(){
+
+ $('#fade').fadeOut();
+ $('#popup').hide();
+
+ $('#popup').removeClass('gdpr_about');
+}
+
+/**
+ * Show notification, that respondent has reached maximum number of chars
+ * @param {type} input - input or textarea
+ * @param {type} sid - id of question
+ * @returns {undefined}
+ */
+function handleMaxTextParam(input, sid){
+ if (input.value.length != input.maxLength)
+ $('#max_text_notification_'+sid).hide();
+ else
+ $('#max_text_notification_'+sid).show();
+}
+
+/**
+ * Refresh char counter of field
+ * @param {type} field - an element to count chars from
+ * @returns {undefined}
+ */
+function charCounter(field){
+ document.getElementById(field.id+'_counter').innerHTML = field.value.length;
+}
+
+/**
+ * Refresh char counter of field
+ * @param {type} field_id - id of filed to count chars from
+ * @returns {undefined}
+ */
+function set_charCounter(field_id){
+ document.getElementById(field_id+'_counter').innerHTML = document.getElementById(field_id).value.length;
+}
+
+
+// Preverjanje in ustrezno disablanje/enablanje polj v dropdownu pri tipu razvrscanje (ostevilcevanje)
+function rankingSelect(value, spremenljivka, counter){
+
+ $("#spremenljivka_" + spremenljivka + "_ranking_cifre_" + counter).val(value);
+
+ rankingSelectCheck(spremenljivka);
+}
+// Preverimo vse ranking dropdowne znotraj vprasanja in jih ustrezno omogocimo/onemogocimo
+function rankingSelectCheck(spremenljivka){
+ var select_values = [];
+
+ // Loop selecte in preberemo vrednosti
+ $("#spremenljivka_"+spremenljivka).find(".ranking_select").each(function(i, obj) {
+
+ select_values[i] = $(obj).val();
+ $(obj).children().attr("disabled", false);
+ });
+
+ // Loop cez vse selecte in disable vrednost
+ $("#spremenljivka_"+spremenljivka).find(".ranking_select").each(function(i, obj) {
+
+ $(select_values).each(function(j, select_value) {
+ if(j != i && select_value != ""){
+ $(obj).children("option[value=" + select_value + "]").attr("disabled", true);
+ }
+ });
+ });
+}
+// Preverimo vse ranking dropdowne znotraj vseh vprasanj in jih ustrezno omogocimo/onemogocimo (na loadu strani)
+function rankingSelectCheckAll(){
+ var select_values = [];
+
+ // Loop cez vsa ranking vprasanja na strani
+ $(".spremenljivka.tip_17").each(function(i, vprasanje) {
+
+ // Loop selecte in preberemo vrednosti
+ $(vprasanje).find(".ranking_select").each(function(i, obj) {
+
+ select_values[i] = $(obj).val();
+ $(obj).children().attr("disabled", false);
+ });
+
+ // Loop cez vse selecte in disable vrednost
+ $(vprasanje).find(".ranking_select").each(function(i, obj) {
+
+ $(select_values).each(function(j, select_value) {
+ if(j != i && select_value != ""){
+ $(obj).children("option[value=" + select_value + "]").attr("disabled", true);
+ }
+ });
+ });
+ });
+}
+
+// Preverjanje in ustrezno disablanje/enablanje polj v dropdownu pri tipu razvrscanje (ostevilcevanje) - SAZU modul
+function sazuSelect(value, spremenljivka, counter){
+ $("#spremenljivka_" + spremenljivka + "_ranking_cifre_" + counter).val(value);
+
+ sazuSelectCheck();
+}
+function sazuSelectCheck(){
+ var select_values = [];
+
+ // Loop selecte in preberemo vrednosti
+ $(".sazu_select").each(function(i, obj) {
+ select_values[i] = $(obj).val();
+ $(obj).children().attr("disabled", false);
+ });
+
+ // Loop cez vse selecte in disable vrednost
+ $(".sazu_select").each(function(i, obj) {
+
+ $(select_values).each(function(j, select_value) {
+ if(j != i && select_value != ""){
+ $(obj).children("option[value=" + select_value + "]").attr("disabled", true);
+ }
+ });
+ });
+}
+
+
+// Ponovimo naslovno vrstico tabele, ce je omogocena nastavitev
+function gridRepeatHeader(repeat_every, spr_id){
+
+ var table = $("#spremenljivka_" + spr_id + " table.grid_table");
+
+ // Ce ima vrstica class za ponavljanje
+ if($(table).find('tr.repeat_header').length){
+
+ var table_header = $(table).find('tr.repeat_header')[0].outerHTML;
+
+ // Za tabelo najprej pobrisemo vse ponovljene vrstice ce so ze prisotne
+ $(table).find('tbody tr.repeat_header').remove();
+
+ // Loopamo cez vidne vrstice in vstavimo header vsakih "repeat_every" vrstic
+ $(table).find("tbody tr:visible").each(function(index) {
+
+ // Insetamo naslovno vrstico na pravo mesto
+ if((index+1) % repeat_every == 0){
+ $(this).after(table_header);
+ }
+ });
+ }
+}
+
+
+// Preverimo upload file omejitve
+function checkUpload(upload, id){
+
+ // Max file size (mb)
+ let maxSize = 16;
+
+ // Get file size
+ let fileSize = Math.round(( upload.files[0].size / 1024 / 1024 ));
+
+ // File is too large
+ if(fileSize > maxSize){
+ $(upload).val(null);
+ alert(lang["srv_alert_upload_size"]);
+
+ return;
+ }
+
+
+ // File extensions allowed
+ let extAllowed = ["jpeg", "jpg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx"];
+
+ // Get file ext
+ let fileNameFull = upload.files[0].name;
+ let lastDot = fileNameFull.lastIndexOf('.');
+
+ let fileName = fileNameFull.substring(0, lastDot);
+ let fileExt = fileNameFull.substring(lastDot + 1).toLowerCase();
+
+ // Wrong file extension
+ if(!extAllowed.includes(fileExt)){
+ $(upload).val(null);
+ alert(lang["srv_alert_upload_ext"]);
+
+ return;
+ }
+
+
+ // Add/remove "remove file" button
+ $('#remove_file_' + id).show();
+}
+
+function removeUpload(id){
+ $('#' + id).val(null);
+}
+
+
+// Disablamo vse inpute in jim dodamo input hidden, da se posta odgovor
+function disableSubsequentAnswers(){
+
+ // Disable radio and checkbox
+ $('input[type="radio"], input[type="checkbox"]').each(function() {
+
+ if($(this).prop("checked") == true){
+ var name = $(this).attr("name");
+ var value = $(this).val();
+
+ $(this).before("<input type=\"hidden\" name=\""+name+"\" value=\""+value+"\">");
+ }
+
+ $(this).prop("disabled", "true");
+ });
+
+ // Disable radio and checkbox
+ $('input[type="text"], textarea, input[type="password"], input[type="email"]').each(function() {
+
+ var name = $(this).attr("name");
+ var value = $(this).val();
+
+ $(this).before("<input type=\"hidden\" name=\""+name+"\" value=\""+value+"\">");
+
+ $(this).prop("disabled", "true");
+ });
+
+}
diff --git a/main/survey/js/signature/LICENSE.txt b/main/survey/js/signature/LICENSE.txt
new file mode 100644
index 0000000..f0c14ea
--- /dev/null
+++ b/main/survey/js/signature/LICENSE.txt
@@ -0,0 +1,27 @@
+Copyright (c) 2014, Thomas J Bradley
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ - Neither the name of Thomas J Bradley nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/main/survey/js/signature/flashcanvas.js b/main/survey/js/signature/flashcanvas.js
new file mode 100644
index 0000000..e7b6ddf
--- /dev/null
+++ b/main/survey/js/signature/flashcanvas.js
@@ -0,0 +1,28 @@
+/*
+ * FlashCanvas
+ *
+ * Copyright (c) 2009 Tim Cameron Ryan
+ * Copyright (c) 2009-2011 FlashCanvas Project
+ * Released under the MIT/X License
+ */
+window.ActiveXObject&&!window.CanvasRenderingContext2D&&function(h,j){function D(a){this.code=a;this.message=T[a]}function U(a){this.width=a}function E(a){this.id=a.C++}function t(a){this.G=a;this.id=a.C++}function u(a,b){this.canvas=a;this.B=b;this.d=a.uniqueID;this.D();this.C=0;this.t="";var c=this;setInterval(function(){n[c.d]===0&&c.e()},30)}function A(){if(j.readyState==="complete"){j.detachEvent(F,A);for(var a=j.getElementsByTagName(r),b=0,c=a.length;b<c;++b)B.initElement(a[b])}}function G(){var a=
+event.srcElement,b=a.parentNode;a.blur();b.focus()}function H(){var a=event.propertyName;if(a==="width"||a==="height"){var b=event.srcElement,c=b[a],d=parseInt(c,10);if(isNaN(d)||d<0)d=a==="width"?300:150;if(c===d){b.style[a]=d+"px";b.getContext("2d").I(b.width,b.height)}else b[a]=d}}function I(){h.detachEvent(J,I);for(var a in s){var b=s[a],c=b.firstChild,d;for(d in c)if(typeof c[d]==="function")c[d]=k;for(d in b)if(typeof b[d]==="function")b[d]=k;c.detachEvent(K,G);b.detachEvent(L,H)}h[M]=k;h[N]=
+k;h[O]=k;h[C]=k;h[P]=k}function V(){var a=j.getElementsByTagName("script");a=a[a.length-1];return j.documentMode>=8?a.src:a.getAttribute("src",4)}function v(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;")}function W(a){return a.toLowerCase()}function i(a){throw new D(a);}function Q(a){var b=parseInt(a.width,10),c=parseInt(a.height,10);if(isNaN(b)||b<0)b=300;if(isNaN(c)||c<0)c=150;a.width=b;a.height=c}var k=null,r="canvas",M="CanvasRenderingContext2D",N="CanvasGradient",O="CanvasPattern",
+C="FlashCanvas",P="G_vmlCanvasManager",K="onfocus",L="onpropertychange",F="onreadystatechange",J="onunload",w=((h[C+"Options"]||{}).swfPath||V().replace(/[^\/]+$/,""))+"flashcanvas.swf",e=new function(a){for(var b=0,c=a.length;b<c;b++)this[a[b]]=b}(["toDataURL","save","restore","scale","rotate","translate","transform","setTransform","globalAlpha","globalCompositeOperation","strokeStyle","fillStyle","createLinearGradient","createRadialGradient","createPattern","lineWidth","lineCap","lineJoin","miterLimit",
+"shadowOffsetX","shadowOffsetY","shadowBlur","shadowColor","clearRect","fillRect","strokeRect","beginPath","closePath","moveTo","lineTo","quadraticCurveTo","bezierCurveTo","arcTo","rect","arc","fill","stroke","clip","isPointInPath","font","textAlign","textBaseline","fillText","strokeText","measureText","drawImage","createImageData","getImageData","putImageData","addColorStop","direction","resize"]),x={},n={},s={},y={};u.prototype={save:function(){this.b();this.c();this.m();this.l();this.z();this.w();
+this.F.push([this.f,this.g,this.A,this.u,this.j,this.h,this.i,this.k,this.p,this.q,this.n,this.o,this.v,this.r,this.s]);this.a.push(e.save)},restore:function(){var a=this.F;if(a.length){a=a.pop();this.globalAlpha=a[0];this.globalCompositeOperation=a[1];this.strokeStyle=a[2];this.fillStyle=a[3];this.lineWidth=a[4];this.lineCap=a[5];this.lineJoin=a[6];this.miterLimit=a[7];this.shadowOffsetX=a[8];this.shadowOffsetY=a[9];this.shadowBlur=a[10];this.shadowColor=a[11];this.font=a[12];this.textAlign=a[13];
+this.textBaseline=a[14]}this.a.push(e.restore)},scale:function(a,b){this.a.push(e.scale,a,b)},rotate:function(a){this.a.push(e.rotate,a)},translate:function(a,b){this.a.push(e.translate,a,b)},transform:function(a,b,c,d,f,g){this.a.push(e.transform,a,b,c,d,f,g)},setTransform:function(a,b,c,d,f,g){this.a.push(e.setTransform,a,b,c,d,f,g)},b:function(){var a=this.a;if(this.f!==this.globalAlpha){this.f=this.globalAlpha;a.push(e.globalAlpha,this.f)}if(this.g!==this.globalCompositeOperation){this.g=this.globalCompositeOperation;
+a.push(e.globalCompositeOperation,this.g)}},m:function(){if(this.A!==this.strokeStyle){var a=this.A=this.strokeStyle;this.a.push(e.strokeStyle,typeof a==="object"?a.id:a)}},l:function(){if(this.u!==this.fillStyle){var a=this.u=this.fillStyle;this.a.push(e.fillStyle,typeof a==="object"?a.id:a)}},createLinearGradient:function(a,b,c,d){isFinite(a)&&isFinite(b)&&isFinite(c)&&isFinite(d)||i(9);this.a.push(e.createLinearGradient,a,b,c,d);return new t(this)},createRadialGradient:function(a,b,c,d,f,g){isFinite(a)&&
+isFinite(b)&&isFinite(c)&&isFinite(d)&&isFinite(f)&&isFinite(g)||i(9);if(c<0||g<0)i(1);this.a.push(e.createRadialGradient,a,b,c,d,f,g);return new t(this)},createPattern:function(a,b){a||i(17);var c=a.tagName,d,f=this.d;if(c){c=c.toLowerCase();if(c==="img")d=a.getAttribute("src",2);else if(c===r||c==="video")return;else i(17)}else if(a.src)d=a.src;else i(17);b==="repeat"||b==="no-repeat"||b==="repeat-x"||b==="repeat-y"||b===""||b===k||i(12);this.a.push(e.createPattern,v(d),b);if(x[f]){this.e();++n[f]}return new E(this)},
+z:function(){var a=this.a;if(this.j!==this.lineWidth){this.j=this.lineWidth;a.push(e.lineWidth,this.j)}if(this.h!==this.lineCap){this.h=this.lineCap;a.push(e.lineCap,this.h)}if(this.i!==this.lineJoin){this.i=this.lineJoin;a.push(e.lineJoin,this.i)}if(this.k!==this.miterLimit){this.k=this.miterLimit;a.push(e.miterLimit,this.k)}},c:function(){var a=this.a;if(this.p!==this.shadowOffsetX){this.p=this.shadowOffsetX;a.push(e.shadowOffsetX,this.p)}if(this.q!==this.shadowOffsetY){this.q=this.shadowOffsetY;
+a.push(e.shadowOffsetY,this.q)}if(this.n!==this.shadowBlur){this.n=this.shadowBlur;a.push(e.shadowBlur,this.n)}if(this.o!==this.shadowColor){this.o=this.shadowColor;a.push(e.shadowColor,this.o)}},clearRect:function(a,b,c,d){this.a.push(e.clearRect,a,b,c,d)},fillRect:function(a,b,c,d){this.b();this.c();this.l();this.a.push(e.fillRect,a,b,c,d)},strokeRect:function(a,b,c,d){this.b();this.c();this.m();this.z();this.a.push(e.strokeRect,a,b,c,d)},beginPath:function(){this.a.push(e.beginPath)},closePath:function(){this.a.push(e.closePath)},
+moveTo:function(a,b){this.a.push(e.moveTo,a,b)},lineTo:function(a,b){this.a.push(e.lineTo,a,b)},quadraticCurveTo:function(a,b,c,d){this.a.push(e.quadraticCurveTo,a,b,c,d)},bezierCurveTo:function(a,b,c,d,f,g){this.a.push(e.bezierCurveTo,a,b,c,d,f,g)},arcTo:function(a,b,c,d,f){f<0&&isFinite(f)&&i(1);this.a.push(e.arcTo,a,b,c,d,f)},rect:function(a,b,c,d){this.a.push(e.rect,a,b,c,d)},arc:function(a,b,c,d,f,g){c<0&&isFinite(c)&&i(1);this.a.push(e.arc,a,b,c,d,f,g?1:0)},fill:function(){this.b();this.c();
+this.l();this.a.push(e.fill)},stroke:function(){this.b();this.c();this.m();this.z();this.a.push(e.stroke)},clip:function(){this.a.push(e.clip)},w:function(){var a=this.a;if(this.v!==this.font)try{var b=y[this.d];b.style.font=this.v=this.font;var c=b.currentStyle;a.push(e.font,[c.fontStyle,c.fontWeight,b.offsetHeight,c.fontFamily].join(" "))}catch(d){}if(this.r!==this.textAlign){this.r=this.textAlign;a.push(e.textAlign,this.r)}if(this.s!==this.textBaseline){this.s=this.textBaseline;a.push(e.textBaseline,
+this.s)}if(this.t!==this.canvas.currentStyle.direction){this.t=this.canvas.currentStyle.direction;a.push(e.direction,this.t)}},fillText:function(a,b,c,d){this.b();this.l();this.c();this.w();this.a.push(e.fillText,v(a),b,c,d===void 0?Infinity:d)},strokeText:function(a,b,c,d){this.b();this.m();this.c();this.w();this.a.push(e.strokeText,v(a),b,c,d===void 0?Infinity:d)},measureText:function(a){var b=y[this.d];try{b.style.font=this.font}catch(c){}b.innerText=a.replace(/[ \n\f\r]/g,"\t");return new U(b.offsetWidth)},
+drawImage:function(a,b,c,d,f,g,o,l,z){a||i(17);var p=a.tagName,m,q=arguments.length,R=this.d;if(p){p=p.toLowerCase();if(p==="img")m=a.getAttribute("src",2);else if(p===r||p==="video")return;else i(17)}else if(a.src)m=a.src;else i(17);this.b();this.c();m=v(m);if(q===3)this.a.push(e.drawImage,q,m,b,c);else if(q===5)this.a.push(e.drawImage,q,m,b,c,d,f);else if(q===9){if(d===0||f===0)i(1);this.a.push(e.drawImage,q,m,b,c,d,f,g,o,l,z)}else return;if(x[R]){this.e();++n[R]}},D:function(){this.globalAlpha=
+this.f=1;this.globalCompositeOperation=this.g="source-over";this.fillStyle=this.u=this.strokeStyle=this.A="#000000";this.lineWidth=this.j=1;this.lineCap=this.h="butt";this.lineJoin=this.i="miter";this.miterLimit=this.k=10;this.shadowBlur=this.n=this.shadowOffsetY=this.q=this.shadowOffsetX=this.p=0;this.shadowColor=this.o="rgba(0, 0, 0, 0.0)";this.font=this.v="10px sans-serif";this.textAlign=this.r="start";this.textBaseline=this.s="alphabetic";this.a=[];this.F=[]},H:function(){var a=this.a;this.a=
+[];return a},e:function(){var a=this.H();if(a.length>0)return eval(this.B.CallFunction('<invoke name="executeCommand" returntype="javascript"><arguments><string>'+a.join("&#0;")+"</string></arguments></invoke>"))},I:function(a,b){this.e();this.D();if(a>0)this.B.width=a;if(b>0)this.B.height=b;this.a.push(e.resize,a,b)}};t.prototype={addColorStop:function(a,b){if(isNaN(a)||a<0||a>1)i(1);this.G.a.push(e.addColorStop,this.id,a,b)}};D.prototype=Error();var T={1:"INDEX_SIZE_ERR",9:"NOT_SUPPORTED_ERR",11:"INVALID_STATE_ERR",
+12:"SYNTAX_ERR",17:"TYPE_MISMATCH_ERR",18:"SECURITY_ERR"},B={initElement:function(a){if(a.getContext)return a;var b=a.uniqueID,c="external"+b;x[b]=false;n[b]=1;Q(a);a.innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+location.protocol+'//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="'+c+'"><param name="allowScriptAccess" value="always"><param name="flashvars" value="id='+c+'"><param name="wmode" value="transparent"></object><span style="margin:0;padding:0;border:0;display:inline-block;position:static;height:1em;overflow:visible;white-space:nowrap"></span>';
+s[b]=a;var d=a.firstChild;y[b]=a.lastChild;var f=j.body.contains;if(f(a))d.movie=w;else var g=setInterval(function(){if(f(a)){clearInterval(g);d.movie=w}},0);if(j.compatMode==="BackCompat"||!h.XMLHttpRequest)y[b].style.overflow="hidden";var o=new u(a,d);a.getContext=function(l){return l==="2d"?o:k};a.toDataURL=function(l,z){(""+l).replace(/[A-Z]+/g,W)==="image/jpeg"?o.a.push(e.toDataURL,l,typeof z==="number"?z:""):o.a.push(e.toDataURL,l);return o.e()};d.attachEvent(K,G);return a},saveImage:function(a){a.firstChild.saveImage()},
+setOptions:function(){},trigger:function(a,b){s[a].fireEvent("on"+b)},unlock:function(a,b){n[a]&&--n[a];if(b){var c=s[a],d=c.firstChild,f,g;Q(c);f=c.width;g=c.height;c.style.width=f+"px";c.style.height=g+"px";if(f>0)d.width=f;if(g>0)d.height=g;d.resize(f,g);c.attachEvent(L,H);x[a]=true}}};j.createElement(r);j.createStyleSheet().cssText=r+"{display:inline-block;overflow:hidden;width:300px;height:150px}";j.readyState==="complete"?A():j.attachEvent(F,A);h.attachEvent(J,I);if(w.indexOf(location.protocol+
+"//"+location.host+"/")===0){var S=new ActiveXObject("Microsoft.XMLHTTP");S.open("GET",w,false);S.send(k)}h[M]=u;h[N]=t;h[O]=E;h[C]=B;h[P]={init:function(){},init_:function(){},initElement:B.initElement};keep=u.measureText}(window,document);
diff --git a/main/survey/js/signature/flashcanvas.swf b/main/survey/js/signature/flashcanvas.swf
new file mode 100644
index 0000000..66ff213
--- /dev/null
+++ b/main/survey/js/signature/flashcanvas.swf
Binary files differ
diff --git a/main/survey/js/signature/jquery.signaturepad.js b/main/survey/js/signature/jquery.signaturepad.js
new file mode 100644
index 0000000..bcef407
--- /dev/null
+++ b/main/survey/js/signature/jquery.signaturepad.js
@@ -0,0 +1,895 @@
+/**
+ * Usage for accepting signatures:
+ * $('.sigPad').signaturePad()
+ *
+ * Usage for displaying previous signatures:
+ * $('.sigPad').signaturePad({displayOnly:true}).regenerate(sig)
+ * or
+ * var api = $('.sigPad').signaturePad({displayOnly:true})
+ * api.regenerate(sig)
+ */
+(function ($) {
+
+function SignaturePad (selector, options) {
+ /**
+ * Reference to the object for use in public methods
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ var self = this
+
+ /**
+ * Holds the merged default settings and user passed settings
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ , settings = $.extend({}, $.fn.signaturePad.defaults, options)
+
+ /**
+ * The current context, as passed by jQuery, of selected items
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ , context = $(selector)
+
+ /**
+ * jQuery reference to the canvas element inside the signature pad
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ , canvas = $(settings.canvas, context)
+
+ /**
+ * Dom reference to the canvas element inside the signature pad
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ , element = canvas.get(0)
+
+ /**
+ * The drawing context for the signature canvas
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ , canvasContext = null
+
+ /**
+ * Holds the previous point of drawing
+ * Disallows drawing over the same location to make lines more delicate
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ , previous = {'x': null, 'y': null}
+
+ /**
+ * An array holding all the points and lines to generate the signature
+ * Each item is an object like:
+ * {
+ * mx: moveTo x coordinate
+ * my: moveTo y coordinate
+ * lx: lineTo x coordinate
+ * lx: lineTo y coordinate
+ * }
+ *
+ * @private
+ *
+ * @type {Array}
+ */
+ , output = []
+
+ /**
+ * Stores a timeout for when the mouse leaves the canvas
+ * If the mouse has left the canvas for a specific amount of time
+ * Stops drawing on the canvas
+ *
+ * @private
+ *
+ * @type {Object}
+ */
+ , mouseLeaveTimeout = false
+
+ /**
+ * Whether the mouse button is currently pressed down or not
+ *
+ * @private
+ *
+ * @type {Boolean}
+ */
+ , mouseButtonDown = false
+
+ /**
+ * Whether the browser is a touch event browser or not
+ *
+ * @private
+ *
+ * @type {Boolean}
+ */
+ , touchable = false
+
+ /**
+ * Whether events have already been bound to the canvas or not
+ *
+ * @private
+ *
+ * @type {Boolean}
+ */
+ , eventsBound = false
+
+ /**
+ * Remembers the default font-size when typing, and will allow it to be scaled for bigger/smaller names
+ *
+ * @private
+ *
+ * @type {Number}
+ */
+ , typeItDefaultFontSize = 30
+
+ /**
+ * Remembers the current font-size when typing
+ *
+ * @private
+ *
+ * @type {Number}
+ */
+ , typeItCurrentFontSize = typeItDefaultFontSize
+
+ /**
+ * Remembers how many characters are in the name field, to help with the scaling feature
+ *
+ * @private
+ *
+ * @type {Number}
+ */
+ , typeItNumChars = 0
+
+
+ /**
+ * Clears the mouseLeaveTimeout
+ * Resets some other variables that may be active
+ *
+ * @private
+ */
+ function clearMouseLeaveTimeout () {
+ clearTimeout(mouseLeaveTimeout)
+ mouseLeaveTimeout = false
+ mouseButtonDown = false
+ }
+
+ /**
+ * Draws a line on canvas using the mouse position
+ * Checks previous position to not draw over top of previous drawing
+ * (makes the line really thick and poorly anti-aliased)
+ *
+ * @private
+ *
+ * @param {Object} e The event object
+ * @param {Number} newYOffset A pixel value for drawing the newY, used for drawing a single dot on click
+ */
+ function drawLine (e, newYOffset) {
+ var offset, newX, newY
+
+ e.preventDefault()
+
+ offset = $(e.target).offset()
+
+ clearTimeout(mouseLeaveTimeout)
+ mouseLeaveTimeout = false
+
+ if (typeof e.targetTouches !== 'undefined') {
+ newX = Math.floor(e.targetTouches[0].pageX - offset.left)
+ newY = Math.floor(e.targetTouches[0].pageY - offset.top)
+ } else {
+ newX = Math.floor(e.pageX - offset.left)
+ newY = Math.floor(e.pageY - offset.top)
+ }
+
+ if (previous.x === newX && previous.y === newY)
+ return true
+
+ if (previous.x === null)
+ previous.x = newX
+
+ if (previous.y === null)
+ previous.y = newY
+
+ if (newYOffset)
+ newY += newYOffset
+
+ canvasContext.beginPath()
+ canvasContext.moveTo(previous.x, previous.y)
+ canvasContext.lineTo(newX, newY)
+ canvasContext.lineCap = settings.penCap
+ canvasContext.stroke()
+ canvasContext.closePath()
+
+ output.push({
+ 'lx' : newX
+ , 'ly' : newY
+ , 'mx' : previous.x
+ , 'my' : previous.y
+ })
+
+ previous.x = newX
+ previous.y = newY
+
+ if (settings.onDraw && typeof settings.onDraw === 'function')
+ settings.onDraw.apply(self)
+ }
+
+ /**
+ * Callback wrapper for executing stopDrawing without the event
+ * Put up here so that it can be removed at a later time
+ *
+ * @private
+ */
+ function stopDrawingWrapper () {
+ stopDrawing()
+ }
+
+ /**
+ * Callback registered to mouse/touch events of the canvas
+ * Stops the drawing abilities
+ *
+ * @private
+ *
+ * @param {Object} e The event object
+ */
+ function stopDrawing (e) {
+ if (!!e) {
+ drawLine(e, 1)
+ } else {
+ if (touchable) {
+ canvas.each(function () {
+ this.removeEventListener('touchmove', drawLine)
+ // this.removeEventListener('MSPointerMove', drawLine)
+ })
+ } else {
+ canvas.unbind('mousemove.signaturepad')
+ }
+
+ if (output.length > 0 && settings.onDrawEnd && typeof settings.onDrawEnd === 'function')
+ settings.onDrawEnd.apply(self)
+ }
+
+ previous.x = null
+ previous.y = null
+
+ if (settings.output && output.length > 0)
+ $(settings.output, context).val(JSON.stringify(output))
+ }
+
+ /**
+ * Draws the signature line
+ *
+ * @private
+ */
+ function drawSigLine () {
+ if (!settings.lineWidth)
+ return false
+
+ canvasContext.beginPath()
+ canvasContext.lineWidth = settings.lineWidth
+ canvasContext.strokeStyle = settings.lineColour
+ canvasContext.moveTo(settings.lineMargin, settings.lineTop)
+ canvasContext.lineTo(element.width - settings.lineMargin, settings.lineTop)
+ //canvasContext.moveTo(50, 250)
+ //canvasContext.moveTo(50, 140)
+ //canvasContext.lineTo(element.width - 50, 250)
+ //canvasContext.lineTo(element.width - 50, 140)
+ canvasContext.stroke()
+ canvasContext.closePath()
+ }
+
+ /**
+ * Clears all drawings off the canvas and redraws the signature line
+ *
+ * @private
+ */
+ function clearCanvas () {
+ canvasContext.clearRect(0, 0, element.width, element.height)
+ canvasContext.fillStyle = settings.bgColour
+ canvasContext.fillRect(0, 0, element.width, element.height)
+
+ if (!settings.displayOnly)
+ //drawSigLine()
+
+ canvasContext.lineWidth = settings.penWidth
+ canvasContext.strokeStyle = settings.penColour
+
+ $(settings.output, context).val('')
+ output = []
+
+ stopDrawing()
+ }
+
+ /**
+ * Callback registered to mouse/touch events of the canvas
+ * Draws a line at the mouse cursor location, starting a new line if necessary
+ *
+ * @private
+ *
+ * @param {Object} e The event object
+ * @param {Object} o The object context registered to the event; canvas
+ */
+ function onMouseMove(e, o) {
+ if (previous.x == null) {
+ drawLine(e, 1)
+ } else {
+ drawLine(e, o)
+ }
+ }
+
+ /**
+ * Callback registered to mouse/touch events of canvas
+ * Triggers the drawLine function
+ *
+ * @private
+ *
+ * @param {Object} e The event object
+ * @param {Object} touchObject The object context registered to the event; canvas
+ */
+ function startDrawing (e, touchObject) {
+ if (touchable) {
+ touchObject.addEventListener('touchmove', onMouseMove, false)
+ // touchObject.addEventListener('MSPointerMove', onMouseMove, false)
+ } else {
+ canvas.bind('mousemove.signaturepad', onMouseMove)
+ }
+
+ // Draws a single point on initial mouse down, for people with periods in their name
+ drawLine(e, 1)
+ }
+
+ /**
+ * Removes all the mouse events from the canvas
+ *
+ * @private
+ */
+ function disableCanvas () {
+ eventsBound = false
+
+ canvas.each(function () {
+ if (this.removeEventListener) {
+ this.removeEventListener('touchend', stopDrawingWrapper)
+ this.removeEventListener('touchcancel', stopDrawingWrapper)
+ this.removeEventListener('touchmove', drawLine)
+ // this.removeEventListener('MSPointerUp', stopDrawingWrapper)
+ // this.removeEventListener('MSPointerCancel', stopDrawingWrapper)
+ // this.removeEventListener('MSPointerMove', drawLine)
+ }
+
+ if (this.ontouchstart)
+ this.ontouchstart = null;
+ })
+
+ $(document).unbind('mouseup.signaturepad')
+ canvas.unbind('mousedown.signaturepad')
+ canvas.unbind('mousemove.signaturepad')
+ canvas.unbind('mouseleave.signaturepad')
+
+ $(settings.clear, context).unbind('click.signaturepad')
+ }
+
+ /**
+ * Lazy touch event detection
+ * Uses the first press on the canvas to detect either touch or mouse reliably
+ * Will then bind other events as needed
+ *
+ * @private
+ *
+ * @param {Object} e The event object
+ */
+ function initDrawEvents (e) {
+ if (eventsBound)
+ return false
+
+ eventsBound = true
+
+ // Closes open keyboards to free up space
+ $('input').blur();
+
+ if (typeof e.targetTouches !== 'undefined')
+ touchable = true
+
+ if (touchable) {
+ canvas.each(function () {
+ this.addEventListener('touchend', stopDrawingWrapper, false)
+ this.addEventListener('touchcancel', stopDrawingWrapper, false)
+ // this.addEventListener('MSPointerUp', stopDrawingWrapper, false)
+ // this.addEventListener('MSPointerCancel', stopDrawingWrapper, false)
+ })
+
+ canvas.unbind('mousedown.signaturepad')
+ } else {
+ $(document).bind('mouseup.signaturepad', function () {
+ if (mouseButtonDown) {
+ stopDrawing()
+ clearMouseLeaveTimeout()
+ }
+ })
+ canvas.bind('mouseleave.signaturepad', function (e) {
+ if (mouseButtonDown) stopDrawing(e)
+
+ if (mouseButtonDown && !mouseLeaveTimeout) {
+ mouseLeaveTimeout = setTimeout(function () {
+ stopDrawing()
+ clearMouseLeaveTimeout()
+ }, 500)
+ }
+ })
+
+ canvas.each(function () {
+ this.ontouchstart = null
+ })
+ }
+ }
+
+ /**
+ * Triggers the abilities to draw on the canvas
+ * Sets up mouse/touch events, hides and shows descriptions and sets current classes
+ *
+ * @private
+ */
+ function drawIt () {
+ $(settings.typed, context).hide()
+ clearCanvas()
+
+ canvas.each(function () {
+ this.ontouchstart = function (e) {
+ e.preventDefault()
+ mouseButtonDown = true
+ initDrawEvents(e)
+ startDrawing(e, this)
+ }
+ })
+
+ canvas.bind('mousedown.signaturepad', function (e) {
+ e.preventDefault()
+
+ // Only allow left mouse clicks to trigger signature drawing
+ if (e.which > 1) return false
+
+ mouseButtonDown = true
+ initDrawEvents(e)
+ startDrawing(e)
+ })
+
+ $(settings.clear, context).bind('click.signaturepad', function (e) { e.preventDefault(); clearCanvas() })
+
+ $(settings.typeIt, context).bind('click.signaturepad', function (e) { e.preventDefault(); typeIt() })
+ $(settings.drawIt, context).unbind('click.signaturepad')
+ $(settings.drawIt, context).bind('click.signaturepad', function (e) { e.preventDefault() })
+
+ $(settings.typeIt, context).removeClass(settings.currentClass)
+ $(settings.drawIt, context).addClass(settings.currentClass)
+ $(settings.sig, context).addClass(settings.currentClass)
+
+ $(settings.typeItDesc, context).hide()
+ $(settings.drawItDesc, context).show()
+ $(settings.clear, context).show()
+ }
+
+ /**
+ * Triggers the abilities to type in the input for generating a signature
+ * Sets up mouse events, hides and shows descriptions and sets current classes
+ *
+ * @private
+ */
+ function typeIt () {
+ clearCanvas()
+ disableCanvas()
+ $(settings.typed, context).show()
+
+ $(settings.drawIt, context).bind('click.signaturepad', function (e) { e.preventDefault(); drawIt() })
+ $(settings.typeIt, context).unbind('click.signaturepad')
+ $(settings.typeIt, context).bind('click.signaturepad', function (e) { e.preventDefault() })
+
+ $(settings.output, context).val('')
+
+ $(settings.drawIt, context).removeClass(settings.currentClass)
+ $(settings.typeIt, context).addClass(settings.currentClass)
+ $(settings.sig, context).removeClass(settings.currentClass)
+
+ $(settings.drawItDesc, context).hide()
+ $(settings.clear, context).hide()
+ $(settings.typeItDesc, context).show()
+
+ typeItCurrentFontSize = typeItDefaultFontSize = $(settings.typed, context).css('font-size').replace(/px/, '')
+ }
+
+ /**
+ * Callback registered on key up and blur events for input field
+ * Writes the text fields value as Html into an element
+ *
+ * @private
+ *
+ * @param {String} val The value of the input field
+ */
+ function type (val) {
+ var typed = $(settings.typed, context)
+ , cleanedVal = $.trim(val.replace(/>/g, '&gt;').replace(/</g, '&lt;'))
+ , oldLength = typeItNumChars
+ , edgeOffset = typeItCurrentFontSize * 0.5
+
+ typeItNumChars = cleanedVal.length
+ typed.html(cleanedVal)
+
+ if (!cleanedVal) {
+ typed.css('font-size', typeItDefaultFontSize + 'px')
+ return
+ }
+
+ if (typeItNumChars > oldLength && typed.outerWidth() > element.width) {
+ while (typed.outerWidth() > element.width) {
+ typeItCurrentFontSize--
+ typed.css('font-size', typeItCurrentFontSize + 'px')
+ }
+ }
+
+ if (typeItNumChars < oldLength && typed.outerWidth() + edgeOffset < element.width && typeItCurrentFontSize < typeItDefaultFontSize) {
+ while (typed.outerWidth() + edgeOffset < element.width && typeItCurrentFontSize < typeItDefaultFontSize) {
+ typeItCurrentFontSize++
+ typed.css('font-size', typeItCurrentFontSize + 'px')
+ }
+ }
+ }
+
+ /**
+ * Default onBeforeValidate function to clear errors
+ *
+ * @private
+ *
+ * @param {Object} context current context object
+ * @param {Object} settings provided settings
+ */
+ function onBeforeValidate (context, settings) {
+ $('p.' + settings.errorClass, context).remove()
+ context.removeClass(settings.errorClass)
+ $('input, label', context).removeClass(settings.errorClass)
+ }
+
+ /**
+ * Default onFormError function to show errors
+ *
+ * @private
+ *
+ * @param {Object} errors object contains validation errors (e.g. nameInvalid=true)
+ * @param {Object} context current context object
+ * @param {Object} settings provided settings
+ */
+ function onFormError (errors, context, settings) {
+ if (errors.nameInvalid) {
+ context.prepend(['<p class="', settings.errorClass, '">', settings.errorMessage, '</p>'].join(''))
+ $(settings.name, context).focus()
+ $(settings.name, context).addClass(settings.errorClass)
+ $('label[for=' + $(settings.name).attr('id') + ']', context).addClass(settings.errorClass)
+ }
+
+ if (errors.drawInvalid)
+ context.prepend(['<p class="', settings.errorClass, '">', settings.errorMessageDraw, '</p>'].join(''))
+ }
+
+ /**
+ * Validates the form to confirm a name was typed in the field
+ * If drawOnly also confirms that the user drew a signature
+ *
+ * @private
+ *
+ * @return {Boolean}
+ */
+ function validateForm () {
+ var valid = true
+ , errors = {drawInvalid: false, nameInvalid: false}
+ , onBeforeArguments = [context, settings]
+ , onErrorArguments = [errors, context, settings]
+
+ if (settings.onBeforeValidate && typeof settings.onBeforeValidate === 'function') {
+ settings.onBeforeValidate.apply(self,onBeforeArguments)
+ } else {
+ onBeforeValidate.apply(self, onBeforeArguments)
+ }
+
+ if (settings.drawOnly && output.length < 1) {
+ errors.drawInvalid = true
+ valid = false
+ }
+
+ if ($(settings.name, context).val() === '') {
+ errors.nameInvalid = true
+ valid = false
+ }
+
+ if (settings.onFormError && typeof settings.onFormError === 'function') {
+ settings.onFormError.apply(self,onErrorArguments)
+ } else {
+ onFormError.apply(self, onErrorArguments)
+ }
+
+ return valid
+ }
+
+ /**
+ * Redraws the signature on a specific canvas
+ *
+ * @private
+ *
+ * @param {Array} paths the signature JSON
+ * @param {Object} context the canvas context to draw on
+ * @param {Boolean} saveOutput whether to write the path to the output array or not
+ */
+ function drawSignature (paths, context, saveOutput) {
+ for(var i in paths) {
+ if (typeof paths[i] === 'object') {
+ context.beginPath()
+ context.moveTo(paths[i].mx, paths[i].my)
+ context.lineTo(paths[i].lx, paths[i].ly)
+ context.lineCap = settings.penCap
+ context.stroke()
+ context.closePath()
+
+ if (saveOutput) {
+ output.push({
+ 'lx' : paths[i].lx
+ , 'ly' : paths[i].ly
+ , 'mx' : paths[i].mx
+ , 'my' : paths[i].my
+ })
+ }
+ }
+ }
+ }
+
+ /**
+ * Initialisation function, called immediately after all declarations
+ * Technically public, but only should be used internally
+ *
+ * @private
+ */
+ function init () {
+ // Fixes the jQuery.fn.offset() function for Mobile Safari Browsers i.e. iPod Touch, iPad and iPhone
+ // https://gist.github.com/661844
+ // http://bugs.jquery.com/ticket/6446
+ if (parseFloat(((/CPU.+OS ([0-9_]{3}).*AppleWebkit.*Mobile/i.exec(navigator.userAgent)) || [0,'4_2'])[1].replace('_','.')) < 4.1) {
+ $.fn.Oldoffset = $.fn.offset;
+ $.fn.offset = function () {
+ var result = $(this).Oldoffset()
+ result.top -= window.scrollY
+ result.left -= window.scrollX
+
+ return result
+ }
+ }
+
+ // Disable selection on the typed div and canvas
+ $(settings.typed, context).bind('selectstart.signaturepad', function (e) { return $(e.target).is(':input') })
+ canvas.bind('selectstart.signaturepad', function (e) { return $(e.target).is(':input') })
+
+ if (!element.getContext && FlashCanvas)
+ FlashCanvas.initElement(element)
+
+ if (element.getContext) {
+ canvasContext = element.getContext('2d')
+
+ $(settings.sig, context).show()
+
+ if (!settings.displayOnly) {
+ if (!settings.drawOnly) {
+ $(settings.name, context).bind('keyup.signaturepad', function () {
+ type($(this).val())
+ })
+
+ $(settings.name, context).bind('blur.signaturepad', function () {
+ type($(this).val())
+ })
+
+ $(settings.drawIt, context).bind('click.signaturepad', function (e) {
+ e.preventDefault()
+ drawIt()
+ })
+ }
+
+ if (settings.drawOnly || settings.defaultAction === 'drawIt') {
+ drawIt()
+ } else {
+ typeIt()
+ }
+
+ if (settings.validateFields) {
+ if ($(selector).is('form')) {
+ $(selector).bind('submit.signaturepad', function () { return validateForm() })
+ } else {
+ $(selector).parents('form').bind('submit.signaturepad', function () { return validateForm() })
+ }
+ }
+
+ $(settings.sigNav, context).show()
+ }
+ }
+ }
+
+ $.extend(self, {
+ /**
+ * A property to store the current version of Signature Pad
+ */
+ signaturePad : '{{version}}'
+
+ /**
+ * Initializes SignaturePad
+ */
+ , init : function () { init() }
+
+ /**
+ * Allows options to be updated after initialization
+ *
+ * @param {Object} options An object containing the options to be changed
+ */
+ , updateOptions : function (options) {
+ $.extend(settings, options)
+ }
+
+ /**
+ * Regenerates a signature on the canvas using an array of objects
+ * Follows same format as object property
+ * @see var object
+ *
+ * @param {Array} paths An array of the lines and points
+ */
+ , regenerate : function (paths) {
+ self.clearCanvas()
+ $(settings.typed, context).hide()
+
+ if (typeof paths === 'string')
+ paths = JSON.parse(paths)
+
+ drawSignature(paths, canvasContext, true)
+
+ if (settings.output && $(settings.output, context).length > 0)
+ $(settings.output, context).val(JSON.stringify(output))
+ }
+
+ /**
+ * Clears the canvas
+ * Redraws the background colour and the signature line
+ */
+ , clearCanvas : function () { clearCanvas() }
+
+ /**
+ * Returns the signature as a Js array
+ *
+ * @return {Array}
+ */
+ , getSignature : function () { return output }
+
+ /**
+ * Returns the signature as a Json string
+ *
+ * @return {String}
+ */
+ , getSignatureString : function () { return JSON.stringify(output) }
+
+ /**
+ * Returns the signature as an image
+ * Re-draws the signature in a shadow canvas to create a clean version
+ *
+ * @return {String}
+ */
+ , getSignatureImage : function () {
+ var tmpCanvas = document.createElement('canvas')
+ , tmpContext = null
+ , data = null
+
+ tmpCanvas.style.position = 'absolute'
+ tmpCanvas.style.top = '-999em'
+ tmpCanvas.width = element.width
+ tmpCanvas.height = element.height
+ document.body.appendChild(tmpCanvas)
+
+ if (!tmpCanvas.getContext && FlashCanvas)
+ FlashCanvas.initElement(tmpCanvas)
+
+ tmpContext = tmpCanvas.getContext('2d')
+
+ tmpContext.fillStyle = settings.bgColour
+ tmpContext.fillRect(0, 0, element.width, element.height)
+ tmpContext.lineWidth = settings.penWidth
+ tmpContext.strokeStyle = settings.penColour
+
+ drawSignature(output, tmpContext)
+ data = tmpCanvas.toDataURL.apply(tmpCanvas, arguments)
+
+ document.body.removeChild(tmpCanvas)
+ tmpCanvas = null
+
+ return data
+ }
+
+ /**
+ * The form validation function
+ * Validates that the signature has been filled in properly
+ * Allows it to be hooked into another validation function and called at a different time
+ *
+ * @return {Boolean}
+ */
+ , validateForm : function () { return validateForm() }
+ })
+}
+
+/**
+ * Create the plugin
+ * Returns an Api which can be used to call specific methods
+ *
+ * @param {Object} options The options array
+ *
+ * @return {Object} The Api for controlling the instance
+ */
+$.fn.signaturePad = function (options) {
+ var api = null
+
+ this.each(function () {
+ if (!$.data(this, 'plugin-signaturePad')) {
+ api = new SignaturePad(this, options)
+ api.init()
+ $.data(this, 'plugin-signaturePad', api)
+ } else {
+ api = $.data(this, 'plugin-signaturePad')
+ api.updateOptions(options)
+ }
+ })
+
+ return api
+}
+
+/**
+ * Expose the defaults so they can be overwritten for multiple instances
+ *
+ * @type {Object}
+ */
+$.fn.signaturePad.defaults = {
+ defaultAction : 'typeIt' // What action should be highlighted first: typeIt or drawIt
+ , displayOnly : false // Initialize canvas for signature display only; ignore buttons and inputs
+ , drawOnly : false // Whether the to allow a typed signature or not
+ , canvas : 'canvas' // Selector for selecting the canvas element
+ , sig : '.sig' // Parts of the signature form that require Javascript (hidden by default)
+ , sigNav : '.sigNav' // The TypeIt/DrawIt navigation (hidden by default)
+ , bgColour : '#ffffff' // The colour fill for the background of the canvas; or transparent
+ , penColour : '#145394' // Colour of the drawing ink
+ , penWidth : 2 // Thickness of the pen
+ , penCap : 'round' // Determines how the end points of each line are drawn (values: 'butt', 'round', 'square')
+ , lineColour : '#ccc' // Colour of the signature line
+ , lineWidth : 2 // Thickness of the signature line
+ , lineMargin : 5 // Margin on right and left of signature line
+ , lineTop : 35 // Distance to draw the line from the top
+ , name : '.name' // The input field for typing a name
+ , typed : '.typed' // The Html element to accept the printed name
+ , clear : '.clearButton' // Button for clearing the canvas
+ , typeIt : '.typeIt a' // Button to trigger name typing actions (current by default)
+ , drawIt : '.drawIt a' // Button to trigger name drawing actions
+ , typeItDesc : '.typeItDesc' // The description for TypeIt actions
+ , drawItDesc : '.drawItDesc' // The description for DrawIt actions (hidden by default)
+ , output : '.output' // The hidden input field for remembering line coordinates
+ , currentClass : 'current' // The class used to mark items as being currently active
+ , validateFields : true // Whether the name, draw fields should be validated
+ , errorClass : 'error' // The class applied to the new error Html element
+ , errorMessage : 'Please enter whose the entered signature' // The error message displayed on invalid submission
+ , errorMessageDraw : 'Please sign the document' // The error message displayed when drawOnly and no signature is drawn
+ , onBeforeValidate : null // Pass a callback to be used instead of the built-in function
+ , onFormError : null // Pass a callback to be used instead of the built-in function
+ , onDraw : null // Pass a callback to be used to capture the drawing process
+ , onDrawEnd : null // Pass a callback to be exectued after the drawing process
+}
+
+}(jQuery));
diff --git a/main/survey/js/signature_pad.js b/main/survey/js/signature_pad.js
new file mode 100644
index 0000000..703c579
--- /dev/null
+++ b/main/survey/js/signature_pad.js
@@ -0,0 +1,323 @@
+var SignaturePad = (function (document) {
+ "use strict";
+
+ var SignaturePad = function (canvas, options) {
+ var self = this,
+ opts = options || {};
+
+ this.velocityFilterWeight = opts.velocityFilterWeight || 0.7;
+ this.minWidth = opts.minWidth || 0.5;
+ this.maxWidth = opts.maxWidth || 2.5;
+ this.dotSize = opts.dotSize || function () {
+ return (this.minWidth + this.maxWidth) / 2;
+ };
+ this.penColor = opts.penColor || "black";
+ this.backgroundColor = opts.backgroundColor || "rgba(0,0,0,0)";
+ this.onEnd = opts.onEnd;
+ this.onBegin = opts.onBegin;
+
+ this._canvas = canvas;
+ this._ctx = canvas.getContext("2d");
+ this.clear();
+
+ this._handleMouseEvents();
+ this._handleTouchEvents();
+ };
+
+ SignaturePad.prototype.clear = function () {
+ var ctx = this._ctx,
+ canvas = this._canvas;
+
+ ctx.fillStyle = this.backgroundColor;
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ this._reset();
+ };
+
+ SignaturePad.prototype.toDataURL = function (imageType, quality) {
+ var canvas = this._canvas;
+ return canvas.toDataURL.apply(canvas, arguments);
+ };
+
+ SignaturePad.prototype.fromDataURL = function (dataUrl) {
+ var self = this,
+ image = new Image();
+
+ this._reset();
+ image.src = dataUrl;
+ image.onload = function () {
+ self._ctx.drawImage(image, 0, 0, self._canvas.width, self._canvas.height);
+ };
+ this._isEmpty = false;
+ };
+
+ SignaturePad.prototype._strokeUpdate = function (event) {
+ var point = this._createPoint(event);
+ this._addPoint(point);
+ };
+
+ SignaturePad.prototype._strokeBegin = function (event) {
+ this._reset();
+ this._strokeUpdate(event);
+ if (typeof this.onBegin === 'function') {
+ this.onBegin(event);
+ }
+ };
+
+ SignaturePad.prototype._strokeDraw = function (point) {
+ var ctx = this._ctx,
+ dotSize = typeof(this.dotSize) === 'function' ? this.dotSize() : this.dotSize;
+
+ ctx.beginPath();
+ this._drawPoint(point.x, point.y, dotSize);
+ ctx.closePath();
+ ctx.fill();
+ };
+
+ SignaturePad.prototype._strokeEnd = function (event) {
+ var canDrawCurve = this.points.length > 2,
+ point = this.points[0];
+
+ if (!canDrawCurve && point) {
+ this._strokeDraw(point);
+ }
+ if (typeof this.onEnd === 'function') {
+ this.onEnd(event);
+ }
+ };
+
+ SignaturePad.prototype._handleMouseEvents = function () {
+ var self = this;
+ this._mouseButtonDown = false;
+
+ this._canvas.addEventListener("mousedown", function (event) {
+ if (event.which === 1) {
+ self._mouseButtonDown = true;
+ self._strokeBegin(event);
+ }
+ });
+
+ this._canvas.addEventListener("mousemove", function (event) {
+ if (self._mouseButtonDown) {
+ self._strokeUpdate(event);
+ }
+ });
+
+ document.addEventListener("mouseup", function (event) {
+ if (event.which === 1 && self._mouseButtonDown) {
+ self._mouseButtonDown = false;
+ self._strokeEnd(event);
+ }
+ });
+ };
+
+ SignaturePad.prototype._handleTouchEvents = function () {
+ var self = this;
+
+ // Pass touch events to canvas element on mobile IE.
+ this._canvas.style.msTouchAction = 'none';
+
+ this._canvas.addEventListener("touchstart", function (event) {
+ var touch = event.changedTouches[0];
+ self._strokeBegin(touch);
+ });
+
+ this._canvas.addEventListener("touchmove", function (event) {
+ // Prevent scrolling.
+ event.preventDefault();
+
+ var touch = event.changedTouches[0];
+ self._strokeUpdate(touch);
+ });
+
+ document.addEventListener("touchend", function (event) {
+ var wasCanvasTouched = event.target === self._canvas;
+ if (wasCanvasTouched) {
+ self._strokeEnd(event);
+ }
+ });
+ };
+
+ SignaturePad.prototype.isEmpty = function () {
+ return this._isEmpty;
+ };
+
+ SignaturePad.prototype._reset = function () {
+ this.points = [];
+ this._lastVelocity = 0;
+ this._lastWidth = (this.minWidth + this.maxWidth) / 2;
+ this._isEmpty = true;
+ this._ctx.fillStyle = this.penColor;
+ };
+
+ SignaturePad.prototype._createPoint = function (event) {
+ var rect = this._canvas.getBoundingClientRect();
+ return new Point(
+ event.clientX - rect.left,
+ event.clientY - rect.top
+ );
+ };
+
+ SignaturePad.prototype._addPoint = function (point) {
+ var points = this.points,
+ c2, c3,
+ curve, tmp;
+
+ points.push(point);
+
+ if (points.length > 2) {
+ // To reduce the initial lag make it work with 3 points
+ // by copying the first point to the beginning.
+ if (points.length === 3) points.unshift(points[0]);
+
+ tmp = this._calculateCurveControlPoints(points[0], points[1], points[2]);
+ c2 = tmp.c2;
+ tmp = this._calculateCurveControlPoints(points[1], points[2], points[3]);
+ c3 = tmp.c1;
+ curve = new Bezier(points[1], c2, c3, points[2]);
+ this._addCurve(curve);
+
+ // Remove the first element from the list,
+ // so that we always have no more than 4 points in points array.
+ points.shift();
+ }
+ };
+
+ SignaturePad.prototype._calculateCurveControlPoints = function (s1, s2, s3) {
+ var dx1 = s1.x - s2.x, dy1 = s1.y - s2.y,
+ dx2 = s2.x - s3.x, dy2 = s2.y - s3.y,
+
+ m1 = {x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0},
+ m2 = {x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0},
+
+ l1 = Math.sqrt(dx1*dx1 + dy1*dy1),
+ l2 = Math.sqrt(dx2*dx2 + dy2*dy2),
+
+ dxm = (m1.x - m2.x),
+ dym = (m1.y - m2.y),
+
+ k = l2 / (l1 + l2),
+ cm = {x: m2.x + dxm*k, y: m2.y + dym*k},
+
+ tx = s2.x - cm.x,
+ ty = s2.y - cm.y;
+
+ return {
+ c1: new Point(m1.x + tx, m1.y + ty),
+ c2: new Point(m2.x + tx, m2.y + ty)
+ };
+ };
+
+ SignaturePad.prototype._addCurve = function (curve) {
+ var startPoint = curve.startPoint,
+ endPoint = curve.endPoint,
+ velocity, newWidth;
+
+ velocity = endPoint.velocityFrom(startPoint);
+ velocity = this.velocityFilterWeight * velocity
+ + (1 - this.velocityFilterWeight) * this._lastVelocity;
+
+ newWidth = this._strokeWidth(velocity);
+ this._drawCurve(curve, this._lastWidth, newWidth);
+
+ this._lastVelocity = velocity;
+ this._lastWidth = newWidth;
+ };
+
+ SignaturePad.prototype._drawPoint = function (x, y, size) {
+ var ctx = this._ctx;
+
+ ctx.moveTo(x, y);
+ ctx.arc(x, y, size, 0, 2 * Math.PI, false);
+ this._isEmpty = false;
+ };
+
+ SignaturePad.prototype._drawCurve = function (curve, startWidth, endWidth) {
+ var ctx = this._ctx,
+ widthDelta = endWidth - startWidth,
+ drawSteps, width, i, t, tt, ttt, u, uu, uuu, x, y;
+
+ drawSteps = Math.floor(curve.length());
+ ctx.beginPath();
+ for (i = 0; i < drawSteps; i++) {
+ // Calculate the Bezier (x, y) coordinate for this step.
+ t = i / drawSteps;
+ tt = t * t;
+ ttt = tt * t;
+ u = 1 - t;
+ uu = u * u;
+ uuu = uu * u;
+
+ x = uuu * curve.startPoint.x;
+ x += 3 * uu * t * curve.control1.x;
+ x += 3 * u * tt * curve.control2.x;
+ x += ttt * curve.endPoint.x;
+
+ y = uuu * curve.startPoint.y;
+ y += 3 * uu * t * curve.control1.y;
+ y += 3 * u * tt * curve.control2.y;
+ y += ttt * curve.endPoint.y;
+
+ width = startWidth + ttt * widthDelta;
+ this._drawPoint(x, y, width);
+ }
+ ctx.closePath();
+ ctx.fill();
+ };
+
+ SignaturePad.prototype._strokeWidth = function (velocity) {
+ return Math.max(this.maxWidth / (velocity + 1), this.minWidth);
+ };
+
+
+ var Point = function (x, y, time) {
+ this.x = x;
+ this.y = y;
+ this.time = time || new Date().getTime();
+ };
+
+ Point.prototype.velocityFrom = function (start) {
+ return (this.time !== start.time) ? this.distanceTo(start) / (this.time - start.time) : 1;
+ };
+
+ Point.prototype.distanceTo = function (start) {
+ return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
+ };
+
+ var Bezier = function (startPoint, control1, control2, endPoint) {
+ this.startPoint = startPoint;
+ this.control1 = control1;
+ this.control2 = control2;
+ this.endPoint = endPoint;
+ };
+
+ // Returns approximated length.
+ Bezier.prototype.length = function () {
+ var steps = 10,
+ length = 0,
+ i, t, cx, cy, px, py, xdiff, ydiff;
+
+ for (i = 0; i <= steps; i++) {
+ t = i / steps;
+ cx = this._point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
+ cy = this._point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
+ if (i > 0) {
+ xdiff = cx - px;
+ ydiff = cy - py;
+ length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
+ }
+ px = cx;
+ py = cy;
+ }
+ return length;
+ };
+
+ Bezier.prototype._point = function (t, start, c1, c2, end) {
+ return start * (1.0 - t) * (1.0 - t) * (1.0 - t)
+ + 3.0 * c1 * (1.0 - t) * (1.0 - t) * t
+ + 3.0 * c2 * (1.0 - t) * t * t
+ + end * t * t * t;
+ };
+
+ return SignaturePad;
+})(document);
diff --git a/main/survey/js/tooltipster.min.js b/main/survey/js/tooltipster.min.js
new file mode 100644
index 0000000..ff8dab1
--- /dev/null
+++ b/main/survey/js/tooltipster.min.js
@@ -0,0 +1 @@
+/* Tooltipster v3.3.0 */;(function(e,t,n){function s(t,n){this.bodyOverflowX;this.callbacks={hide:[],show:[]};this.checkInterval=null;this.Content;this.$el=e(t);this.$elProxy;this.elProxyPosition;this.enabled=true;this.options=e.extend({},i,n);this.mouseIsOverProxy=false;this.namespace="tooltipster-"+Math.round(Math.random()*1e5);this.Status="hidden";this.timerHide=null;this.timerShow=null;this.$tooltip;this.options.iconTheme=this.options.iconTheme.replace(".","");this.options.theme=this.options.theme.replace(".","");this._init()}function o(t,n){var r=true;e.each(t,function(e,i){if(typeof n[e]==="undefined"||t[e]!==n[e]){r=false;return false}});return r}function f(){return!a&&u}function l(){var e=n.body||n.documentElement,t=e.style,r="transition";if(typeof t[r]=="string"){return true}v=["Moz","Webkit","Khtml","O","ms"],r=r.charAt(0).toUpperCase()+r.substr(1);for(var i=0;i<v.length;i++){if(typeof t[v[i]+r]=="string"){return true}}return false}var r="tooltipster",i={animation:"fade",arrow:true,arrowColor:"",autoClose:true,content:null,contentAsHTML:false,contentCloning:true,debug:true,delay:200,minWidth:0,maxWidth:null,functionInit:function(e,t){},functionBefore:function(e,t){t()},functionReady:function(e,t){},functionAfter:function(e){},hideOnClick:false,icon:"(?)",iconCloning:true,iconDesktop:false,iconTouch:false,iconTheme:"tooltipster-icon",interactive:false,interactiveTolerance:350,multiple:false,offsetX:0,offsetY:0,onlyOne:false,position:"top",positionTracker:false,positionTrackerCallback:function(e){if(this.option("trigger")=="hover"&&this.option("autoClose")){this.hide()}},restoration:"current",speed:350,timer:0,theme:"tooltipster-default",touchDevices:true,trigger:"hover",updateAnimation:true};s.prototype={_init:function(){var t=this;if(n.querySelector){var r=null;if(t.$el.data("tooltipster-initialTitle")===undefined){r=t.$el.attr("title");if(r===undefined)r=null;t.$el.data("tooltipster-initialTitle",r)}if(t.options.content!==null){t._content_set(t.options.content)}else{t._content_set(r)}var i=t.options.functionInit.call(t.$el,t.$el,t.Content);if(typeof i!=="undefined")t._content_set(i);t.$el.removeAttr("title").addClass("tooltipstered");if(!u&&t.options.iconDesktop||u&&t.options.iconTouch){if(typeof t.options.icon==="string"){t.$elProxy=e('<span class="'+t.options.iconTheme+'"></span>');t.$elProxy.text(t.options.icon)}else{if(t.options.iconCloning)t.$elProxy=t.options.icon.clone(true);else t.$elProxy=t.options.icon}t.$elProxy.insertAfter(t.$el)}else{t.$elProxy=t.$el}if(t.options.trigger=="hover"){t.$elProxy.on("mouseenter."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=true;t._show()}}).on("mouseleave."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=false}});if(u&&t.options.touchDevices){t.$elProxy.on("touchstart."+t.namespace,function(){t._showNow()})}}else if(t.options.trigger=="click"){t.$elProxy.on("click."+t.namespace,function(){if(!f()||t.options.touchDevices){t._show()}})}}},_show:function(){var e=this;if(e.Status!="shown"&&e.Status!="appearing"){if(e.options.delay){e.timerShow=setTimeout(function(){if(e.options.trigger=="click"||e.options.trigger=="hover"&&e.mouseIsOverProxy){e._showNow()}},e.options.delay)}else e._showNow()}},_showNow:function(n){var r=this;r.options.functionBefore.call(r.$el,r.$el,function(){if(r.enabled&&r.Content!==null){if(n)r.callbacks.show.push(n);r.callbacks.hide=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;if(r.options.onlyOne){e(".tooltipstered").not(r.$el).each(function(t,n){var r=e(n),i=r.data("tooltipster-ns");e.each(i,function(e,t){var n=r.data(t),i=n.status(),s=n.option("autoClose");if(i!=="hidden"&&i!=="disappearing"&&s){n.hide()}})})}var i=function(){r.Status="shown";e.each(r.callbacks.show,function(e,t){t.call(r.$el)});r.callbacks.show=[]};if(r.Status!=="hidden"){var s=0;if(r.Status==="disappearing"){r.Status="appearing";if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-dying").addClass("tooltipster-"+r.options.animation+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.stop().fadeIn(i)}}else if(r.Status==="shown"){i()}}else{r.Status="appearing";var s=r.options.speed;r.bodyOverflowX=e("body").css("overflow-x");e("body").css("overflow-x","hidden");var o="tooltipster-"+r.options.animation,a="-webkit-transition-duration: "+r.options.speed+"ms; -webkit-animation-duration: "+r.options.speed+"ms; -moz-transition-duration: "+r.options.speed+"ms; -moz-animation-duration: "+r.options.speed+"ms; -o-transition-duration: "+r.options.speed+"ms; -o-animation-duration: "+r.options.speed+"ms; -ms-transition-duration: "+r.options.speed+"ms; -ms-animation-duration: "+r.options.speed+"ms; transition-duration: "+r.options.speed+"ms; animation-duration: "+r.options.speed+"ms;",f=r.options.minWidth?"min-width:"+Math.round(r.options.minWidth)+"px;":"",c=r.options.maxWidth?"max-width:"+Math.round(r.options.maxWidth)+"px;":"",h=r.options.interactive?"pointer-events: auto;":"";r.$tooltip=e('<div class="tooltipster-base '+r.options.theme+'" style="'+f+" "+c+" "+h+" "+a+'"><div class="tooltipster-content"></div></div>');if(l())r.$tooltip.addClass(o);r._content_insert();r.$tooltip.appendTo("body");r.reposition();r.options.functionReady.call(r.$el,r.$el,r.$tooltip);if(l()){r.$tooltip.addClass(o+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.css("display","none").fadeIn(r.options.speed,i)}r._interval_set();e(t).on("scroll."+r.namespace+" resize."+r.namespace,function(){r.reposition()});if(r.options.autoClose){e("body").off("."+r.namespace);if(r.options.trigger=="hover"){if(u){setTimeout(function(){e("body").on("touchstart."+r.namespace,function(){r.hide()})},0)}if(r.options.interactive){if(u){r.$tooltip.on("touchstart."+r.namespace,function(e){e.stopPropagation()})}var p=null;r.$elProxy.add(r.$tooltip).on("mouseleave."+r.namespace+"-autoClose",function(){clearTimeout(p);p=setTimeout(function(){r.hide()},r.options.interactiveTolerance)}).on("mouseenter."+r.namespace+"-autoClose",function(){clearTimeout(p)})}else{r.$elProxy.on("mouseleave."+r.namespace+"-autoClose",function(){r.hide()})}if(r.options.hideOnClick){r.$elProxy.on("click."+r.namespace+"-autoClose",function(){r.hide()})}}else if(r.options.trigger=="click"){setTimeout(function(){e("body").on("click."+r.namespace+" touchstart."+r.namespace,function(){r.hide()})},0);if(r.options.interactive){r.$tooltip.on("click."+r.namespace+" touchstart."+r.namespace,function(e){e.stopPropagation()})}}}}if(r.options.timer>0){r.timerHide=setTimeout(function(){r.timerHide=null;r.hide()},r.options.timer+s)}}})},_interval_set:function(){var t=this;t.checkInterval=setInterval(function(){if(e("body").find(t.$el).length===0||e("body").find(t.$elProxy).length===0||t.Status=="hidden"||e("body").find(t.$tooltip).length===0){if(t.Status=="shown"||t.Status=="appearing")t.hide();t._interval_cancel()}else{if(t.options.positionTracker){var n=t._repositionInfo(t.$elProxy),r=false;if(o(n.dimension,t.elProxyPosition.dimension)){if(t.$elProxy.css("position")==="fixed"){if(o(n.position,t.elProxyPosition.position))r=true}else{if(o(n.offset,t.elProxyPosition.offset))r=true}}if(!r){t.reposition();t.options.positionTrackerCallback.call(t,t.$el)}}}},200)},_interval_cancel:function(){clearInterval(this.checkInterval);this.checkInterval=null},_content_set:function(e){if(typeof e==="object"&&e!==null&&this.options.contentCloning){e=e.clone(true)}this.Content=e},_content_insert:function(){var e=this,t=this.$tooltip.find(".tooltipster-content");if(typeof e.Content==="string"&&!e.options.contentAsHTML){t.text(e.Content)}else{t.empty().append(e.Content)}},_update:function(e){var t=this;t._content_set(e);if(t.Content!==null){if(t.Status!=="hidden"){t._content_insert();t.reposition();if(t.options.updateAnimation){if(l()){t.$tooltip.css({width:"","-webkit-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-moz-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-o-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-ms-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms",transition:"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms"}).addClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!="hidden"){t.$tooltip.removeClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!=="hidden"){t.$tooltip.css({"-webkit-transition":t.options.speed+"ms","-moz-transition":t.options.speed+"ms","-o-transition":t.options.speed+"ms","-ms-transition":t.options.speed+"ms",transition:t.options.speed+"ms"})}},t.options.speed)}},t.options.speed)}else{t.$tooltip.fadeTo(t.options.speed,.5,function(){if(t.Status!="hidden"){t.$tooltip.fadeTo(t.options.speed,1)}})}}}}else{t.hide()}},_repositionInfo:function(e){return{dimension:{height:e.outerHeight(false),width:e.outerWidth(false)},offset:e.offset(),position:{left:parseInt(e.css("left")),top:parseInt(e.css("top"))}}},hide:function(n){var r=this;if(n)r.callbacks.hide.push(n);r.callbacks.show=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;var i=function(){e.each(r.callbacks.hide,function(e,t){t.call(r.$el)});r.callbacks.hide=[]};if(r.Status=="shown"||r.Status=="appearing"){r.Status="disappearing";var s=function(){r.Status="hidden";if(typeof r.Content=="object"&&r.Content!==null){r.Content.detach()}r.$tooltip.remove();r.$tooltip=null;e(t).off("."+r.namespace);e("body").off("."+r.namespace).css("overflow-x",r.bodyOverflowX);e("body").off("."+r.namespace);r.$elProxy.off("."+r.namespace+"-autoClose");r.options.functionAfter.call(r.$el,r.$el);i()};if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-"+r.options.animation+"-show").addClass("tooltipster-dying");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(s)}else{r.$tooltip.stop().fadeOut(r.options.speed,s)}}else if(r.Status=="hidden"){i()}return r},show:function(e){this._showNow(e);return this},update:function(e){return this.content(e)},content:function(e){if(typeof e==="undefined"){return this.Content}else{this._update(e);return this}},reposition:function(){var n=this;if(e("body").find(n.$tooltip).length!==0){n.$tooltip.css("width","");n.elProxyPosition=n._repositionInfo(n.$elProxy);var r=null,i=e(t).width(),s=n.elProxyPosition,o=n.$tooltip.outerWidth(false),u=n.$tooltip.innerWidth()+1,a=n.$tooltip.outerHeight(false);if(n.$elProxy.is("area")){var f=n.$elProxy.attr("shape"),l=n.$elProxy.parent().attr("name"),c=e('img[usemap="#'+l+'"]'),h=c.offset().left,p=c.offset().top,d=n.$elProxy.attr("coords")!==undefined?n.$elProxy.attr("coords").split(","):undefined;if(f=="circle"){var v=parseInt(d[0]),m=parseInt(d[1]),g=parseInt(d[2]);s.dimension.height=g*2;s.dimension.width=g*2;s.offset.top=p+m-g;s.offset.left=h+v-g}else if(f=="rect"){var v=parseInt(d[0]),m=parseInt(d[1]),y=parseInt(d[2]),b=parseInt(d[3]);s.dimension.height=b-m;s.dimension.width=y-v;s.offset.top=p+m;s.offset.left=h+v}else if(f=="poly"){var w=[],E=[],S=0,x=0,T=0,N=0,C="even";for(var k=0;k<d.length;k++){var L=parseInt(d[k]);if(C=="even"){if(L>T){T=L;if(k===0){S=T}}if(L<S){S=L}C="odd"}else{if(L>N){N=L;if(k==1){x=N}}if(L<x){x=L}C="even"}}s.dimension.height=N-x;s.dimension.width=T-S;s.offset.top=p+x;s.offset.left=h+S}else{s.dimension.height=c.outerHeight(false);s.dimension.width=c.outerWidth(false);s.offset.top=p;s.offset.left=h}}var A=0,O=0,M=0,_=parseInt(n.options.offsetY),D=parseInt(n.options.offsetX),P=n.options.position;function H(){var n=e(t).scrollLeft();if(A-n<0){r=A-n;A=n}if(A+o-n>i){r=A-(i+n-o);A=i+n-o}}function B(n,r){if(s.offset.top-e(t).scrollTop()-a-_-12<0&&r.indexOf("top")>-1){P=n}if(s.offset.top+s.dimension.height+a+12+_>e(t).scrollTop()+e(t).height()&&r.indexOf("bottom")>-1){P=n;M=s.offset.top-a-_-12}}if(P=="top"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left+D-j/2;M=s.offset.top-a-_-12;H();B("bottom","top")}if(P=="top-left"){A=s.offset.left+D;M=s.offset.top-a-_-12;H();B("bottom-left","top-left")}if(P=="top-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top-a-_-12;H();B("bottom-right","top-right")}if(P=="bottom"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left-j/2+D;M=s.offset.top+s.dimension.height+_+12;H();B("top","bottom")}if(P=="bottom-left"){A=s.offset.left+D;M=s.offset.top+s.dimension.height+_+12;H();B("top-left","bottom-left")}if(P=="bottom-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top+s.dimension.height+_+12;H();B("top-right","bottom-right")}if(P=="left"){A=s.offset.left-D-o-12;O=s.offset.left+D+s.dimension.width+12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A<0&&O+o>i){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=o+A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);A=s.offset.left-D-q-12-I;F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A<0){A=s.offset.left+D+s.dimension.width+12;r="left"}}if(P=="right"){A=s.offset.left+D+s.dimension.width+12;O=s.offset.left-D-o-12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A+o>i&&O<0){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=i-A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A+o>i){A=s.offset.left-D-o-12;r="right"}}if(n.options.arrow){var R="tooltipster-arrow-"+P;if(n.options.arrowColor.length<1){var U=n.$tooltip.css("background-color")}else{var U=n.options.arrowColor}if(!r){r=""}else if(r=="left"){R="tooltipster-arrow-right";r=""}else if(r=="right"){R="tooltipster-arrow-left";r=""}else{r="left:"+Math.round(r)+"px;"}if(P=="top"||P=="top-left"||P=="top-right"){var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}else if(P=="bottom"||P=="bottom-left"||P=="bottom-right"){var z=parseFloat(n.$tooltip.css("border-top-width")),W=n.$tooltip.css("border-top-color")}else if(P=="left"){var z=parseFloat(n.$tooltip.css("border-right-width")),W=n.$tooltip.css("border-right-color")}else if(P=="right"){var z=parseFloat(n.$tooltip.css("border-left-width")),W=n.$tooltip.css("border-left-color")}else{var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}if(z>1){z++}var X="";if(z!==0){var V="",J="border-color: "+W+";";if(R.indexOf("bottom")!==-1){V="margin-top: -"+Math.round(z)+"px;"}else if(R.indexOf("top")!==-1){V="margin-bottom: -"+Math.round(z)+"px;"}else if(R.indexOf("left")!==-1){V="margin-right: -"+Math.round(z)+"px;"}else if(R.indexOf("right")!==-1){V="margin-left: -"+Math.round(z)+"px;"}X='<span class="tooltipster-arrow-border" style="'+V+" "+J+';"></span>'}n.$tooltip.find(".tooltipster-arrow").remove();var K='<div class="'+R+' tooltipster-arrow" style="'+r+'">'+X+'<span style="border-color:'+U+';"></span></div>';n.$tooltip.append(K)}n.$tooltip.css({top:Math.round(M)+"px",left:Math.round(A)+"px"})}return n},enable:function(){this.enabled=true;return this},disable:function(){this.hide();this.enabled=false;return this},destroy:function(){var t=this;t.hide();if(t.$el[0]!==t.$elProxy[0]){t.$elProxy.remove()}t.$el.removeData(t.namespace).off("."+t.namespace);var n=t.$el.data("tooltipster-ns");if(n.length===1){var r=null;if(t.options.restoration==="previous"){r=t.$el.data("tooltipster-initialTitle")}else if(t.options.restoration==="current"){r=typeof t.Content==="string"?t.Content:e("<div></div>").append(t.Content).html()}if(r){t.$el.attr("title",r)}t.$el.removeClass("tooltipstered").removeData("tooltipster-ns").removeData("tooltipster-initialTitle")}else{n=e.grep(n,function(e,n){return e!==t.namespace});t.$el.data("tooltipster-ns",n)}return t},elementIcon:function(){return this.$el[0]!==this.$elProxy[0]?this.$elProxy[0]:undefined},elementTooltip:function(){return this.$tooltip?this.$tooltip[0]:undefined},option:function(e,t){if(typeof t=="undefined")return this.options[e];else{this.options[e]=t;return this}},status:function(){return this.Status}};e.fn[r]=function(){var t=arguments;if(this.length===0){if(typeof t[0]==="string"){var n=true;switch(t[0]){case"setDefaults":e.extend(i,t[1]);break;default:n=false;break}if(n)return true;else return this}else{return this}}else{if(typeof t[0]==="string"){var r="#*$~&";this.each(function(){var n=e(this).data("tooltipster-ns"),i=n?e(this).data(n[0]):null;if(i){if(typeof i[t[0]]==="function"){var s=i[t[0]](t[1],t[2])}else{throw new Error('Unknown method .tooltipster("'+t[0]+'")')}if(s!==i){r=s;return false}}else{throw new Error("You called Tooltipster's \""+t[0]+'" method on an uninitialized element')}});return r!=="#*$~&"?r:this}else{var o=[],u=t[0]&&typeof t[0].multiple!=="undefined",a=u&&t[0].multiple||!u&&i.multiple,f=t[0]&&typeof t[0].debug!=="undefined",l=f&&t[0].debug||!f&&i.debug;this.each(function(){var n=false,r=e(this).data("tooltipster-ns"),i=null;if(!r){n=true}else if(a){n=true}else if(l){console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.')}if(n){i=new s(this,t[0]);if(!r)r=[];r.push(i.namespace);e(this).data("tooltipster-ns",r);e(this).data(i.namespace,i)}o.push(i)});if(a)return o;else return this}}};var u=!!("ontouchstart"in t);var a=false;e("body").one("mousemove",function(){a=true})})(jQuery,window,document); \ No newline at end of file
diff --git a/main/survey/js/trak_respondent.js b/main/survey/js/trak_respondent.js
new file mode 100644
index 0000000..fc89da3
--- /dev/null
+++ b/main/survey/js/trak_respondent.js
@@ -0,0 +1,67 @@
+//urejanje videza nadnaslovov traka in dropdown-a
+function trak_edit_num_titles_respondent(size, spremenljivka, trak_num_of_titles, trak_nadnaslov){
+ //console.log("Izbrana možnost: "+trak_num_of_titles+" spremenljivka: "+spremenljivka+" size: "+size);
+
+ var g_last = 'gr_'+trak_num_of_titles;
+ var colspan_calc = [];
+ var g_middle = [];
+
+ if(size % trak_num_of_titles == 0){ //ce je stevilo deljivo s trenutnim izbranim stevilom label, spoji ustrezno stevilo label na vsako skupino label
+ for(var i = 1; i<=trak_num_of_titles; i++){
+ colspan_calc[i] = size / trak_num_of_titles;
+ //console.log("colspan_calc za "+i+" je "+colspan_calc[i]);
+ if(i != 1 && i != trak_num_of_titles){
+ g_middle[i] = 'gr_'+i;
+ //console.log("g_middle "+i+" je "+g_middle[i]);
+ }
+ }
+ }else if(size % trak_num_of_titles == 2){
+ for(var i = 1; i<=trak_num_of_titles; i++){
+ //console.log("colspan_calc za "+i+" je "+colspan_calc[i]);
+ if(i != 1 && i != trak_num_of_titles){
+ g_middle[i] = 'gr_'+i;
+ colspan_calc[i] = parseInt(size / trak_num_of_titles);
+ }else{
+ colspan_calc[i] = 1 + parseInt(size / trak_num_of_titles);
+ }
+ }
+ }else if(trak_num_of_titles == 2){ //
+ if(size % trak_num_of_titles == 0){
+ for(var i = 1; i<=trak_num_of_titles; i++){
+ colspan_calc[i] = size / trak_num_of_titles;
+ }
+ }else{
+ colspan_calc[1] = (size / trak_num_of_titles) + 0.5;
+ colspan_calc[trak_num_of_titles] = (size / trak_num_of_titles) - 0.5;
+ }
+ }
+
+ var indeks = 1;
+ $('.display_trak_num_of_titles_respondent_'+spremenljivka+' > td').each(function(){ //preleti labele
+ var grd = $(this).attr('grd');
+ if(String(grd) != 'gr_1' && String(grd) != g_last && String(grd) != g_middle[indeks]){ //ce ni prva ali zadnja labela oz. vmesnim labelam,
+ if(grd !== undefined){
+ $(this).children().text(""); //odstrani tekst
+ $(this).remove(); //odstrani celico
+ }
+ }
+ if(String(grd) == 'gr_1'){ //ce je prva labela,
+ $(this).attr('colspan', colspan_calc[1]); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: left'); //tekst koncne skupine label poravnaj levo
+ $(this).children().text(trak_nadnaslov[String(1)]);
+ indeks++;
+ }
+ if(String(grd) == g_last){ //ce je zadnja labela,
+ $(this).attr('colspan', colspan_calc[trak_num_of_titles]); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: right'); //tekst koncne skupine label poravnaj desno
+ $(this).children().text(trak_nadnaslov[String(trak_num_of_titles)]);
+ }
+ if(String(grd) == g_middle[indeks]){ //ce je vmesna labela,
+ $(this).attr('colspan', colspan_calc[indeks]); //razsiri celico oz. spoji z ostalimi prostimi celicami za tole skupino label
+ $(this).attr('style', 'text-align: center'); //tekst koncne skupine label poravnaj sredinsko
+ $(this).children().text(trak_nadnaslov[String(indeks)]);
+ indeks++;
+ }
+
+ });
+} \ No newline at end of file
diff --git a/main/survey/mobile-detect/Mobile_Detect.php b/main/survey/mobile-detect/Mobile_Detect.php
new file mode 100644
index 0000000..9588386
--- /dev/null
+++ b/main/survey/mobile-detect/Mobile_Detect.php
@@ -0,0 +1,767 @@
+<?php
+/**
+ * MIT License
+ * ===========
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * @author Serban Ghita <serbanghita@gmail.com>
+ * Victor Stanciu <vic.stanciu@gmail.com> (until v.1.0)
+ * @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
+ * @link Official page: http://mobiledetect.net
+ * GitHub Repository: https://github.com/serbanghita/Mobile-Detect
+ * Google Code Old Page: http://code.google.com/p/php-mobile-detect/
+ */
+
+class Mobile_Detect {
+
+ protected $scriptVersion = '2.5.4';
+
+ // External info.
+ protected $userAgent = null;
+ protected $httpHeaders;
+
+ // Arrays holding all detection rules.
+ protected $mobileDetectionRules = null;
+ protected $mobileDetectionRulesExtended = null;
+ // Type of detection to use.
+ protected $detectionType = 'mobile'; // mobile, extended @todo: refactor this.
+
+ // List of mobile devices (phones)
+ protected $phoneDevices = array(
+ 'iPhone' => '(iPhone.*Mobile|iPod|iTunes)',
+ 'BlackBerry' => 'BlackBerry|rim[0-9]+',
+ 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6425|001HT|Inspire 4G',
+ 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile',
+ // @todo: Is 'Dell Streak' a tablet or a phone? ;)
+ 'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
+ 'Motorola' => 'Motorola|\bDroid\b.*Build|DROIDX|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT909|XT910|XT912|XT928',
+ 'Samsung' => 'Samsung|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9300 |GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-P6810|GT-P7100|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N8010',
+ 'Sony' => 'sony|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i',
+ 'Asus' => 'Asus.*Galaxy',
+ 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; @todo - complete the regex.
+ 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
+ // @ref: http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
+ // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
+ 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790',
+ // @ref: http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
+ 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
+ 'GenericPhone' => 'PDA;|PPC;|SAGEM|mmp|pocket|psp|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|wap|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser|LG-P500'
+ );
+ // List of tablet devices.
+ protected $tabletDevices = array(
+ 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
+ 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic.
+ 'NexusTablet' => '^.*Android.*Nexus(((?:(?!Mobile))|(?:(\s(7|10).+))).)*$',
+ // @reference: http://www.labnol.org/software/kindle-user-agent-string/20378/
+ 'Kindle' => 'Kindle|Silk.*Accelerated',
+ 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|GT-P1000|GT-P1010|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P6810|GT-P7501',
+ 'HTCtablet' => 'HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200',
+ 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
+ 'AsusTablet' => 'Transformer|TF101',
+ 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNTV250A|LogicPD Zoom2',
+ // @ref: http://www.acer.ro/ac/ro/RO/content/drivers
+ // @ref: http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
+ 'AcerTablet' => 'Android.*\b(A100|A101|A200|A500|A501|A510|A700|A701|W500|W500P|W501|W501P|G100|G100W)\b',
+ // @ref: http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
+ // @ref: http://us.toshiba.com/tablets/tablet-finder
+ // @ref: http://www.toshiba.co.jp/regza/tablet/
+ 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)',
+ 'YarvikTablet' => 'Android.*(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468)',
+ 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
+ 'ArnovaTablet' => 'AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT',
+ // @reference: http://wiki.archosfans.com/index.php?title=Main_Page
+ 'ArchosTablet' => 'Android.*ARCHOS|101G9|80G9',
+ // @reference: http://en.wikipedia.org/wiki/NOVO7
+ 'AinolTablet' => 'NOVO7|Novo7Aurora|Novo7Basic|NOVO7PALADIN',
+ // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
+ 'SonyTablet' => 'Sony Tablet|Sony Tablet S',
+ // @ref: db + http://www.cube-tablet.com/buy-products.html
+ 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)',
+ // @ref: http://www.cobyusa.com/?p=pcat&pcat_id=3001
+ 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
+ // @ref: http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
+ // @ref: http://www.imp3.net/14/show.php?itemid=20454
+ 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
+ // @ref: http://www.rock-chips.com/index.php?do=prod&pid=2
+ 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
+ // @ref: http://www.telstra.com.au/home-phone/thub-2/
+ 'TelstraTablet' => 'T-Hub2',
+ // @ref: http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
+ 'FlyTablet' => 'IQ310|Fly Vision',
+ // @ref: http://www.bqreaders.com/gb/tablets-prices-sale.html
+ 'bqTablet' => 'bq.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant)',
+ // @ref: http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
+ // @ref: http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
+ 'HuaweiTablet' => 'MediaPad|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim',
+ 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|ViewPad7|LG-V909|MID7015|BNTV250A|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|hp-tablet',
+ );
+ // List of mobile Operating Systems.
+ protected $operatingSystems = array(
+ 'AndroidOS' => 'Android',
+ 'BlackBerryOS' => 'blackberry|rim tablet os',
+ 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
+ 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
+ // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
+ 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
+ // @reference: http://en.wikipedia.org/wiki/Windows_Phone
+ // http://wifeng.cn/?r=blog&a=view&id=106
+ // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
+ 'WindowsPhoneOS' => 'Windows Phone OS|XBLWP7|ZuneWP7',
+ 'iOS' => 'iphone|ipod|ipad',
+ 'FlashLiteOS' => '',
+ // http://en.wikipedia.org/wiki/MeeGo
+ // @todo: research MeeGo in UAs
+ 'MeeGoOS' => 'MeeGo',
+ // http://en.wikipedia.org/wiki/Maemo
+ // @todo: research Maemo in UAs
+ 'MaemoOS' => 'Maemo',
+ 'JavaOS' => 'J2ME/MIDP|Java/',
+ 'webOS' => 'webOS|hpwOS',
+ 'badaOS' => '\bBada\b',
+ 'BREWOS' => 'BREW',
+ );
+ // List of mobile User Agents.
+ protected $userAgents = array(
+ // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
+ 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
+ 'Dolfin' => '\bDolfin\b',
+ 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera',
+ 'Skyfire' => 'Skyfire',
+ 'IE' => 'IEMobile|MSIEMobile',
+ 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile',
+ 'Bolt' => 'bolt',
+ 'TeaShark' => 'teashark',
+ 'Blazer' => 'Blazer',
+ // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
+ 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile',
+ // @ref: http://en.wikipedia.org/wiki/Midori_(web_browser)
+ //'Midori' => 'midori',
+ 'Tizen' => 'Tizen',
+ 'UCBrowser' => 'UC.*Browser|UCWEB',
+ // @ref: https://github.com/serbanghita/Mobile-Detect/issues/7
+ 'DiigoBrowser' => 'DiigoBrowser',
+ // http://www.puffinbrowser.com/index.php
+ 'Puffin' => 'Puffin',
+ // @reference: http://en.wikipedia.org/wiki/Minimo
+ // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
+ 'GenericBrowser' => 'NokiaBrowser|OviBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision'
+ );
+ // Utilities.
+ protected $utilities = array(
+ 'WebKit' => '(webkit)[ /]([\w.]+)',
+ 'Bot' => 'Googlebot|DoCoMo|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|facebookexternalhit',
+ 'MobileBot' => 'Googlebot-Mobile|DoCoMo|YahooSeeker/M1A1-R2D2',
+ );
+ // Properties list.
+ // @reference: http://user-agent-string.info/list-of-ua#Mobile Browser
+ const VER = '([\w._]+)';
+ protected $properties = array(
+
+ // Build
+ 'Mobile' => 'Mobile/[VER]',
+ 'Build' => 'Build/[VER]',
+ 'Version' => 'Version/[VER]',
+ 'VendorID' => 'VendorID/[VER]',
+
+ // Devices
+ 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
+ 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
+ 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
+ //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
+ 'Kindle' => 'Kindle/[VER]',
+
+ // Browser
+ 'Chrome' => 'Chrome/[VER]',
+ 'CriOS' => 'CriOS/[VER]',
+ 'Dolfin' => 'Dolfin/[VER]',
+ // @reference: https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference
+ 'Firefox' => 'Firefox/[VER]',
+ 'Fennec' => 'Fennec/[VER]',
+ // @reference: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
+ 'IEMobile' => array('IEMobile/[VER];', 'IEMobile [VER]'),
+ 'MSIE' => 'MSIE [VER];',
+ // http://en.wikipedia.org/wiki/NetFront
+ 'NetFront' => 'NetFront/[VER]',
+ 'NokiaBrowser' => 'NokiaBrowser/[VER]',
+ 'NokiaBrowser' => 'NokiaBrowser/[VER]',
+ 'Opera' => 'Version/[VER]',
+ 'Opera Mini' => 'Opera Mini/[VER]',
+ 'Opera Mobi' => 'Version/[VER]',
+ 'UC Browser' => 'UC Browser[VER]',
+ 'Safari' => 'Version/[VER]',
+ 'Skyfire' => 'Skyfire/[VER]',
+ 'Tizen' => 'Tizen/[VER]',
+ 'Webkit' => 'webkit[ /][VER]',
+
+ // Engine
+ 'Gecko' => 'Gecko/[VER]',
+ 'Trident' => 'Trident/[VER]',
+ 'Presto' => 'Presto/[VER]',
+
+ // OS
+ 'Android' => 'Android [VER]',
+ 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]'),
+ 'BREW' => 'BREW [VER]',
+ 'Java' => 'Java/[VER]',
+ // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
+ // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
+ 'Windows Phone OS' => 'Windows Phone OS [VER]',
+ 'Windows Phone' => 'Windows Phone [VER]',
+ 'Windows CE' => 'Windows CE/[VER]',
+ // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
+ 'Windows NT' => 'Windows NT [VER]',
+ 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
+ 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
+
+
+ );
+
+ function __construct(){
+
+ $this->setHttpHeaders();
+ $this->setUserAgent();
+
+ $this->setMobileDetectionRules();
+ $this->setMobileDetectionRulesExtended();
+
+ }
+
+
+ /**
+ * Get the current script version.
+ * This is useful for the demo.php file,
+ * so people can check on what version they are testing
+ * for mobile devices.
+ */
+ public function getScriptVersion(){
+
+ return $this->scriptVersion;
+
+ }
+
+ public function setHttpHeaders($httpHeaders = null){
+
+ if(!empty($httpHeaders)){
+ $this->httpHeaders = $httpHeaders;
+ } else {
+ foreach($_SERVER as $key => $value){
+ if(substr($key,0,5)=='HTTP_'){
+ $this->httpHeaders[$key] = $value;
+ }
+ }
+ }
+
+ }
+
+ public function getHttpHeaders(){
+
+ return $this->httpHeaders;
+
+ }
+
+ public function setUserAgent($userAgent = null){
+
+ if(!empty($userAgent)){
+ $this->userAgent = $userAgent;
+ } else {
+ $this->userAgent = isset($this->httpHeaders['HTTP_USER_AGENT']) ? $this->httpHeaders['HTTP_USER_AGENT'] : null;
+
+ if(empty($this->userAgent)){
+ $this->userAgent = isset($this->httpHeaders['HTTP_X_DEVICE_USER_AGENT']) ? $this->httpHeaders['HTTP_X_DEVICE_USER_AGENT'] : null;
+ }
+ // Header can occur on devices using Opera Mini (can expose the real device type). Let's concatenate it (we need this extra info in the regexes).
+ if(!empty($this->httpHeaders['HTTP_X_OPERAMINI_PHONE_UA'])){
+ $this->userAgent .= ' '.$this->httpHeaders['HTTP_X_OPERAMINI_PHONE_UA'];
+ }
+ }
+
+ }
+
+ public function getUserAgent(){
+
+ return $this->userAgent;
+
+ }
+
+ function setDetectionType($type = null){
+
+ $this->detectionType = (!empty($type) ? $type : 'mobile');
+
+ }
+
+ public function getPhoneDevices(){
+
+ return $this->phoneDevices;
+
+ }
+
+ public function getTabletDevices(){
+
+ return $this->tabletDevices;
+
+ }
+
+ /**
+ * Method sets the mobile detection rules.
+ *
+ * This method is used for the magic methods $detect->is*()
+ */
+ public function setMobileDetectionRules(){
+ // Merge all rules together.
+ $this->mobileDetectionRules = array_merge(
+ $this->phoneDevices,
+ $this->tabletDevices,
+ $this->operatingSystems,
+ $this->userAgents
+ );
+
+ }
+
+ /**
+ * Method sets the mobile detection rules + utilities.
+ * The reason this is separate is because utilities rules
+ * don't necessary imply mobile.
+ *
+ * This method is used inside the new $detect->is('stuff') method.
+ *
+ * @return bool
+ */
+ public function setMobileDetectionRulesExtended(){
+
+ // Merge all rules together.
+ $this->mobileDetectionRulesExtended = array_merge(
+ $this->phoneDevices,
+ $this->tabletDevices,
+ $this->operatingSystems,
+ $this->userAgents,
+ $this->utilities
+ );
+
+ }
+
+ /**
+ * @return array
+ */
+ public function getRules()
+ {
+
+ if($this->detectionType=='extended'){
+ return $this->mobileDetectionRulesExtended;
+ } else {
+ return $this->mobileDetectionRules;
+ }
+
+ }
+
+/**
+* Check the HTTP headers for signs of mobile.
+* This is the fastest mobile check possible; it's used
+* inside isMobile() method.
+* @return boolean
+*/
+ public function checkHttpHeadersForMobile(){
+
+ if(
+ isset($this->httpHeaders['HTTP_ACCEPT']) &&
+ (strpos($this->httpHeaders['HTTP_ACCEPT'], 'application/x-obml2d') !== false || // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
+ strpos($this->httpHeaders['HTTP_ACCEPT'], 'application/vnd.rim.html') !== false || // BlackBerry devices.
+ strpos($this->httpHeaders['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false ||
+ strpos($this->httpHeaders['HTTP_ACCEPT'], 'application/vnd.wap.xhtml+xml') !== false) ||
+ isset($this->httpHeaders['HTTP_X_WAP_PROFILE']) || // @todo: validate
+ isset($this->httpHeaders['HTTP_X_WAP_CLIENTID']) ||
+ isset($this->httpHeaders['HTTP_WAP_CONNECTION']) ||
+ isset($this->httpHeaders['HTTP_PROFILE']) ||
+ isset($this->httpHeaders['HTTP_X_OPERAMINI_PHONE_UA']) || // Reported by Nokia devices (eg. C3)
+ isset($this->httpHeaders['HTTP_X_NOKIA_IPADDRESS']) ||
+ isset($this->httpHeaders['HTTP_X_NOKIA_GATEWAY_ID']) ||
+ isset($this->httpHeaders['HTTP_X_ORANGE_ID']) ||
+ isset($this->httpHeaders['HTTP_X_VODAFONE_3GPDPCONTEXT']) ||
+ isset($this->httpHeaders['HTTP_X_HUAWEI_USERID']) ||
+ isset($this->httpHeaders['HTTP_UA_OS']) || // Reported by Windows Smartphones.
+ isset($this->httpHeaders['HTTP_X_MOBILE_GATEWAY']) || // Reported by Verizon, Vodafone proxy system.
+ isset($this->httpHeaders['HTTP_X_ATT_DEVICEID']) || // Seend this on HTC Sensation. @ref: SensationXE_Beats_Z715e
+ //HTTP_X_NETWORK_TYPE = WIFI
+ ( isset($this->httpHeaders['HTTP_UA_CPU']) &&
+ $this->httpHeaders['HTTP_UA_CPU'] == 'ARM' // Seen this on a HTC.
+ )
+ ){
+
+ return true;
+
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Magic overloading method.
+ *
+ * @method boolean is[...]()
+ * @param string $name
+ * @param array $arguments
+ * @return mixed
+ */
+ public function __call($name, $arguments)
+ {
+
+ $this->setDetectionType('mobile');
+
+ $key = substr($name, 2);
+ return $this->matchUAAgainstKey($key);
+
+ }
+
+ /**
+ * Find a detection rule that matches the current User-agent.
+ *
+ * @param null $userAgent deprecated
+ * @return boolean
+ */
+ private function matchDetectionRulesAgainstUA($userAgent = null){
+
+ // Begin general search.
+ foreach($this->getRules() as $_regex){
+ if(empty($_regex)){ continue; }
+ if( $this->match($_regex, $userAgent) ){
+ //var_dump( $_regex );
+ return true;
+ }
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Search for a certain key in the rules array.
+ * If the key is found the try to match the corresponding
+ * regex agains the User-agent.
+ *
+ * @param string $key
+ * @param null $userAgent deprecated
+ * @return mixed
+ */
+ private function matchUAAgainstKey($key, $userAgent = null){
+
+ // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
+ $key = strtolower($key);
+ $_rules = array_change_key_case($this->getRules());
+
+ if(array_key_exists($key, $_rules)){
+ if(empty($_rules[$key])){ return null; }
+ return $this->match($_rules[$key], $userAgent);
+ }
+
+ return false;
+
+ }
+
+ /**
+ * Check if the device is mobile.
+ * Returns true if any type of mobile device detected, including special ones
+ * @param null $userAgent deprecated
+ * @param null $httpHeaders deprecated
+ * @return bool
+ */
+ public function isMobile($userAgent = null, $httpHeaders = null) {
+
+ if($httpHeaders){ $this->setHttpHeaders($httpHeaders); }
+ if($userAgent){ $this->setUserAgent($userAgent); }
+
+ $this->setDetectionType('mobile');
+
+ if ($this->checkHttpHeadersForMobile()) {
+ return true;
+ } else {
+ return $this->matchDetectionRulesAgainstUA();
+ }
+
+ }
+
+ /**
+ * Check if the device is a tablet.
+ * Return true if any type of tablet device is detected.
+ *
+ * @param null $userAgent deprecated
+ * @param null $httpHeaders deprecated
+ * @return bool
+ */
+ public function isTablet($userAgent = null, $httpHeaders = null) {
+
+ $this->setDetectionType('mobile');
+
+ foreach($this->tabletDevices as $_regex){
+ if($this->match($_regex, $userAgent)){
+ return true;
+ }
+ }
+
+ return false;
+
+ }
+
+ /**
+ * This method checks for a certain property in the
+ * userAgent.
+ * @todo: The httpHeaders part is not yet used.
+ *
+ * @param $key
+ * @param string $userAgent deprecated
+ * @param string $httpHeaders deprecated
+ * @return bool|int|null
+ */
+ public function is($key, $userAgent = null, $httpHeaders = null){
+
+
+ // Set the UA and HTTP headers only if needed (eg. batch mode).
+ if($httpHeaders) $this->setHttpHeaders($httpHeaders);
+ if($userAgent) $this->setUserAgent($userAgent);
+
+ $this->setDetectionType('extended');
+
+ return $this->matchUAAgainstKey($key);
+
+ }
+
+ public function getOperatingSystems(){
+
+ return $this->operatingSystems;
+
+ }
+
+ /**
+ * Some detection rules are relative (not standard),
+ * because of the diversity of devices, vendors and
+ * their conventions in representing the User-Agent or
+ * the HTTP headers.
+ *
+ * This method will be used to check custom regexes against
+ * the User-Agent string.
+ *
+ * @param $regex
+ * @param string $userAgent
+ * @return bool
+ *
+ * @todo: search in the HTTP headers too.
+ */
+ function match($regex, $userAgent=null){
+
+ // Escape the special character which is the delimiter.
+ $regex = str_replace('/', '\/', $regex);
+
+ return (bool)preg_match('/'.$regex.'/is', (!empty($userAgent) ? $userAgent : $this->userAgent));
+
+ }
+
+ /**
+ * Get the properties array.
+ * @return array
+ */
+ function getProperties(){
+
+ return $this->properties;
+
+ }
+
+ /**
+ * Prepare the version number.
+ *
+ * @param $ver
+ * @return int
+ */
+ function prepareVersionNo($ver){
+
+ $ver = str_replace(array('_', ' ', '/'), array('.', '.', '.'), $ver);
+ $arrVer = explode('.', $ver, 2);
+ $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
+ $ver = (float)implode('.', $arrVer);
+
+ return $ver;
+
+ }
+
+ /**
+ * Check the version of the given property in the User-Agent.
+ * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
+ *
+ * @param string $propertyName
+ * @return mixed $version
+ */
+ function version($propertyName){
+
+ $properties = $this->getProperties();
+
+ // If the property is found in the User-Agent then move to the next step.
+ if(stripos($this->userAgent, $propertyName)!==false){
+
+ // Prepare the pattern to be matched.
+ // Make sure we always deal with an array (string is converted).
+ $properties[$propertyName] = (array)$properties[$propertyName];
+
+ foreach($properties[$propertyName] as $propertyMatchString){
+
+ $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
+
+ // Escape the special character which is the delimiter.
+ $propertyPattern = str_replace('/', '\/', $propertyPattern);
+
+ // Identify and extract the version.
+ preg_match('/'.$propertyPattern.'/is', $this->userAgent, $match);
+
+ if(!empty($match[1])){
+ $version = $this->prepareVersionNo($match[1]);
+ return $version;
+ }
+
+ }
+
+ return 0;
+
+ }
+
+ return false;
+
+ }
+
+ function mobileGrade(){
+
+ $isMobile = $this->isMobile();
+
+ if(
+ // Apple iOS 3.2-5.1 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), iPad 3 (5.1), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.1)
+ $this->version('iPad')>=4.3 ||
+ $this->version('iPhone')>=3.1 ||
+ $this->version('iPod')>=3.1 ||
+
+ // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5)
+ // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
+ // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
+ // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
+ ( $this->version('Android')>2.1 && $this->is('Webkit') ) ||
+
+ // Windows Phone 7-7.5 - Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800
+ $this->version('Windows Phone OS')>=7.0 ||
+
+ // Blackberry 7 - Tested on BlackBerry® Torch 9810
+ // Blackberry 6.0 - Tested on the Torch 9800 and Style 9670
+ $this->version('BlackBerry')>=6.0 ||
+ // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
+ $this->match('Playbook.*Tablet') ||
+
+ // Palm WebOS (1.4-2.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0)
+ ( $this->version('webOS')>=1.4 && $this->match('Palm|Pre|Pixi') ) ||
+ // Palm WebOS 3.0 - Tested on HP TouchPad
+ $this->match('hp.*TouchPad') ||
+
+ // Firefox Mobile (12 Beta) - Tested on Android 2.3 device
+ ( $this->is('Firefox') && $this->version('Firefox')>=12 ) ||
+
+ // Chrome for Android - Tested on Android 4.0, 4.1 device
+ ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android')>=4.0 ) ||
+
+ // Skyfire 4.1 - Tested on Android 2.3 device
+ ( $this->is('Skyfire') && $this->version('Skyfire')>=4.1 && $this->is('AndroidOS') && $this->version('Android')>=2.3 ) ||
+
+ // Opera Mobile 11.5-12: Tested on Android 2.3
+ ( $this->is('Opera') && $this->version('Opera Mobi')>11 && $this->is('AndroidOS') ) ||
+
+ // Meego 1.2 - Tested on Nokia 950 and N9
+ $this->is('MeeGoOS') ||
+
+ // Tizen (pre-release) - Tested on early hardware
+ $this->is('Tizen') ||
+
+ // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
+ // @todo: more tests here!
+ $this->is('Dolfin') && $this->version('Bada')>=2.0 ||
+
+ // UC Browser - Tested on Android 2.3 device
+ ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android')>=2.3 ) ||
+
+ // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
+ ( $this->match('Kindle Fire') ||
+ $this->is('Kindle') && $this->version('Kindle')>=3.0 ) ||
+
+ // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
+ $this->is('AndroidOS') && $this->is('NookTablet') ||
+
+ // Chrome Desktop 11-21 - Tested on OS X 10.7 and Windows 7
+ $this->version('Chrome')>=11 && !$isMobile ||
+
+ // Safari Desktop 4-5 - Tested on OS X 10.7 and Windows 7
+ $this->version('Safari')>=5.0 && !$isMobile ||
+
+ // Firefox Desktop 4-13 - Tested on OS X 10.7 and Windows 7
+ $this->version('Firefox')>=4.0 && !$isMobile ||
+
+ // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
+ $this->version('MSIE')>=7.0 && !$isMobile ||
+
+ // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
+ // @reference: http://my.opera.com/community/openweb/idopera/
+ $this->version('Opera')>=10 && !$isMobile
+
+
+ ){
+ return 'A';
+ }
+
+ if(
+ // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
+ $this->version('BlackBerry')>=5 && $this->version('BlackBerry')<6 ||
+
+ //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
+ ( $this->version('Opera Mini')>=5.0 && $this->version('Opera Mini')<=6.5 &&
+ ($this->version('Android')>=2.3 || $this->is('iOS')) ) ||
+
+ // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
+ $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
+
+ // @todo: report this (tested on Nokia N71)
+ $this->version('Opera Mobi')>=11 && $this->is('SymbianOS')
+
+ ){
+ return 'B';
+ }
+
+ if(
+ // Blackberry 4.x - Tested on the Curve 8330
+ $this->version('BlackBerry')<5.0 ||
+ // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
+ $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile')<=5.2
+
+
+ ){
+
+ return 'C';
+
+ }
+
+ // All older smartphone platforms and featurephones - Any device that doesn't support media queries will receive the basic, C grade experience
+ return 'C';
+
+
+ }
+
+
+} \ No newline at end of file
diff --git a/main/survey/sa_koda.php b/main/survey/sa_koda.php
new file mode 100644
index 0000000..b7d00b6
--- /dev/null
+++ b/main/survey/sa_koda.php
@@ -0,0 +1,45 @@
+<?php
+/***************************************
+ * Description:
+ * Autor: Robert Šmalc
+ * Created date: 15.04.2016
+ *****************************************/
+include_once('../../settings.php');
+include_once('../../function.php');
+
+if (!empty($_POST['koda'])) {
+ $koda = strtolower($_POST['koda']);
+
+ $sql = sisplet_query("SELECT url, anketa_id FROM srv_hierarhija_koda WHERE koda='" . $koda . "'");
+
+ if ($sql->num_rows > 0) {
+ $row = $sql->fetch_object();
+
+ //kodiramo spremenljivke z base64_encode
+ $url_encode_spremenljivke = urlencode(base64_encode($row->url));
+
+ //celotni url do ankete
+ header("Location: " . $site_url . "a/" . $row->anketa_id . "?enc=" . $url_encode_spremenljivke);
+ die();
+ }
+
+ // V kolikor gre za superšifro potem preverimo še med superšiframi
+ $sql = sisplet_query("SELECT koda, kode, anketa_id FROM srv_hierarhija_supersifra WHERE koda='" . $koda . "'");
+ if ($sql->num_rows > 0) {
+ $row = $sql->fetch_object();
+ $kode = unserialize($row->kode);
+
+ $koda_resevanje = sisplet_query("SELECT url FROM srv_hierarhija_koda WHERE koda='" . $kode[0] . "' AND anketa_id='" . $row->anketa_id . "'", "obj");
+
+ //kodiramo spremenljivke z base64_encode
+ $url_encode_spremenljivke = urlencode(base64_encode($koda_resevanje->url . '&supersifra=' . $koda.'&resujem=0'));
+
+ //celotni url do ankete
+ header("Location: " . $site_url . "a/" . $row->anketa_id . "?enc=" . $url_encode_spremenljivke);
+ die();
+ }
+
+}
+
+header("Location: " . $site_url);
+die();
diff --git a/main/survey/skins/1ka.css b/main/survey/skins/1ka.css
new file mode 100644
index 0000000..4f7dfb4
--- /dev/null
+++ b/main/survey/skins/1ka.css
@@ -0,0 +1,256 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+
+ background: #eff2f7;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+
+ background: #ffffff url('1ka/header.png') top left repeat-x;
+}
+#container {
+ position: relative;
+
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 130px 0 0 0;
+
+ font-size: 22px;
+ color: #0c377a;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 20px;
+ top: 24px;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#logo a{
+ width: 80px;
+ height: 46px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+
+ font-size: 11px;
+ color: #6D87AF;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #0C377A;
+}
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+
+ border-top: 1px #B9C5D9 solid;
+
+ /*box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
+ -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);*/
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 16px;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+.spremenljivka .counter{
+ font-size: 16px;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #EFF2F7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #EFF2F7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #CED7E4;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+input[type="text"], textarea, select{
+ padding: 2px 4px;
+ background: #fff;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 6px 8px;
+
+ text-align: center;
+ /*font-size: 15px;*/
+ font-size: 13px;
+ font-weight: bold;
+ color: #FFFFFF;
+
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #3D5F95;
+ border: 1px solid #3D5F95;
+}
+div.buttons input.next:hover {
+ background-color: #fe8333;
+ border: 1px solid #fe8333;
+}
+div.buttons input.prev {
+ color: #3D5F95;
+ background-color: #ffffff;
+ border: 1px solid #3D5F95;
+}
+div.buttons input.prev:hover {
+ color: #FFFFFF;
+ background-color: #3D5F95;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+
+ background-color: #eff2f7;
+ border-top: 1px #b9c5d9 solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #6d87af;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+/* awesome radio in checkboxi */
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before{
+ color: #3D5F95;
+}
+
+
diff --git a/main/survey/skins/1ka/close.png b/main/survey/skins/1ka/close.png
new file mode 100644
index 0000000..9eefd77
--- /dev/null
+++ b/main/survey/skins/1ka/close.png
Binary files differ
diff --git a/main/survey/skins/1ka/header.png b/main/survey/skins/1ka/header.png
new file mode 100644
index 0000000..76babc7
--- /dev/null
+++ b/main/survey/skins/1ka/header.png
Binary files differ
diff --git a/main/survey/skins/1ka/header_new.png b/main/survey/skins/1ka/header_new.png
new file mode 100644
index 0000000..4b1a281
--- /dev/null
+++ b/main/survey/skins/1ka/header_new.png
Binary files differ
diff --git a/main/survey/skins/1ka/header_new2.png b/main/survey/skins/1ka/header_new2.png
new file mode 100644
index 0000000..0a369ad
--- /dev/null
+++ b/main/survey/skins/1ka/header_new2.png
Binary files differ
diff --git a/main/survey/skins/1ka/logo.png b/main/survey/skins/1ka/logo.png
new file mode 100644
index 0000000..310467c
--- /dev/null
+++ b/main/survey/skins/1ka/logo.png
Binary files differ
diff --git a/main/survey/skins/1ka/logo_full.png b/main/survey/skins/1ka/logo_full.png
new file mode 100644
index 0000000..f37ea54
--- /dev/null
+++ b/main/survey/skins/1ka/logo_full.png
Binary files differ
diff --git a/main/survey/skins/1ka/logo_full_ang.png b/main/survey/skins/1ka/logo_full_ang.png
new file mode 100644
index 0000000..efc8be7
--- /dev/null
+++ b/main/survey/skins/1ka/logo_full_ang.png
Binary files differ
diff --git a/main/survey/skins/1ka/logo_full_old.png b/main/survey/skins/1ka/logo_full_old.png
new file mode 100644
index 0000000..784522a
--- /dev/null
+++ b/main/survey/skins/1ka/logo_full_old.png
Binary files differ
diff --git a/main/survey/skins/1ka/plus.png b/main/survey/skins/1ka/plus.png
new file mode 100644
index 0000000..ab385ca
--- /dev/null
+++ b/main/survey/skins/1ka/plus.png
Binary files differ
diff --git a/main/survey/skins/1kaBlack.css b/main/survey/skins/1kaBlack.css
new file mode 100644
index 0000000..48698bd
--- /dev/null
+++ b/main/survey/skins/1kaBlack.css
@@ -0,0 +1,529 @@
+/*
+ Default tema ankete - 1ka - Crna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #333333 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #333333;
+ text-align: center;
+ border-bottom: 1px solid #eaeaea;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #333333;
+}
+.header_settings_holder .progress_bar p a {
+ color: #333333;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #595959;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #333333;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #595959;
+}
+.header_settings_holder .tawk_chat a {
+ color: #333333;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #595959;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #eaeaea solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #eaeaea;
+ color: #444444;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #d0d0d0;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #444444;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #333333;
+}
+.spremenljivka .arrow {
+ color: #333333;
+}
+.spremenljivka .arrow:hover {
+ color: #595959;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #444444 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #444444 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #444444 solid;
+ border-top: 2px #444444 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #eaeaea;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #eaeaea solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #333333;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #333333 solid;
+ background-color: #eaeaea;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #444444 solid;
+ background-color: #eaeaea;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #333333;
+}
+button.record_foto::before {
+ color: #333333;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #595959;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #595959;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #333333;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #595959;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #333333 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #333333 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #444444;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #444444 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #eaeaea;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #333333;
+ border: 1px solid #333333;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #595959;
+ border: 1px solid #595959;
+}
+div.buttons input.prev {
+ color: #333333;
+ background-color: #fff;
+ border: 1px solid #333333;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #333333;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #eaeaea solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #444444;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #040404;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #444444;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/*# sourceMappingURL=1kaBlack.css.map */
diff --git a/main/survey/skins/1kaBlue.css b/main/survey/skins/1kaBlue.css
new file mode 100644
index 0000000..06bba47
--- /dev/null
+++ b/main/survey/skins/1kaBlue.css
@@ -0,0 +1,529 @@
+/*
+ Default tema ankete - 1ka - Modra barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #1e88e5 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #1e88e5;
+ text-align: center;
+ border-bottom: 1px solid #ddeffd;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #1e88e5;
+}
+.header_settings_holder .progress_bar p a {
+ color: #1e88e5;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #ffa608;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #1e88e5;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #ffa608;
+}
+.header_settings_holder .tawk_chat a {
+ color: #1e88e5;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #ffa608;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #ddeffd solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #ddeffd;
+ color: #42A5F5;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #add8fb;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #42A5F5;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #1e88e5;
+}
+.spremenljivka .arrow {
+ color: #1e88e5;
+}
+.spremenljivka .arrow:hover {
+ color: #ffa608;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #42A5F5 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #42A5F5 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #42A5F5 solid;
+ border-top: 2px #42A5F5 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #ddeffd;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #ddeffd solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #1e88e5;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #1e88e5 solid;
+ background-color: #ddeffd;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #42A5F5 solid;
+ background-color: #ddeffd;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #1e88e5;
+}
+button.record_foto::before {
+ color: #1e88e5;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #ffa608;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #ffa608;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #1e88e5;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #ffa608;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #1e88e5 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #1e88e5 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #42A5F5;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #42A5F5 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #ddeffd;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #1e88e5;
+ border: 1px solid #1e88e5;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #ffa608;
+ border: 1px solid #ffa608;
+}
+div.buttons input.prev {
+ color: #1e88e5;
+ background-color: #fff;
+ border: 1px solid #1e88e5;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #1e88e5;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #ddeffd solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #42A5F5;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #0965ae;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #42A5F5;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/*# sourceMappingURL=1kaBlue.css.map */
diff --git a/main/survey/skins/1kaGreen.css b/main/survey/skins/1kaGreen.css
new file mode 100644
index 0000000..10b97fb
--- /dev/null
+++ b/main/survey/skins/1kaGreen.css
@@ -0,0 +1,529 @@
+/*
+ Default tema ankete - 1ka - Zelena barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #2e7d3a solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #2e7d3a;
+ text-align: center;
+ border-bottom: 1px solid #e2f2e2;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #2e7d3a;
+}
+.header_settings_holder .progress_bar p a {
+ color: #2e7d3a;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #43b554;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #2e7d3a;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #43b554;
+}
+.header_settings_holder .tawk_chat a {
+ color: #2e7d3a;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #43b554;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #e2f2e2 solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #e2f2e2;
+ color: #66bb6a;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #bee2c0;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #66bb6a;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #2e7d3a;
+}
+.spremenljivka .arrow {
+ color: #2e7d3a;
+}
+.spremenljivka .arrow:hover {
+ color: #43b554;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #66bb6a solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #66bb6a solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #66bb6a solid;
+ border-top: 2px #66bb6a solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #e2f2e2;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #e2f2e2 solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #2e7d3a;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #2e7d3a solid;
+ background-color: #e2f2e2;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #66bb6a solid;
+ background-color: #e2f2e2;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #2e7d3a;
+}
+button.record_foto::before {
+ color: #2e7d3a;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #43b554;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #43b554;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #2e7d3a;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #43b554;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #2e7d3a !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #2e7d3a !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #66bb6a;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #66bb6a transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #e2f2e2;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #2e7d3a;
+ border: 1px solid #2e7d3a;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #43b554;
+ border: 1px solid #43b554;
+}
+div.buttons input.prev {
+ color: #2e7d3a;
+ background-color: #fff;
+ border: 1px solid #2e7d3a;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #2e7d3a;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #e2f2e2 solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #66bb6a;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #327035;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #66bb6a;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/*# sourceMappingURL=1kaGreen.css.map */
diff --git a/main/survey/skins/1kaGrey.css b/main/survey/skins/1kaGrey.css
new file mode 100644
index 0000000..7a981e1
--- /dev/null
+++ b/main/survey/skins/1kaGrey.css
@@ -0,0 +1,442 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+
+ color: #455a64;
+ font-size: 100%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+
+ background: #ffffff;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+
+ background: #ffffff url('1ka/header_new2.png') top left repeat-x;
+}
+#container {
+ position: relative;
+
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ font-size: 13px;
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ /*margin: 0px auto 70px;*/
+ margin: 0px auto 30px;
+ /*padding: 36px 0 20px 0;*/
+ padding: 110px 0 40px 0;
+
+ font-size: 26px;
+ color: #0c377a;
+ text-align: center;
+
+ border-bottom: 1px solid #dfe2e7;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 20px;
+ /*top: 28px;*/
+ top: 13px;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#logo a{
+ width: 80px;
+ height: 46px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+
+ font-size: 11px;
+ color: #6D87AF;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #0C377A;
+}
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 10px 2px 35px 12px !important;
+
+ border-bottom: 1px #dfe2e7 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 16px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+ color: #a0aec1;
+}
+
+.spremenljivka .counter{
+ font-size: 16px;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+
+div.variable_holder thead {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td{
+ padding: 10px 5px;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #EFF2F7;
+}
+table.grid_table td {
+ padding: 7px 10px;
+}
+
+/* ranking */
+.dropzone{
+ border-top: 1px #dfe2e7 solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+table.ranking_table ul{
+ margin-top: 19px;
+}
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving{
+ font-size: 13px;
+ padding: 7px 10px 9px;
+
+ border: 2px solid #0c377a;
+ background-color: #ffffff;
+ border-radius: 2px 2px !important;
+}
+div.variable_holder .frame_ranking_hover{
+ border: 2px #0c377a solid;
+ background-color: #eff2f7;
+ border-radius: 2px 2px !important;
+}
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover{
+ text-indent: -35px;
+
+ border: 2px #a0aec1 solid;
+ background-color: #eff2f7;
+ border-radius: 2px 2px !important;
+}
+table.ranking_table b{
+ font-size: 13px;
+ font-weight: 600;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input[type="text"], textarea, select{
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px #9fa2a7 solid;
+ background-color: #fff;
+}
+
+/* Koledar */
+.ui-datepicker{
+ font-size: 14px;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip{
+ color: #455a64;
+}
+.grupa .spremenljivka .slider.ui-widget-content{
+ background-color: #a0aec1 !important;
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal{
+ height: 13px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 3px;
+
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #0c377a !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active{
+ background-color: #0c377a !important;
+}
+.grupa .spremenljivka .sliderText{
+ padding-top: 2px;
+
+ color: white;
+
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after{
+ border-color: #a0aec1 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+
+ background-color: #eff2f7;
+
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 15px;
+
+ text-align: center;
+ /*font-size: 15px;*/
+ font-size: 15px;
+ font-weight: bold;
+ color: #FFFFFF;
+
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #0c377a;
+ border: 1px solid #0c377a;
+}
+div.buttons input.next:hover {
+ background-color: #fe8333;
+ border: 1px solid #fe8333;
+}
+div.buttons input.prev {
+ color: #0c377a;
+ background-color: #eff2f7;
+ border: 1px solid #dfe2e7;
+}
+div.buttons input.prev:hover {
+ color: #eff2f7;
+ background-color: #0c377a;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 30px;
+
+ background-color: #ffffff;
+ border-top: 5px #eff2f7 solid;
+}
+#footer_survey p,
+#footer_survey a,
+#footer_survey a:visited {
+ color: #455a64;
+ font-size: 12px;
+ font-weight: 600;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+
+/* awesome radio in checkboxi */
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before{
+ color: #3D5F95;
+}
+
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right{
+ top: -9px!important;
+ left: -12px!important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_box_right{
+ top: 19px!important;
+ left: -12px!important;
+}
+
+.drag_and_drop_box_right_after_refresh{
+ /*top: 44px!important;*/
+ left: -12px!important;
+}
+
+.drag_and_drop_box_right_over{
+ left: -12px!important;
+}
+
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+} \ No newline at end of file
diff --git a/main/survey/skins/1kaNature.css b/main/survey/skins/1kaNature.css
new file mode 100644
index 0000000..7103d81
--- /dev/null
+++ b/main/survey/skins/1kaNature.css
@@ -0,0 +1,564 @@
+/*
+ Tema ankete - 1ka Nature - Modra barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #1e88e5 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #505050;
+ text-align: center;
+ border-bottom: 1px solid #ddeffd;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #1e88e5;
+}
+.header_settings_holder .progress_bar p a {
+ color: #1e88e5;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #ffa608;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #1e88e5;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #ffa608;
+}
+.header_settings_holder .tawk_chat a {
+ color: #1e88e5;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #ffa608;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #ddeffd solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #ddeffd;
+ color: #42A5F5;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #add8fb;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #42A5F5;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #1e88e5;
+}
+.spremenljivka .arrow {
+ color: #1e88e5;
+}
+.spremenljivka .arrow:hover {
+ color: #ffa608;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #42A5F5 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #42A5F5 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #42A5F5 solid;
+ border-top: 2px #42A5F5 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #ddeffd;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #ddeffd solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #1e88e5;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #1e88e5 solid;
+ background-color: #ddeffd;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #42A5F5 solid;
+ background-color: #ddeffd;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #1e88e5;
+}
+button.record_foto::before {
+ color: #1e88e5;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #ffa608;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #ffa608;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #1e88e5;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #ffa608;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #1e88e5 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #1e88e5 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #42A5F5;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #42A5F5 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #ddeffd;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #1e88e5;
+ border: 1px solid #1e88e5;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #ffa608;
+ border: 1px solid #ffa608;
+}
+div.buttons input.prev {
+ color: #1e88e5;
+ background-color: #fff;
+ border: 1px solid #1e88e5;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #1e88e5;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #ddeffd solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #42A5F5;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #0965ae;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #42A5F5;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+html {
+ background-repeat: no-repeat;
+ background-attachment: fixed;
+ background-size: cover;
+}
+html body {
+ background: none !important;
+}
+html body #outercontainer {
+ max-width: 1100px;
+ margin: 70px auto 70px auto;
+ padding: 50px 50px 20px 50px;
+ background-color: #fff;
+ opacity: 0.95;
+}
+html body #outercontainer .outercontainer_header {
+ display: none;
+}
+html body #outercontainer h1 {
+ margin: 10px 0 0 30px;
+ text-align: left;
+ font-size: 50px;
+ line-height: 50px;
+ font-weight: 300;
+ border: 0;
+}
+html body #outercontainer #logo {
+ left: 30px;
+ top: 20px;
+}
+html body #outercontainer .header_settings_holder {
+ right: 30px;
+ top: 10px;
+}
+
+/*# sourceMappingURL=1kaNature.css.map */
diff --git a/main/survey/skins/1kaNature/bg1.jpg b/main/survey/skins/1kaNature/bg1.jpg
new file mode 100644
index 0000000..4c9cede
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg1.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg10.jpg b/main/survey/skins/1kaNature/bg10.jpg
new file mode 100644
index 0000000..a8454c4
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg10.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg11.jpg b/main/survey/skins/1kaNature/bg11.jpg
new file mode 100644
index 0000000..dfe8e95
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg11.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg12.jpg b/main/survey/skins/1kaNature/bg12.jpg
new file mode 100644
index 0000000..2a3a946
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg12.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg13.jpg b/main/survey/skins/1kaNature/bg13.jpg
new file mode 100644
index 0000000..2d6a71d
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg13.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg14.jpg b/main/survey/skins/1kaNature/bg14.jpg
new file mode 100644
index 0000000..65bddc0
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg14.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg15.jpg b/main/survey/skins/1kaNature/bg15.jpg
new file mode 100644
index 0000000..e0fba5a
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg15.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg2.jpg b/main/survey/skins/1kaNature/bg2.jpg
new file mode 100644
index 0000000..f3555b1
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg2.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg3.jpg b/main/survey/skins/1kaNature/bg3.jpg
new file mode 100644
index 0000000..8d0bce1
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg3.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg4.jpg b/main/survey/skins/1kaNature/bg4.jpg
new file mode 100644
index 0000000..7800cce
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg4.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg5.jpg b/main/survey/skins/1kaNature/bg5.jpg
new file mode 100644
index 0000000..bd581b3
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg5.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg6.jpg b/main/survey/skins/1kaNature/bg6.jpg
new file mode 100644
index 0000000..ba13b04
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg6.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg7.jpg b/main/survey/skins/1kaNature/bg7.jpg
new file mode 100644
index 0000000..a1d70ac
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg7.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg8.jpg b/main/survey/skins/1kaNature/bg8.jpg
new file mode 100644
index 0000000..6609c75
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg8.jpg
Binary files differ
diff --git a/main/survey/skins/1kaNature/bg9.jpg b/main/survey/skins/1kaNature/bg9.jpg
new file mode 100644
index 0000000..b9732d4
--- /dev/null
+++ b/main/survey/skins/1kaNature/bg9.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice.css b/main/survey/skins/1kaOffice.css
new file mode 100644
index 0000000..d15f058
--- /dev/null
+++ b/main/survey/skins/1kaOffice.css
@@ -0,0 +1,564 @@
+/*
+ Tema ankete - 1ka Urban - Modra barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #1e88e5 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #505050;
+ text-align: center;
+ border-bottom: 1px solid #ddeffd;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #1e88e5;
+}
+.header_settings_holder .progress_bar p a {
+ color: #1e88e5;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #ffa608;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #1e88e5;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #ffa608;
+}
+.header_settings_holder .tawk_chat a {
+ color: #1e88e5;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #ffa608;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #ddeffd solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #ddeffd;
+ color: #42A5F5;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #add8fb;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #42A5F5;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #1e88e5;
+}
+.spremenljivka .arrow {
+ color: #1e88e5;
+}
+.spremenljivka .arrow:hover {
+ color: #ffa608;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #42A5F5 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #42A5F5 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #42A5F5 solid;
+ border-top: 2px #42A5F5 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #ddeffd;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #ddeffd solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #1e88e5;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #1e88e5 solid;
+ background-color: #ddeffd;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #42A5F5 solid;
+ background-color: #ddeffd;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #1e88e5;
+}
+button.record_foto::before {
+ color: #1e88e5;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #ffa608;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #ffa608;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #1e88e5;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #ffa608;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #1e88e5 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #1e88e5 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #42A5F5;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #42A5F5 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #ddeffd;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #1e88e5;
+ border: 1px solid #1e88e5;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #ffa608;
+ border: 1px solid #ffa608;
+}
+div.buttons input.prev {
+ color: #1e88e5;
+ background-color: #fff;
+ border: 1px solid #1e88e5;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #1e88e5;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #ddeffd solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #42A5F5;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #0965ae;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #42A5F5;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+html {
+ background-repeat: no-repeat;
+ background-attachment: fixed;
+ background-size: cover;
+}
+html body {
+ background: none !important;
+}
+html body #outercontainer {
+ max-width: 1100px;
+ margin: 70px auto 70px auto;
+ padding: 50px 50px 20px 50px;
+ background-color: #fff;
+ opacity: 0.95;
+}
+html body #outercontainer .outercontainer_header {
+ display: none;
+}
+html body #outercontainer h1 {
+ margin: 10px 0 0 30px;
+ text-align: left;
+ font-size: 50px;
+ line-height: 50px;
+ font-weight: 300;
+ border: 0;
+}
+html body #outercontainer #logo {
+ left: 30px;
+ top: 20px;
+}
+html body #outercontainer .header_settings_holder {
+ right: 30px;
+ top: 10px;
+}
+
+/*# sourceMappingURL=1kaOffice.css.map */
diff --git a/main/survey/skins/1kaOffice/bg1.jpg b/main/survey/skins/1kaOffice/bg1.jpg
new file mode 100644
index 0000000..2912d42
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg1.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg10.jpg b/main/survey/skins/1kaOffice/bg10.jpg
new file mode 100644
index 0000000..3e8b217
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg10.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg11.jpg b/main/survey/skins/1kaOffice/bg11.jpg
new file mode 100644
index 0000000..7776ed4
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg11.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg12.jpg b/main/survey/skins/1kaOffice/bg12.jpg
new file mode 100644
index 0000000..51e8b1f
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg12.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg13.jpg b/main/survey/skins/1kaOffice/bg13.jpg
new file mode 100644
index 0000000..ee26971
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg13.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg14.jpg b/main/survey/skins/1kaOffice/bg14.jpg
new file mode 100644
index 0000000..c07bc6f
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg14.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg15.jpg b/main/survey/skins/1kaOffice/bg15.jpg
new file mode 100644
index 0000000..6a7761b
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg15.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg2.jpg b/main/survey/skins/1kaOffice/bg2.jpg
new file mode 100644
index 0000000..c967bdd
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg2.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg3.jpg b/main/survey/skins/1kaOffice/bg3.jpg
new file mode 100644
index 0000000..103ea04
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg3.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg4.jpg b/main/survey/skins/1kaOffice/bg4.jpg
new file mode 100644
index 0000000..3b4599e
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg4.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg5.jpg b/main/survey/skins/1kaOffice/bg5.jpg
new file mode 100644
index 0000000..d61cb27
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg5.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg6.jpg b/main/survey/skins/1kaOffice/bg6.jpg
new file mode 100644
index 0000000..e4b5ed3
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg6.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg7.jpg b/main/survey/skins/1kaOffice/bg7.jpg
new file mode 100644
index 0000000..6ec3293
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg7.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg8.jpg b/main/survey/skins/1kaOffice/bg8.jpg
new file mode 100644
index 0000000..66cb5c1
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg8.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOffice/bg9.jpg b/main/survey/skins/1kaOffice/bg9.jpg
new file mode 100644
index 0000000..d6d6077
--- /dev/null
+++ b/main/survey/skins/1kaOffice/bg9.jpg
Binary files differ
diff --git a/main/survey/skins/1kaOrange.css b/main/survey/skins/1kaOrange.css
new file mode 100644
index 0000000..5d1792c
--- /dev/null
+++ b/main/survey/skins/1kaOrange.css
@@ -0,0 +1,529 @@
+/*
+ Default tema ankete - 1ka - Oranzna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #ef6c00 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #ef6c00;
+ text-align: center;
+ border-bottom: 1px solid #ffe9c9;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #ef6c00;
+}
+.header_settings_holder .progress_bar p a {
+ color: #ef6c00;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #ff943d;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #ef6c00;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #ff943d;
+}
+.header_settings_holder .tawk_chat a {
+ color: #ef6c00;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #ff943d;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #ffe9c9 solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #ffe9c9;
+ color: #ffa726;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #ffd596;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #ffa726;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #ef6c00;
+}
+.spremenljivka .arrow {
+ color: #ef6c00;
+}
+.spremenljivka .arrow:hover {
+ color: #ff943d;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #ffa726 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #ffa726 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #ffa726 solid;
+ border-top: 2px #ffa726 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #ffe9c9;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #ffe9c9 solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #ef6c00;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #ef6c00 solid;
+ background-color: #ffe9c9;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #ffa726 solid;
+ background-color: #ffe9c9;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #ef6c00;
+}
+button.record_foto::before {
+ color: #ef6c00;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #ff943d;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #ff943d;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #ef6c00;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #ff943d;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #ef6c00 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #ef6c00 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #ffa726;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #ffa726 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #ffe9c9;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #ef6c00;
+ border: 1px solid #ef6c00;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #ff943d;
+ border: 1px solid #ff943d;
+}
+div.buttons input.prev {
+ color: #ef6c00;
+ background-color: #fff;
+ border: 1px solid #ef6c00;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #ef6c00;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #ffe9c9 solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #ffa726;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #a66200;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #ffa726;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/*# sourceMappingURL=1kaOrange.css.map */
diff --git a/main/survey/skins/1kaPurple.css b/main/survey/skins/1kaPurple.css
new file mode 100644
index 0000000..d2c62e3
--- /dev/null
+++ b/main/survey/skins/1kaPurple.css
@@ -0,0 +1,529 @@
+/*
+ Default tema ankete - 1ka - Vijolicna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #4527a0 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #4527a0;
+ text-align: center;
+ border-bottom: 1px solid #e3daf2;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #4527a0;
+}
+.header_settings_holder .progress_bar p a {
+ color: #4527a0;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #6642d1;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #4527a0;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #6642d1;
+}
+.header_settings_holder .tawk_chat a {
+ color: #4527a0;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #6642d1;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #e3daf2 solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #e3daf2;
+ color: #7e57c2;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #c6b5e4;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #7e57c2;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #4527a0;
+}
+.spremenljivka .arrow {
+ color: #4527a0;
+}
+.spremenljivka .arrow:hover {
+ color: #6642d1;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #7e57c2 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #7e57c2 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #7e57c2 solid;
+ border-top: 2px #7e57c2 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #e3daf2;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #e3daf2 solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #4527a0;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #4527a0 solid;
+ background-color: #e3daf2;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #7e57c2 solid;
+ background-color: #e3daf2;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #4527a0;
+}
+button.record_foto::before {
+ color: #4527a0;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #6642d1;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #6642d1;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #4527a0;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #6642d1;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #4527a0 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #4527a0 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #7e57c2;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #7e57c2 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #e3daf2;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #4527a0;
+ border: 1px solid #4527a0;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #6642d1;
+ border: 1px solid #6642d1;
+}
+div.buttons input.prev {
+ color: #4527a0;
+ background-color: #fff;
+ border: 1px solid #4527a0;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #4527a0;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #e3daf2 solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #7e57c2;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #432971;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #7e57c2;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/*# sourceMappingURL=1kaPurple.css.map */
diff --git a/main/survey/skins/1kaRed.css b/main/survey/skins/1kaRed.css
new file mode 100644
index 0000000..7a68f3a
--- /dev/null
+++ b/main/survey/skins/1kaRed.css
@@ -0,0 +1,529 @@
+/*
+ Default tema ankete - 1ka - Rdeca barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #c62828 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #c62828;
+ text-align: center;
+ border-bottom: 1px solid #fde6e6;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #c62828;
+}
+.header_settings_holder .progress_bar p a {
+ color: #c62828;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #de5c5c;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #c62828;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #de5c5c;
+}
+.header_settings_holder .tawk_chat a {
+ color: #c62828;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #de5c5c;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #fde6e6 solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #fde6e6;
+ color: #ef5350;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #f8b8b7;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #ef5350;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #c62828;
+}
+.spremenljivka .arrow {
+ color: #c62828;
+}
+.spremenljivka .arrow:hover {
+ color: #de5c5c;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #ef5350 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #ef5350 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #ef5350 solid;
+ border-top: 2px #ef5350 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #fde6e6;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #fde6e6 solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #c62828;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #c62828 solid;
+ background-color: #fde6e6;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #ef5350 solid;
+ background-color: #fde6e6;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #c62828;
+}
+button.record_foto::before {
+ color: #c62828;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #de5c5c;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #de5c5c;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #c62828;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #de5c5c;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #c62828 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #c62828 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #ef5350;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #ef5350 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #fde6e6;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #c62828;
+ border: 1px solid #c62828;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #de5c5c;
+ border: 1px solid #de5c5c;
+}
+div.buttons input.prev {
+ color: #c62828;
+ background-color: #fff;
+ border: 1px solid #c62828;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #c62828;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #fde6e6 solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #ef5350;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #af1310;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #ef5350;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/*# sourceMappingURL=1kaRed.css.map */
diff --git a/main/survey/skins/1ka_customsortables.css b/main/survey/skins/1ka_customsortables.css
new file mode 100644
index 0000000..e56b500
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables.css
@@ -0,0 +1,286 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+
+ background: #eff2f7;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+
+ background: #ffffff url('1ka/header.png') top left repeat-x;
+}
+#container {
+ position: relative;
+
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 130px 0 0 0;
+
+ font-size: 22px;
+ color: #0c377a;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 20px;
+ top: 24px;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#logo a{
+ width: 80px;
+ height: 46px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+
+ font-size: 11px;
+ color: #6D87AF;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #0C377A;
+}
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+
+ border-top: 1px #B9C5D9 solid;
+
+ /*box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
+ -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);*/
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 16px;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+.spremenljivka .counter{
+ font-size: 16px;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #EFF2F7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #EFF2F7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #CED7E4;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+input[type="text"], textarea, select{
+ padding: 2px 4px;
+ background: #fff;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 6px 8px;
+
+ text-align: center;
+ /*font-size: 15px;*/
+ font-size: 13px;
+ font-weight: bold;
+ color: #FFFFFF;
+
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #3D5F95;
+ border: 1px solid #3D5F95;
+}
+div.buttons input.next:hover {
+ background-color: #fe8333;
+ border: 1px solid #fe8333;
+}
+div.buttons input.prev {
+ color: #3D5F95;
+ background-color: #ffffff;
+ border: 1px solid #3D5F95;
+}
+div.buttons input.prev:hover {
+ color: #FFFFFF;
+ background-color: #3D5F95;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+
+ background-color: #eff2f7;
+ border-top: 1px #b9c5d9 solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #6d87af;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+/* awesome radio in checkboxi */
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before{
+ color: #3D5F95;
+}
+
+
+
+
+.ranking, .ranking_long, .handle, .handle_long, .ime, .izbran {
+ width: 350px;
+ padding: 5px;
+ margin: 0 auto 10px auto;
+ border: 1px solid #000000;
+ height: 85px !important;
+ text-align: center;
+ overflow: hidden;
+ background-color: #ffffff;
+}
+
+.ranking img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.ranking, .ranking_long {
+ cursor: pointer;
+ overflow: hidden;
+ text-overflow: none !important;
+ white-space: normal !important;
+
+}
+.ranking br, .ranking_long br {
+ display: none;
+
+} \ No newline at end of file
diff --git a/main/survey/skins/1ka_customsortables/close.png b/main/survey/skins/1ka_customsortables/close.png
new file mode 100644
index 0000000..9eefd77
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/close.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/header.png b/main/survey/skins/1ka_customsortables/header.png
new file mode 100644
index 0000000..76babc7
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/header.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/header_new.png b/main/survey/skins/1ka_customsortables/header_new.png
new file mode 100644
index 0000000..4b1a281
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/header_new.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/header_new2.png b/main/survey/skins/1ka_customsortables/header_new2.png
new file mode 100644
index 0000000..0a369ad
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/header_new2.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/logo.png b/main/survey/skins/1ka_customsortables/logo.png
new file mode 100644
index 0000000..310467c
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/logo.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/logo_full.png b/main/survey/skins/1ka_customsortables/logo_full.png
new file mode 100644
index 0000000..f37ea54
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/logo_full.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/logo_full_ang.png b/main/survey/skins/1ka_customsortables/logo_full_ang.png
new file mode 100644
index 0000000..efc8be7
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/logo_full_ang.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/logo_full_old.png b/main/survey/skins/1ka_customsortables/logo_full_old.png
new file mode 100644
index 0000000..784522a
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/logo_full_old.png
Binary files differ
diff --git a/main/survey/skins/1ka_customsortables/plus.png b/main/survey/skins/1ka_customsortables/plus.png
new file mode 100644
index 0000000..ab385ca
--- /dev/null
+++ b/main/survey/skins/1ka_customsortables/plus.png
Binary files differ
diff --git a/main/survey/skins/Classic.css b/main/survey/skins/Classic.css
new file mode 100644
index 0000000..41a550f
--- /dev/null
+++ b/main/survey/skins/Classic.css
@@ -0,0 +1,243 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+
+ background:url(Classic/resna-1-top.png) left top repeat-x;
+ background-attachment: local;
+}
+#container {
+ position:relative;
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 130px 0 0 0;
+ font-size: 22px;
+ color: #000;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 20px;
+}
+#logo.english{
+}
+#logo a{
+ width:211px;
+ height:47px;
+ padding:10px;
+ background:#fff url(1ka/logo_full.png) no-repeat 10px 10px;
+ -webkit-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ border:1px solid #CCC;
+}
+#logo.english a{
+ background:#fff url(1ka/logo_full_ang.png) no-repeat 10px 10px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #ccc;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.next:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+div.buttons input.prev {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.prev:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #ebebea;
+ border-top: 1px #b1b1b1 solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+#container { width:760px;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+#container { width:280px;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+#container { width:480px;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Classic2.css b/main/survey/skins/Classic2.css
new file mode 100644
index 0000000..1bb8aae
--- /dev/null
+++ b/main/survey/skins/Classic2.css
@@ -0,0 +1,244 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+
+ background:url(Classic/resna-2-top.png) left top repeat-x;
+ background-attachment: local;
+}
+#container {
+ position:relative;
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 130px 0 0 0;
+ font-size: 22px;
+ color: #000;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 13px;
+}
+#logo.english{
+}
+#logo a{
+ width:211px;
+ height:47px;
+ padding:10px;
+ background:#fff url(1ka/logo_full.png) no-repeat 10px 10px;
+ -webkit-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ border:1px solid #CCC;
+}
+#logo.english a{
+ background:#fff url(1ka/logo_full_ang.png) no-repeat 10px 10px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #ccc;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #eff2f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #eff2f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #0c377a;
+ border: 1px solid #939191;
+ color:#fff;
+}
+div.buttons input.next:hover {
+ background-color: #3c67aa;
+ border: 1px solid #000000;
+ color:#fff;
+}
+div.buttons input.prev {
+ background-color: #0c377a;
+ border: 1px solid #939191;
+ color:#fff;
+}
+div.buttons input.prev:hover {
+ background-color: #3c67aa;
+ border: 1px solid #000000;
+ color:#fff;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #ebebea;
+ border-top: 1px #b1b1b1 solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+#container { width:760px;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+#container { width:280px;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+#container { width:480px;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Classic3.css b/main/survey/skins/Classic3.css
new file mode 100644
index 0000000..6146f4e
--- /dev/null
+++ b/main/survey/skins/Classic3.css
@@ -0,0 +1,239 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+ background:url(Classic/resna-3-top.png) center top no-repeat;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+ padding-top:120px;
+}
+#container {
+ position:relative;
+ width: 100%;
+ width: 980px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 130px 0 0 0;
+ font-size: 22px;
+ color: #000;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ width:100%;
+}
+#logo.english{
+}
+#logo a{
+ text-align:center;
+ margin:-80px auto 0 auto;
+ width:80px;
+ height:62px;
+ background:#fff url(1ka/logo_full.png) no-repeat 20px 10px;
+}
+#logo.english a{
+ width:80px;
+ height:62px;
+ background:#fff url(1ka/logo_full_ang.png) no-repeat 20px 10px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #ccc;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #eff2f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #eff2f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.next:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+div.buttons input.prev {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.prev:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #ebebea;
+ border-top: 1px #b1b1b1 solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+#container { width:760px;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+#container { width:280px;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+#container { width:480px;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Classic4.css b/main/survey/skins/Classic4.css
new file mode 100644
index 0000000..00057f7
--- /dev/null
+++ b/main/survey/skins/Classic4.css
@@ -0,0 +1,240 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+ background:url(Classic/resna-4-top.png) center top repeat-x;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#container {
+ position:relative;
+ width: 100%;
+ width: 980px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 80px 0 0 0;
+ font-size: 22px;
+ color: #000;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 20px;
+}
+#logo.english{
+}
+#logo a{
+ width:211px;
+ height:47px;
+ padding:10px;
+ background:#fff url(1ka/logo_full.png) no-repeat 10px 10px;
+ -webkit-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ border:1px solid #CCC;
+}
+#logo.english a{
+ background:#fff url(1ka/logo_full_ang.png) no-repeat 10px 10px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 20px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #ccc;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.next:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+div.buttons input.prev {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.prev:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #ebebea;
+ border-top: 1px #b1b1b1 solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+#container { width:760px;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+#container { width:280px;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+#container { width:480px;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Classic5.css b/main/survey/skins/Classic5.css
new file mode 100644
index 0000000..c9e5e55
--- /dev/null
+++ b/main/survey/skins/Classic5.css
@@ -0,0 +1,242 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+
+ background:url(Classic/resna-5-top.png) center top repeat-x;
+ background-attachment: local;
+}
+#container {
+ position:relative;
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin:0px;
+ padding: 130px 0 0 0;
+ font-size: 22px;
+ color: #000;
+ text-align: right;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 20px;
+}
+#logo.english{
+}
+#logo a{
+ width:211px;
+ height:47px;
+ padding:10px;
+ background:#fff url(1ka/logo_full.png) no-repeat 10px 10px;
+ -webkit-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.2);
+ border:1px solid #CCC;
+}
+#logo.english a{
+ background:#fff url(1ka/logo_full_ang.png) no-repeat 10px 10px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #ccc;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.next:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+div.buttons input.prev {
+ background-color: #fff;
+ border: 1px solid #949391;
+ color:#000;
+}
+div.buttons input.prev:hover {
+ background-color: #f7f7f7;
+ border: 1px solid #222;
+ color:#000;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #ebebea;
+ border-top: 1px #b1b1b1 solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+#container { width:760px;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+#container { width:280px;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+#container { width:480px;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Colorful.css b/main/survey/skins/Colorful.css
new file mode 100644
index 0000000..860ed80
--- /dev/null
+++ b/main/survey/skins/Colorful.css
@@ -0,0 +1,127 @@
+/* 1KA default theme */
+
+body {
+ color: #333;
+ font-size: 75%;
+ background: none repeat scroll 0 0 #4E4E4E;
+ font-family: Arial,Verdana,Sans-Serif;
+ margin-top: 0;
+}
+
+textarea, input, select {
+ margin: 0 4px;
+}
+
+#outercontainer {
+ width: 100%;
+ max-width: 980px;
+ margin: 0 auto;
+}
+
+#container {
+ position: relative;
+/* background: url("1KA/logo_transparent.png") no-repeat scroll right top #596ED5; */
+ background-color: #596ED5;
+border: 1px solid black;
+ border-radius: 10px 10px 10px 10px;
+ margin: 10px auto;
+}
+
+/*#logo {
+ background: url("Default/logo_transparent.png") no-repeat scroll 100% 0 transparent;
+ top: 14px;
+ right: 10px;
+}
+#logo a {
+ width: 103px;
+ height: 60px;
+}*/
+#logo {
+ top: 20px;
+ margin-right: 10px;
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 100% 0 transparent;
+ background-position: 20px 4px;
+ background-repeat: no-repeat;
+}
+#logo.english{
+ top: 24px;
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 100% 0 transparent;
+}
+#logo a{
+ width: 80px;
+ height: 46px;
+}
+
+h1 {
+ color: white;
+ font-size: 170%;
+ font-weight: 100;
+ margin: 30pt 0 20pt;
+ text-align: center;
+}
+
+#admin_options {
+ left: 20px;
+ position: fixed;
+}
+#preview {
+ border: 3px solid #596ED5;
+ border-radius: 5px 5px 5px 5px;
+ background-color: #f6f6f6;
+}
+
+#progress_bar {
+ right: auto;
+ left: 20px;
+ top: 33px;
+}
+#progress_bar span {
+ color: #000;
+}
+#progress_bar div {
+ border: 1px solid #000;
+}
+#progress_bar div span {
+ background-color: #fff;
+}
+
+div.grupa {
+ background-color: white;
+ border-bottom: 1px solid #999999;
+ border-top: 1px solid #999999;
+ margin: 10px auto ;
+ padding: 0 2px;
+}
+
+div.spremenljivka {
+ background-color: white;
+ border-bottom: 1px solid #999999;
+ margin: 20px 10px;
+ padding: 0 2px 20px 12px;
+}
+div.variable_holder {
+ margin: 0;
+ padding: 0 30px;
+}
+
+span.reminder {
+ left: 4px;
+}
+
+div.buttons {
+ padding: 25px 20px;
+}
+div.buttons input {
+ padding: 0 10px;
+}
+
+#footer_survey {
+ padding: 25px 20px;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #333;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+} \ No newline at end of file
diff --git a/main/survey/skins/Default.css b/main/survey/skins/Default.css
new file mode 100644
index 0000000..cb4061a
--- /dev/null
+++ b/main/survey/skins/Default.css
@@ -0,0 +1,92 @@
+/* 1KA default theme */
+
+body {
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, sans-serif;
+}
+
+#outercontainer {
+ width: 100%;
+ max-width: 980px;
+ margin: 0 auto;
+}
+
+#container {
+ position: relative;
+ margin-top: 30px;
+}
+
+h1 {
+ padding: 70px 0 50px 0;
+ font-size: 170%;
+ color: #0C377A;
+}
+
+#admin_options {
+ left: 20px;
+ position: fixed;
+}
+#preview {
+ border: 3px solid red;
+ border-radius: 5px 5px 5px 5px;
+ background-color: #f6f6f6;
+}
+
+/*Dodano iz 1ka skina */
+
+#logo {
+ margin-right: 10px;
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 100% 0 transparent;
+ background-position: 20px 4px;
+ background-repeat: no-repeat;
+}
+#logo.english{
+ top: 24px;
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 100% 0 transparent;
+}
+#logo a{
+ width: 80px;
+ height: 46px;
+ }
+
+/*Do tukaj*/
+
+#progress_bar {
+ right: auto;
+ left: 20px;
+ border-top: 1px solid #777;
+ border-bottom: 1px solid #777;
+ padding: 3px 6px;
+}
+#progress_bar div {
+ border: 1px solid #777;
+}
+#progress_bar div span {
+ background-color: #c2e1e7;
+}
+
+div.grupa {
+ border-top: 1px solid #ccc;
+}
+
+div.spremenljivka {
+ padding: 25px 20px;
+ border-bottom: 1px solid #999;
+}
+
+div.buttons {
+ padding: 25px 20px;
+ border-bottom: 1px solid #ccc;
+}
+div.buttons input {
+ padding: 0 10px;
+}
+
+#footer_survey {
+ padding: 25px 20px;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #333;
+}
+
diff --git a/main/survey/skins/Embed.css b/main/survey/skins/Embed.css
new file mode 100644
index 0000000..f253df1
--- /dev/null
+++ b/main/survey/skins/Embed.css
@@ -0,0 +1,64 @@
+/* 1KA default theme */
+
+body {
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, sans-serif;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0;
+}
+
+#container {
+ position: relative;
+}
+
+h1 {
+ font-size: 130%;
+}
+#logo {
+ display: none;
+}
+
+
+#progress_bar {
+ right: auto;
+ left: 20px;
+ top: 10px;
+}
+#progress_bar div {
+ border: 1px solid #777;
+}
+#progress_bar div span {
+ background-color: #c2e1e7;
+}
+
+div.grupa {
+ border-top: 1px solid #ccc;
+}
+
+div.spremenljivka {
+ padding: 25px 20px;
+ border-bottom: 1px solid #999;
+}
+
+div.buttons {
+ padding: 15px 10px;
+ border-bottom: 1px solid #ccc;
+}
+div.buttons input {
+ padding: 0 10px;
+}
+
+#footer_survey {
+ padding: 15px 10px;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #333;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+} \ No newline at end of file
diff --git a/main/survey/skins/Embed2.css b/main/survey/skins/Embed2.css
new file mode 100644
index 0000000..15dfe7f
--- /dev/null
+++ b/main/survey/skins/Embed2.css
@@ -0,0 +1,72 @@
+body {
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, sans-serif;
+}
+
+#outercontainer {
+ width: 380px;
+ margin: 10px auto;
+ padding: 0 10px;
+
+ border: 2px solid #999999;
+ -moz-border-radius:15px;
+ border-radius: 15px;
+ -webkit-border-radius: 15px;
+}
+
+#container {
+ position: relative;
+}
+
+h1 {
+ font-size: 130%;
+}
+#logo {
+ display: none;
+}
+
+
+#progress_bar {
+ right: auto;
+ left: 20px;
+ top: 10px;
+}
+#progress_bar div {
+ border: 1px solid #777;
+}
+#progress_bar div span {
+ background-color: #c2e1e7;
+}
+
+div.grupa {
+ /*border-top: 1px solid #ccc;*/
+}
+
+div.spremenljivka {
+ padding: 25px 20px;
+ border-bottom: 1px solid #999;
+}
+
+div.buttons {
+ padding: 15px 10px;
+ border-bottom: 1px solid #ccc;
+}
+div.buttons input {
+ padding: 0 10px;
+}
+
+#footer_survey {
+ padding: 15px 10px;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #333;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+#progress_bar{
+ display: none;
+} \ No newline at end of file
diff --git a/main/survey/skins/Fdv.css b/main/survey/skins/Fdv.css
new file mode 100644
index 0000000..05b140c
--- /dev/null
+++ b/main/survey/skins/Fdv.css
@@ -0,0 +1,534 @@
+/*
+ FDV tema - Siva barva z logotipom
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #666666 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #666666;
+ text-align: center;
+ border-bottom: 1px solid #eeeeee;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #666666;
+}
+.header_settings_holder .progress_bar p a {
+ color: #666666;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #8c8c8c;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #666666;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #8c8c8c;
+}
+.header_settings_holder .tawk_chat a {
+ color: #666666;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #8c8c8c;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #eeeeee solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #eeeeee;
+ color: #888888;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #d5d5d5;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #888888;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #666666;
+}
+.spremenljivka .arrow {
+ color: #666666;
+}
+.spremenljivka .arrow:hover {
+ color: #8c8c8c;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #888888 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #888888 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #888888 solid;
+ border-top: 2px #888888 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #eeeeee;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #eeeeee solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #666666;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #666666 solid;
+ background-color: #eeeeee;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #888888 solid;
+ background-color: #eeeeee;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #666666;
+}
+button.record_foto::before {
+ color: #666666;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #8c8c8c;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #8c8c8c;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #666666;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #8c8c8c;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #666666 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #666666 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #888888;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #888888 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #eeeeee;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #666666;
+ border: 1px solid #666666;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #8c8c8c;
+ border: 1px solid #8c8c8c;
+}
+div.buttons input.prev {
+ color: #666666;
+ background-color: #fff;
+ border: 1px solid #666666;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #666666;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #eeeeee solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #888888;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #484848;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #888888;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/* Popravimo se logo */
+#logo, #logo.english {
+ background-image: url("../../../public/img/logo/fdv.png");
+}
+
+/*# sourceMappingURL=Fdv.css.map */
diff --git a/main/survey/skins/Mobile.css b/main/survey/skins/Mobile.css
new file mode 100644
index 0000000..0729bb8
--- /dev/null
+++ b/main/survey/skins/Mobile.css
@@ -0,0 +1,220 @@
+body{
+ padding: 0px;
+
+ font-family: 'Bree Serif', serif !important;
+ font-size: 13px;
+ color: #455a64;
+
+ background-color: white;
+}
+
+span, label{
+ color: #455a64;
+}
+
+
+/* GLAVNI ELEMENTI */
+#container{
+ margin-top: 0px;
+}
+
+#container h1{
+ padding: 18px 5px 22px 5px;
+ margin-bottom: 10px;
+
+ font-size: 23px;
+ font-weight: normal;
+ color: #0c377a;
+ line-height: 30px;
+
+ background-color: #eff2f7;
+ border-bottom: 8px #0c377a solid;
+}
+
+
+/* INPUT ELEMENTI */
+.grupa .spremenljivka input[type=text]{
+ padding: 5px 7px;
+
+ border: 1px #a0aec1 solid;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before {
+ color: #0c377a;
+}
+
+
+.grupa{
+ min-height: 100px;
+ padding-top: 0px;
+}
+.grupa .spremenljivka{
+ margin: 0 10px;
+
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #a0aec1 solid;
+}
+.grupa .spremenljivka:last-of-type{
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov{
+ margin: 0;
+ padding: 5px 0 10px 0;
+
+ font-size: 15px;
+ font-weight: normal;
+ color: #455a64;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info{
+ font-size: 11px;
+ color: #a0aec1;
+}
+
+.variable_holder{
+ border: 0;
+}
+.variable_holder .variabla{
+ font-weight: normal;
+ color: #455a64;
+}
+table thead {
+ font-weight: normal;
+}
+
+.grupa .spremenljivka .sequence_number{
+ padding: 2px 7px 5px 7px;
+
+ background-color: #a0aec1;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.grupa .spremenljivka .sequence_number.active{
+ background-color: #dbe8f9;
+ color: #a0aec1;
+}
+
+.grupa .spremenljivka .slider_mobile{
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal{
+ height: 7px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 3px;
+
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #0c377a;
+}
+.grupa .spremenljivka .ui-slider-handle:active{
+ background-color: #0c377a;
+}
+.grupa .spremenljivka .sliderText{
+ padding-top: 0;
+
+ color: white;
+
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after{
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka span.reminder {
+ left: 0;
+}
+
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons{
+ margin-top: 20px;
+ margin-bottom: 10px;
+}
+.buttons .prev,
+.buttons .next{
+ cursor: pointer;
+
+ padding: 5px 10px;
+ margin-left: 5px;
+ margin-right: 5px;
+
+ font-size: 14px;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.buttons .prev{
+ background-color: #eff2f7;
+ color: #455a64;
+}
+.buttons .next{
+ background-color: #0c377a;
+}
+
+
+/* FOOTER */
+#footer_survey{
+ font-size: 12px;
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+
+ border-top: 3px #0c377a solid;
+}
+#footer_survey a{
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+}
+
+
+/* LOGO */
+#container #logo{
+ display: none !important;
+}
+#footer_survey #logo {
+ display: block;
+ position: relative;
+
+ width: 80px;
+ height: 46px;
+
+ margin: 10px auto 20px auto;
+ left: 0;
+ right: 0;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#footer_survey #logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#footer_survey #logo a {
+ display: block;
+ width: 80px;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+/* Desni del samo za skine Otroci3 in Otroci4 */
+#footer_survey #logo #logo_right{
+ display: none;
+}
diff --git a/main/survey/skins/Mobile2.css b/main/survey/skins/Mobile2.css
new file mode 100644
index 0000000..a639d70
--- /dev/null
+++ b/main/survey/skins/Mobile2.css
@@ -0,0 +1,219 @@
+body{
+ padding: 0px;
+
+ font-family: 'Bree Serif', serif !important;
+ font-size: 13px;
+ color: #455a64;
+
+ background-color: white;
+}
+
+span, label{
+ color: #455a64;
+}
+
+
+/* GLAVNI ELEMENTI */
+#container{
+ margin-top: 0px;
+}
+
+#container h1{
+ padding: 18px 5px 22px 5px;
+ margin-bottom: 10px;
+
+ font-size: 23px;
+ font-weight: normal;
+ color: white;
+ line-height: 30px;
+
+ background-color: #466289;
+ border-bottom: 8px #fa6121 solid;
+}
+
+
+/* INPUT ELEMENTI */
+.grupa .spremenljivka input[type=text]{
+ padding: 5px 7px;
+
+ border: 1px #a0aec1 solid;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before {
+ color: #fa6121;
+}
+
+
+.grupa{
+ min-height: 100px;
+ padding-top: 0px;
+}
+.grupa .spremenljivka{
+ margin: 0 10px;
+
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #a0aec1 solid;
+}
+.grupa .spremenljivka:last-of-type{
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov{
+ margin: 0;
+ padding: 5px 0 10px 0;
+
+ font-size: 15px;
+ font-weight: normal;
+ color: #455a64;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info{
+ font-size: 11px;
+ color: #a0aec1;
+}
+
+.variable_holder{
+ border: 0;
+}
+.variable_holder .variabla{
+ font-weight: normal;
+ color: #455a64;
+}
+table thead {
+ font-weight: normal;
+}
+
+.grupa .spremenljivka .sequence_number{
+ padding: 2px 7px 5px 7px;
+
+ background-color: #a0aec1;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.grupa .spremenljivka .sequence_number.active{
+ background-color: #dbe8f9;
+ color: #a0aec1;
+}
+
+.grupa .spremenljivka .slider_mobile{
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal{
+ height: 7px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 3px;
+
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #fa6121;
+}
+.grupa .spremenljivka .ui-slider-handle:active{
+ background-color: #fa6121;
+}
+.grupa .spremenljivka .sliderText{
+ padding-top: 0;
+
+ color: white;
+
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after{
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka span.reminder {
+ left: 0;
+}
+
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons{
+ margin-top: 20px;
+ margin-bottom: 10px;
+}
+.buttons .prev,
+.buttons .next{
+ cursor: pointer;
+
+ padding: 5px 10px;
+ margin-left: 5px;
+ margin-right: 5px;
+
+ font-size: 14px;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.buttons .prev{
+ background-color: #a0aec1;
+}
+.buttons .next{
+ background-color: #fa6121;
+}
+
+
+/* FOOTER */
+#footer_survey{
+ font-size: 12px;
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+
+ border-top: 3px #a0aec1 solid;
+}
+#footer_survey a{
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+}
+
+
+/* LOGO */
+#container #logo{
+ display: none !important;
+}
+#footer_survey #logo {
+ display: block;
+ position: relative;
+
+ width: 80px;
+ height: 46px;
+
+ margin: 10px auto 20px auto;
+ left: 0;
+ right: 0;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#footer_survey #logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#footer_survey #logo a {
+ display: block;
+ width: 80px;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+/* Desni del samo za skine Otroci3 in Otroci4 */
+#footer_survey #logo #logo_right{
+ display: none;
+}
diff --git a/main/survey/skins/Mobile3.css b/main/survey/skins/Mobile3.css
new file mode 100644
index 0000000..29e1451
--- /dev/null
+++ b/main/survey/skins/Mobile3.css
@@ -0,0 +1,219 @@
+body{
+ padding: 0px;
+
+ font-family: 'Bree Serif', serif !important;
+ font-size: 13px;
+ color: #455a64;
+
+ background-color: white;
+}
+
+span, label{
+ color: #455a64;
+}
+
+
+/* GLAVNI ELEMENTI */
+#container{
+ margin-top: 0px;
+}
+
+#container h1{
+ padding: 18px 5px 22px 5px;
+ margin-bottom: 10px;
+
+ font-size: 23px;
+ font-weight: normal;
+ color: white;
+ line-height: 30px;
+
+ background-color: #57BC90;
+ border-bottom: 8px #77C9D4 solid;
+}
+
+
+/* INPUT ELEMENTI */
+.grupa .spremenljivka input[type=text]{
+ padding: 5px 7px;
+
+ border: 1px #a0aec1 solid;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before {
+ color: #015249;
+}
+
+
+.grupa{
+ min-height: 100px;
+ padding-top: 0px;
+}
+.grupa .spremenljivka{
+ margin: 0 10px;
+
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #a0aec1 solid;
+}
+.grupa .spremenljivka:last-of-type{
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov{
+ margin: 0;
+ padding: 5px 0 10px 0;
+
+ font-size: 15px;
+ font-weight: normal;
+ color: #455a64;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info{
+ font-size: 11px;
+ color: #a0aec1;
+}
+
+.variable_holder{
+ border: 0;
+}
+.variable_holder .variabla{
+ font-weight: normal;
+ color: #455a64;
+}
+table thead {
+ font-weight: normal;
+}
+
+.grupa .spremenljivka .sequence_number{
+ padding: 2px 7px 5px 7px;
+
+ background-color: #a0aec1;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.grupa .spremenljivka .sequence_number.active{
+ background-color: #dbe8f9;
+ color: #a0aec1;
+}
+
+.grupa .spremenljivka .slider_mobile{
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal{
+ height: 7px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 3px;
+
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #015249;
+}
+.grupa .spremenljivka .ui-slider-handle:active{
+ background-color: #015249;
+}
+.grupa .spremenljivka .sliderText{
+ padding-top: 0;
+
+ color: white;
+
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after{
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka span.reminder {
+ left: 0;
+}
+
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons{
+ margin-top: 20px;
+ margin-bottom: 10px;
+}
+.buttons .prev,
+.buttons .next{
+ cursor: pointer;
+
+ padding: 5px 10px;
+ margin-left: 5px;
+ margin-right: 5px;
+
+ font-size: 14px;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.buttons .prev{
+ background-color: #a0aec1;
+}
+.buttons .next{
+ background-color: #015249;
+}
+
+
+/* FOOTER */
+#footer_survey{
+ font-size: 12px;
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+
+ border-top: 3px #77C9D4 solid;
+}
+#footer_survey a{
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+}
+
+
+/* LOGO */
+#container #logo{
+ display: none !important;
+}
+#footer_survey #logo {
+ display: block;
+ position: relative;
+
+ width: 80px;
+ height: 46px;
+
+ margin: 10px auto 20px auto;
+ left: 0;
+ right: 0;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#footer_survey #logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#footer_survey #logo a {
+ display: block;
+ width: 80px;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+/* Desni del samo za skine Otroci3 in Otroci4 */
+#footer_survey #logo #logo_right{
+ display: none;
+}
diff --git a/main/survey/skins/Mobile4.css b/main/survey/skins/Mobile4.css
new file mode 100644
index 0000000..75233a6
--- /dev/null
+++ b/main/survey/skins/Mobile4.css
@@ -0,0 +1,219 @@
+body{
+ padding: 0px;
+
+ font-family: 'Bree Serif', serif !important;
+ font-size: 13px;
+ color: #455a64;
+
+ background-color: white;
+}
+
+span, label{
+ color: #455a64;
+}
+
+
+/* GLAVNI ELEMENTI */
+#container{
+ margin-top: 0px;
+}
+
+#container h1{
+ padding: 18px 5px 22px 5px;
+ margin-bottom: 10px;
+
+ font-size: 23px;
+ font-weight: normal;
+ color: #FF3B3F;
+ line-height: 30px;
+
+ background-color: #CAEBF2;
+ border-bottom: 8px #FF3B3F solid;
+}
+
+
+/* INPUT ELEMENTI */
+.grupa .spremenljivka input[type=text]{
+ padding: 5px 7px;
+
+ border: 1px #a0aec1 solid;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before {
+ color: #FF3B3F;
+}
+
+
+.grupa{
+ min-height: 100px;
+ padding-top: 0px;
+}
+.grupa .spremenljivka{
+ margin: 0 10px;
+
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #a0aec1 solid;
+}
+.grupa .spremenljivka:last-of-type{
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov{
+ margin: 0;
+ padding: 5px 0 10px 0;
+
+ font-size: 15px;
+ font-weight: normal;
+ color: #455a64;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info{
+ font-size: 11px;
+ color: #a0aec1;
+}
+
+.variable_holder{
+ border: 0;
+}
+.variable_holder .variabla{
+ font-weight: normal;
+ color: #455a64;
+}
+table thead {
+ font-weight: normal;
+}
+
+.grupa .spremenljivka .sequence_number{
+ padding: 2px 7px 5px 7px;
+
+ background-color: #a0aec1;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.grupa .spremenljivka .sequence_number.active{
+ background-color: #dbe8f9;
+ color: #a0aec1;
+}
+
+.grupa .spremenljivka .slider_mobile{
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal{
+ height: 7px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 3px;
+
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #FF3B3F;
+}
+.grupa .spremenljivka .ui-slider-handle:active{
+ background-color: #FF3B3F;
+}
+.grupa .spremenljivka .sliderText{
+ padding-top: 0;
+
+ color: white;
+
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after{
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka span.reminder {
+ left: 0;
+}
+
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons{
+ margin-top: 20px;
+ margin-bottom: 10px;
+}
+.buttons .prev,
+.buttons .next{
+ cursor: pointer;
+
+ padding: 5px 10px;
+ margin-left: 5px;
+ margin-right: 5px;
+
+ font-size: 14px;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.buttons .prev{
+ background-color: #a0aec1;
+}
+.buttons .next{
+ background-color: #FF3B3F;
+}
+
+
+/* FOOTER */
+#footer_survey{
+ font-size: 12px;
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+
+ border-top: 3px #FF3B3F solid;
+}
+#footer_survey a{
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+}
+
+
+/* LOGO */
+#container #logo{
+ display: none !important;
+}
+#footer_survey #logo {
+ display: block;
+ position: relative;
+
+ width: 80px;
+ height: 46px;
+
+ margin: 10px auto 20px auto;
+ left: 0;
+ right: 0;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#footer_survey #logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#footer_survey #logo a {
+ display: block;
+ width: 80px;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+/* Desni del samo za skine Otroci3 in Otroci4 */
+#footer_survey #logo #logo_right{
+ display: none;
+}
diff --git a/main/survey/skins/Mobile5.css b/main/survey/skins/Mobile5.css
new file mode 100644
index 0000000..471f298
--- /dev/null
+++ b/main/survey/skins/Mobile5.css
@@ -0,0 +1,219 @@
+body{
+ padding: 0px;
+
+ font-family: 'Bree Serif', serif !important;
+ font-size: 13px;
+ color: #455a64;
+
+ background-color: white;
+}
+
+span, label{
+ color: #455a64;
+}
+
+
+/* GLAVNI ELEMENTI */
+#container{
+ margin-top: 0px;
+}
+
+#container h1{
+ padding: 18px 5px 22px 5px;
+ margin-bottom: 10px;
+
+ font-size: 23px;
+ font-weight: normal;
+ color: white;
+ line-height: 30px;
+
+ background-color: #76323F;
+ border-bottom: 8px #C09F80 solid;
+}
+
+
+/* INPUT ELEMENTI */
+.grupa .spremenljivka input[type=text]{
+ padding: 5px 7px;
+
+ border: 1px #a0aec1 solid;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+
+input[type="checkbox"] + span.enka-checkbox-radio,
+input[type="radio"] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before {
+ color: #565656;
+}
+
+
+.grupa{
+ min-height: 100px;
+ padding-top: 0px;
+}
+.grupa .spremenljivka{
+ margin: 0 10px;
+
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #a0aec1 solid;
+}
+.grupa .spremenljivka:last-of-type{
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov{
+ margin: 0;
+ padding: 5px 0 10px 0;
+
+ font-size: 15px;
+ font-weight: normal;
+ color: #455a64;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info{
+ font-size: 11px;
+ color: #a0aec1;
+}
+
+.variable_holder{
+ border: 0;
+}
+.variable_holder .variabla{
+ font-weight: normal;
+ color: #455a64;
+}
+table thead {
+ font-weight: normal;
+}
+
+.grupa .spremenljivka .sequence_number{
+ padding: 2px 7px 5px 7px;
+
+ background-color: #a0aec1;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.grupa .spremenljivka .sequence_number.active{
+ background-color: #dbe8f9;
+ color: #a0aec1;
+}
+
+.grupa .spremenljivka .slider_mobile{
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal{
+ height: 7px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 3px;
+
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #565656;
+}
+.grupa .spremenljivka .ui-slider-handle:active{
+ background-color: #565656;
+}
+.grupa .spremenljivka .sliderText{
+ padding-top: 0;
+
+ color: white;
+
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after{
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka span.reminder {
+ left: 0;
+}
+
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons{
+ margin-top: 20px;
+ margin-bottom: 10px;
+}
+.buttons .prev,
+.buttons .next{
+ cursor: pointer;
+
+ padding: 5px 10px;
+ margin-left: 5px;
+ margin-right: 5px;
+
+ font-size: 14px;
+ color: white;
+
+ border: 0;
+ border-radius: 3px;
+ -moz-border-radius: 3px 3px 3px 3px;
+ -webkit-border-radius: 3px;
+}
+.buttons .prev{
+ background-color: #C09F80;
+}
+.buttons .next{
+ background-color: #565656;
+}
+
+
+/* FOOTER */
+#footer_survey{
+ font-size: 12px;
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+
+ border-top: 3px #C09F80 solid;
+}
+#footer_survey a{
+ font-weight: normal;
+ text-decoration: none;
+ color: #455a64;
+}
+
+
+/* LOGO */
+#container #logo{
+ display: none !important;
+}
+#footer_survey #logo {
+ display: block;
+ position: relative;
+
+ width: 80px;
+ height: 46px;
+
+ margin: 10px auto 20px auto;
+ left: 0;
+ right: 0;
+
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 0 0 transparent;
+ background-repeat: no-repeat;
+}
+#footer_survey #logo.english{
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 0 0 transparent;
+}
+#footer_survey #logo a {
+ display: block;
+ width: 80px;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+/* Desni del samo za skine Otroci3 in Otroci4 */
+#footer_survey #logo #logo_right{
+ display: none;
+}
diff --git a/main/survey/skins/MobileBlack.css b/main/survey/skins/MobileBlack.css
new file mode 100644
index 0000000..33c9a26
--- /dev/null
+++ b/main/survey/skins/MobileBlack.css
@@ -0,0 +1,228 @@
+@charset "UTF-8";
+/*
+ Mobile tema ankete - Črna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #333333;
+ background-color: #ffffff;
+ border-bottom: 8px #333333 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #444444;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #444444 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #eaeaea;
+ color: #444444;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #d0d0d0;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #444444;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #333333 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #333333 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #eaeaea dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #333333;
+}
+button.ui-datepicker-trigger:hover {
+ color: #595959;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #333333;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #595959;
+}
+.header_settings_holder .tawk_chat a {
+ color: #333333;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #595959;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #444444 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #333333;
+ border: 1px solid #333333;
+}
+.buttons input.next:hover {
+ background-color: #595959;
+ border: 1px solid #595959;
+}
+.buttons input.prev {
+ color: #333333;
+ background-color: #fff;
+ border: 1px solid #333333;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #333333;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #333333 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/*# sourceMappingURL=MobileBlack.css.map */
diff --git a/main/survey/skins/MobileBlue.css b/main/survey/skins/MobileBlue.css
new file mode 100644
index 0000000..980420a
--- /dev/null
+++ b/main/survey/skins/MobileBlue.css
@@ -0,0 +1,227 @@
+/*
+ Mobile tema ankete - Modra barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #1e88e5;
+ background-color: #ffffff;
+ border-bottom: 8px #1e88e5 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #42A5F5;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #42A5F5 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #ddeffd;
+ color: #42A5F5;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #add8fb;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #42A5F5;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #1e88e5 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #1e88e5 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #ddeffd dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #1e88e5;
+}
+button.ui-datepicker-trigger:hover {
+ color: #ffa608;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #1e88e5;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #ffa608;
+}
+.header_settings_holder .tawk_chat a {
+ color: #1e88e5;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #ffa608;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #42A5F5 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #1e88e5;
+ border: 1px solid #1e88e5;
+}
+.buttons input.next:hover {
+ background-color: #ffa608;
+ border: 1px solid #ffa608;
+}
+.buttons input.prev {
+ color: #1e88e5;
+ background-color: #fff;
+ border: 1px solid #1e88e5;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #1e88e5;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #1e88e5 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/*# sourceMappingURL=MobileBlue.css.map */
diff --git a/main/survey/skins/MobileCdi.css b/main/survey/skins/MobileCdi.css
new file mode 100644
index 0000000..81973d6
--- /dev/null
+++ b/main/survey/skins/MobileCdi.css
@@ -0,0 +1,237 @@
+@charset "UTF-8";
+/*
+ Mobile tema ankete - Črna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #666666;
+ background-color: #ffffff;
+ border-bottom: 8px #666666 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #888888;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #888888 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #eeeeee;
+ color: #888888;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #d5d5d5;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #888888;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #666666 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #666666 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #eeeeee dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #666666;
+}
+button.ui-datepicker-trigger:hover {
+ color: #8c8c8c;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #666666;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #8c8c8c;
+}
+.header_settings_holder .tawk_chat a {
+ color: #666666;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #8c8c8c;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #888888 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #666666;
+ border: 1px solid #666666;
+}
+.buttons input.next:hover {
+ background-color: #8c8c8c;
+ border: 1px solid #8c8c8c;
+}
+.buttons input.prev {
+ color: #666666;
+ background-color: #fff;
+ border: 1px solid #666666;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #666666;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #666666 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/* Popravimo se logo */
+#footer_survey #logo {
+ background-image: url("../../../public/img/logo/cdi_slo.png");
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/cdi_eng.png");
+}
+
+/*# sourceMappingURL=MobileCdi.css.map */
diff --git a/main/survey/skins/MobileFdv.css b/main/survey/skins/MobileFdv.css
new file mode 100644
index 0000000..d206d11
--- /dev/null
+++ b/main/survey/skins/MobileFdv.css
@@ -0,0 +1,233 @@
+@charset "UTF-8";
+/*
+ Mobile tema ankete - Črna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #666666;
+ background-color: #ffffff;
+ border-bottom: 8px #666666 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #888888;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #888888 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #eeeeee;
+ color: #888888;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #d5d5d5;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #888888;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #666666 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #666666 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #eeeeee dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #666666;
+}
+button.ui-datepicker-trigger:hover {
+ color: #8c8c8c;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #666666;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #8c8c8c;
+}
+.header_settings_holder .tawk_chat a {
+ color: #666666;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #8c8c8c;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #888888 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #666666;
+ border: 1px solid #666666;
+}
+.buttons input.next:hover {
+ background-color: #8c8c8c;
+ border: 1px solid #8c8c8c;
+}
+.buttons input.prev {
+ color: #666666;
+ background-color: #fff;
+ border: 1px solid #666666;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #666666;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #666666 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/* Popravimo se logo */
+#footer_survey #logo {
+ background-image: url("../../../public/img/logo/fdv.png");
+}
+
+/*# sourceMappingURL=MobileFdv.css.map */
diff --git a/main/survey/skins/MobileGreen.css b/main/survey/skins/MobileGreen.css
new file mode 100644
index 0000000..6ef6572
--- /dev/null
+++ b/main/survey/skins/MobileGreen.css
@@ -0,0 +1,227 @@
+/*
+ Mobile tema ankete - Zelena barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #2e7d3a;
+ background-color: #ffffff;
+ border-bottom: 8px #2e7d3a solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #66bb6a;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #66bb6a solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #e2f2e2;
+ color: #66bb6a;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #bee2c0;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #66bb6a;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #2e7d3a !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #2e7d3a !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #e2f2e2 dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #2e7d3a;
+}
+button.ui-datepicker-trigger:hover {
+ color: #43b554;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #2e7d3a;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #43b554;
+}
+.header_settings_holder .tawk_chat a {
+ color: #2e7d3a;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #43b554;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #66bb6a solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #2e7d3a;
+ border: 1px solid #2e7d3a;
+}
+.buttons input.next:hover {
+ background-color: #43b554;
+ border: 1px solid #43b554;
+}
+.buttons input.prev {
+ color: #2e7d3a;
+ background-color: #fff;
+ border: 1px solid #2e7d3a;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #2e7d3a;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #2e7d3a solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/*# sourceMappingURL=MobileGreen.css.map */
diff --git a/main/survey/skins/MobileOrange.css b/main/survey/skins/MobileOrange.css
new file mode 100644
index 0000000..37c26a1
--- /dev/null
+++ b/main/survey/skins/MobileOrange.css
@@ -0,0 +1,227 @@
+/*
+ Mobile tema ankete - Ornazna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #ef6c00;
+ background-color: #ffffff;
+ border-bottom: 8px #ef6c00 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #ffa726;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #ffa726 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #ffe9c9;
+ color: #ffa726;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #ffd596;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #ffa726;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #ef6c00 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #ef6c00 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #ffe9c9 dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #ef6c00;
+}
+button.ui-datepicker-trigger:hover {
+ color: #ff943d;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #ef6c00;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #ff943d;
+}
+.header_settings_holder .tawk_chat a {
+ color: #ef6c00;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #ff943d;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #ffa726 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #ef6c00;
+ border: 1px solid #ef6c00;
+}
+.buttons input.next:hover {
+ background-color: #ff943d;
+ border: 1px solid #ff943d;
+}
+.buttons input.prev {
+ color: #ef6c00;
+ background-color: #fff;
+ border: 1px solid #ef6c00;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #ef6c00;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #ef6c00 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/*# sourceMappingURL=MobileOrange.css.map */
diff --git a/main/survey/skins/MobilePurple.css b/main/survey/skins/MobilePurple.css
new file mode 100644
index 0000000..c25c8db
--- /dev/null
+++ b/main/survey/skins/MobilePurple.css
@@ -0,0 +1,228 @@
+@charset "UTF-8";
+/*
+ Mobile tema ankete - Vijolična barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #4527a0;
+ background-color: #ffffff;
+ border-bottom: 8px #4527a0 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #7e57c2;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #7e57c2 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #e3daf2;
+ color: #7e57c2;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #c6b5e4;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #7e57c2;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #4527a0 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #4527a0 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #e3daf2 dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #4527a0;
+}
+button.ui-datepicker-trigger:hover {
+ color: #6642d1;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #4527a0;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #6642d1;
+}
+.header_settings_holder .tawk_chat a {
+ color: #4527a0;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #6642d1;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #7e57c2 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #4527a0;
+ border: 1px solid #4527a0;
+}
+.buttons input.next:hover {
+ background-color: #6642d1;
+ border: 1px solid #6642d1;
+}
+.buttons input.prev {
+ color: #4527a0;
+ background-color: #fff;
+ border: 1px solid #4527a0;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #4527a0;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #4527a0 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/*# sourceMappingURL=MobilePurple.css.map */
diff --git a/main/survey/skins/MobileRed.css b/main/survey/skins/MobileRed.css
new file mode 100644
index 0000000..c05ed57
--- /dev/null
+++ b/main/survey/skins/MobileRed.css
@@ -0,0 +1,228 @@
+@charset "UTF-8";
+/*
+ Mobile tema ankete - Rdeča barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #c62828;
+ background-color: #ffffff;
+ border-bottom: 8px #c62828 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #ef5350;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #ef5350 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #fde6e6;
+ color: #ef5350;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #f8b8b7;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #ef5350;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #c62828 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #c62828 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #fde6e6 dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #c62828;
+}
+button.ui-datepicker-trigger:hover {
+ color: #de5c5c;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #c62828;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #de5c5c;
+}
+.header_settings_holder .tawk_chat a {
+ color: #c62828;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #de5c5c;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #ef5350 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #c62828;
+ border: 1px solid #c62828;
+}
+.buttons input.next:hover {
+ background-color: #de5c5c;
+ border: 1px solid #de5c5c;
+}
+.buttons input.prev {
+ color: #c62828;
+ background-color: #fff;
+ border: 1px solid #c62828;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #c62828;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #c62828 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/*# sourceMappingURL=MobileRed.css.map */
diff --git a/main/survey/skins/MobileUni.css b/main/survey/skins/MobileUni.css
new file mode 100644
index 0000000..d7f4af8
--- /dev/null
+++ b/main/survey/skins/MobileUni.css
@@ -0,0 +1,233 @@
+@charset "UTF-8";
+/*
+ Mobile tema ankete - Črna barva
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna mobilna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ color: #505050;
+ background-color: white;
+}
+
+span, label {
+ color: #505050;
+}
+
+/* GLAVNI ELEMENTI */
+#container h1 {
+ color: #666666;
+ background-color: #ffffff;
+ border-bottom: 8px #666666 solid;
+}
+
+/* INPUT ELEMENTI */
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 5px 7px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #888888;
+}
+
+.grupa .spremenljivka {
+ background-color: white;
+ border: 0;
+ border-bottom: 1px #888888 solid;
+ /* Mejnik pri dvojni tabeli */
+}
+.grupa .spremenljivka:last-of-type {
+ border-bottom: 0;
+}
+.grupa .spremenljivka .naslov {
+ color: #505050;
+}
+.grupa .spremenljivka .naslov .spremenljivka_info {
+ color: #505050;
+}
+.grupa .spremenljivka .sequence_number {
+ background-color: #eeeeee;
+ color: #888888;
+}
+.grupa .spremenljivka .sequence_number:hover {
+ background-color: #d5d5d5;
+}
+.grupa .spremenljivka .sequence_number.active {
+ background-color: #888888;
+ color: #ffffff;
+}
+.grupa .spremenljivka .slider_mobile {
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #666666 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #666666 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 0;
+ color: white;
+ background-color: #a0aec1;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #a0aec1 transparent;
+}
+.grupa .spremenljivka .grid_mobile .grid_mobile_question {
+ padding-top: 15px;
+ border-top: 1px #b4b5b7 solid;
+}
+.grupa .spremenljivka .grid_mobile > div:first-child {
+ padding-top: 0 !important;
+ border-top: 0 !important;
+}
+.grupa .spremenljivka .grid_mobile_double_separator {
+ width: 100%;
+ height: 5px;
+ border-top: 1px #eeeeee dashed;
+}
+
+.variable_holder .variabla {
+ color: #505050;
+}
+
+/* Koledar */
+button.ui-datepicker-trigger {
+ color: #666666;
+}
+button.ui-datepicker-trigger:hover {
+ color: #8c8c8c;
+}
+
+/* Opcija nadaljuj kasneje */
+.header_settings_holder .continue_later_setting a {
+ color: #666666;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #8c8c8c;
+}
+.header_settings_holder .tawk_chat a {
+ color: #666666;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #8c8c8c;
+}
+
+/* GUMBI NAPREJ/NAZAJ */
+.buttons {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ padding-top: 10px;
+ border-top: 1px #888888 solid !important;
+}
+.buttons input {
+ cursor: pointer;
+ margin: 8px 5px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 15px;
+ letter-spacing: 0px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ -moz-border-radius: 20px 20px 20px 20px;
+ -webkit-border-radius: 20px;
+ border: 0;
+}
+.buttons input.next {
+ background-color: #666666;
+ border: 1px solid #666666;
+}
+.buttons input.next:hover {
+ background-color: #8c8c8c;
+ border: 1px solid #8c8c8c;
+}
+.buttons input.prev {
+ color: #666666;
+ background-color: #fff;
+ border: 1px solid #666666;
+}
+.buttons input.prev:hover {
+ color: #fff;
+ background-color: #666666;
+}
+
+/* FOOTER */
+#footer_survey {
+ color: #505050;
+ border-top: 3px #666666 solid;
+}
+#footer_survey a {
+ font-weight: normal;
+ text-decoration: none;
+ color: #505050;
+}
+
+/* LOGO */
+#container #logo {
+ display: none !important;
+}
+
+#footer_survey #logo {
+ display: block;
+ position: relative;
+ width: 100%;
+ height: 40px;
+ margin: 10px auto 30px auto;
+ left: 0;
+ right: 0;
+ background-image: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat;
+ background-size: auto 100% !important;
+ background-position: center;
+ /* Desni del samo za skine Otroci3 in Otroci4 */
+}
+#footer_survey #logo a {
+ display: block;
+ width: 100%;
+ height: 46px;
+ text-indent: -9999px;
+ overflow: hidden;
+}
+#footer_survey #logo #logo_right {
+ display: none;
+}
+
+#footer_survey #logo.english {
+ background-image: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+/* Popravimo se logo */
+#footer_survey #logo {
+ background-image: url("../../../public/img/logo/uni.png");
+}
+
+/*# sourceMappingURL=MobileUni.css.map */
diff --git a/main/survey/skins/Modern.css b/main/survey/skins/Modern.css
new file mode 100644
index 0000000..eff5c21
--- /dev/null
+++ b/main/survey/skins/Modern.css
@@ -0,0 +1,105 @@
+/* 1KA modern theme */
+
+body {
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ background: #f9f9f9 url('Modern/background.jpg') top left repeat-x;
+}
+
+#outercontainer {
+ width: 100%;
+ max-width: 980px;
+ margin: 0 auto;
+}
+
+#container {
+ position: relative;
+ margin-top: 30px;
+ background: none repeat scroll 0 0 #F4F4F4;
+ border: 1px solid #CCCCCC;
+ margin: 30px auto 10px;
+}
+
+h1 {
+ color: #0C377A;
+ margin: 70px auto 50px;
+ text-align: center;
+}
+
+#admin_options {
+ left: 20px;
+ position: fixed;
+}
+#preview {
+ border: 3px solid red;
+ border-radius: 5px 5px 5px 5px;
+ background-color: #f6f6f6;
+}
+
+#logo {
+ right: auto;
+ left: 20px;
+ top: 20px;
+ /*Dodano iz 1ka*/
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 100% 0 transparent;
+ background-position: 20px 4px;
+ background-repeat: no-repeat;
+ /*konec*/
+}
+#logo.english{
+ top: 24px;
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 100% 0 transparent;
+}
+#logo a{
+ width: 80px;
+ height: 46px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 20px;
+}
+#progress_bar div {
+ border: 1px solid #777;
+}
+#progress_bar div span {
+ background-color: #333;
+}
+
+
+.spremenljivka {
+ background-color: #E9E9E9;
+ margin: 10px;
+ padding: 0 2px 10px 12px;
+}
+div.variable_holder {
+ padding: 0 30px;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #eee;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+div.buttons {
+ padding: 10px 20px 35px;
+}
+div.buttons input {
+ padding: 0 5px;
+ font-size: 90%;
+}
+
+#footer_survey {
+ padding: 25px 20px;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #333;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+} \ No newline at end of file
diff --git a/main/survey/skins/Modern/add.png b/main/survey/skins/Modern/add.png
new file mode 100644
index 0000000..6332fef
--- /dev/null
+++ b/main/survey/skins/Modern/add.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrow.png b/main/survey/skins/Modern/arrow.png
new file mode 100644
index 0000000..4f8d6cc
--- /dev/null
+++ b/main/survey/skins/Modern/arrow.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowD.png b/main/survey/skins/Modern/arrowD.png
new file mode 100644
index 0000000..d7ebd4e
--- /dev/null
+++ b/main/survey/skins/Modern/arrowD.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowD2.png b/main/survey/skins/Modern/arrowD2.png
new file mode 100644
index 0000000..676b840
--- /dev/null
+++ b/main/survey/skins/Modern/arrowD2.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowL.png b/main/survey/skins/Modern/arrowL.png
new file mode 100644
index 0000000..fcf6bfe
--- /dev/null
+++ b/main/survey/skins/Modern/arrowL.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowL2.png b/main/survey/skins/Modern/arrowL2.png
new file mode 100644
index 0000000..d7dfb56
--- /dev/null
+++ b/main/survey/skins/Modern/arrowL2.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowR.png b/main/survey/skins/Modern/arrowR.png
new file mode 100644
index 0000000..68481f6
--- /dev/null
+++ b/main/survey/skins/Modern/arrowR.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowR2.png b/main/survey/skins/Modern/arrowR2.png
new file mode 100644
index 0000000..eb1b035
--- /dev/null
+++ b/main/survey/skins/Modern/arrowR2.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowU.png b/main/survey/skins/Modern/arrowU.png
new file mode 100644
index 0000000..9cf2cd8
--- /dev/null
+++ b/main/survey/skins/Modern/arrowU.png
Binary files differ
diff --git a/main/survey/skins/Modern/arrowU2.png b/main/survey/skins/Modern/arrowU2.png
new file mode 100644
index 0000000..dde25fa
--- /dev/null
+++ b/main/survey/skins/Modern/arrowU2.png
Binary files differ
diff --git a/main/survey/skins/Modern/background.jpg b/main/survey/skins/Modern/background.jpg
new file mode 100644
index 0000000..f9d4612
--- /dev/null
+++ b/main/survey/skins/Modern/background.jpg
Binary files differ
diff --git a/main/survey/skins/Modern/blue_delete.png b/main/survey/skins/Modern/blue_delete.png
new file mode 100644
index 0000000..08f2493
--- /dev/null
+++ b/main/survey/skins/Modern/blue_delete.png
Binary files differ
diff --git a/main/survey/skins/Oko.css b/main/survey/skins/Oko.css
new file mode 100644
index 0000000..2df8129
--- /dev/null
+++ b/main/survey/skins/Oko.css
@@ -0,0 +1,328 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+ background: #ffffff url('Oko/oko-1.png') top left repeat-x;
+}
+#container {
+ position: relative;
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Admin nastavitve okno pri testnih vnosih in previewju */
+#admin_options {
+ left: 20px;
+ position: fixed;
+}
+#preview_open{
+ top: 40px;
+}
+#preview_open a.close{
+ top: 13px;
+ right: 9px;
+ width: 15px;
+ height: 15px;
+
+ color: transparent;
+ background-image: url('1ka/plus.png');
+}
+
+#preview_switch{
+ top: 83px;
+ right: 13px;
+ z-index: 1000;
+
+ padding: 0 20px 7px 20px;
+
+ font-size: 11px;
+
+ border-bottom: 1px #8a9fbf dashed;
+}
+
+#preview-holder{
+ top: 45px;
+
+ font-size: 11px;
+
+ border-top: 30px #e2e4e7 solid;
+ background-color: #e8ecf2;
+}
+#preview {
+ margin: 40px 15px 10px 15px;
+ padding: 0;
+ border: 0;
+}
+#preview a.close{
+ top: -22px;
+ right: 8px;
+
+ width: 14px;
+ height: 15px;
+
+ text-indent: -9999px;
+
+ background-image: url('1ka/close.png');
+}
+#preview a, #preview_switch a, #preview-holder div span a{
+ color: #0C377A;
+ text-decoration: none;
+}
+#preview a:hover, #preview_switch a:hover, #preview-holder div span a:hover{
+ color: #fa4913;
+}
+
+#preview-holder div span.floatLeft{
+ margin-left: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+
+div.qtip-content {
+ font-size: 9px;
+}
+.qtip-wrapper, .qtip-contentWrapper{
+ border: 0 !important;
+}
+.qtip-borderTop, .qtip-borderBottom{
+ display: none !important;
+}
+.qtip-title{
+ color: #0C377A !important;
+ background-color: #D8DFEA !important;
+}
+.qtip-content{
+ padding: 12px 9px !important;
+ background-color: #f7f7f7 !important;
+ border: 1px #D8DFEA solid;
+}
+
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 130px 0 0 0;
+ font-size: 22px;
+ color: #83bb0c;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 20px;
+ background: url(Oko/oko-logo.png) no-repeat 0 0 ;
+}
+#logo.english{
+}
+#logo a{
+ width:183px;
+ height:57px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #94d60a;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #94d60a;
+ border: 1px solid #659109;
+ color:#000;
+}
+div.buttons input.next:hover {
+ background-color: #86c209;
+ border: 1px solid #94d60a;
+ color:#fff;
+}
+div.buttons input.prev {
+ background-color: #94d60a;
+ border: 1px solid #659109;
+ color:#000;
+}
+div.buttons input.prev:hover {
+ background-color: #86c209;
+ border: 1px solid #94d60a;
+ color:#fff;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #e7e5e0;
+ border-top: 3px #cecece solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+select { width:95%;}
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+select { width:95%;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+select { width:95%;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+select { width:95%;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Oko2.css b/main/survey/skins/Oko2.css
new file mode 100644
index 0000000..c509ebc
--- /dev/null
+++ b/main/survey/skins/Oko2.css
@@ -0,0 +1,328 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+ background: #ffffff url('Oko/oko-2.png') top left repeat-x;
+}
+#container {
+ position: relative;
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+}
+
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Admin nastavitve okno pri testnih vnosih in previewju */
+#admin_options {
+ left: 20px;
+ position: fixed;
+}
+#preview_open{
+ top: 40px;
+}
+#preview_open a.close{
+ top: 13px;
+ right: 9px;
+ width: 15px;
+ height: 15px;
+
+ color: transparent;
+ background-image: url('1ka/plus.png');
+}
+
+#preview_switch{
+ top: 83px;
+ right: 13px;
+ z-index: 1000;
+
+ padding: 0 20px 7px 20px;
+
+ font-size: 11px;
+
+ border-bottom: 1px #8a9fbf dashed;
+}
+
+#preview-holder{
+ top: 45px;
+
+ font-size: 11px;
+
+ border-top: 30px #e2e4e7 solid;
+ background-color: #e8ecf2;
+}
+#preview {
+ margin: 40px 15px 10px 15px;
+ padding: 0;
+ border: 0;
+}
+#preview a.close{
+ top: -22px;
+ right: 8px;
+
+ width: 14px;
+ height: 15px;
+
+ text-indent: -9999px;
+
+ background-image: url('1ka/close.png');
+}
+#preview a, #preview_switch a, #preview-holder div span a{
+ color: #0C377A;
+ text-decoration: none;
+}
+#preview a:hover, #preview_switch a:hover, #preview-holder div span a:hover{
+ color: #fa4913;
+}
+
+#preview-holder div span.floatLeft{
+ margin-left: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+
+div.qtip-content {
+ font-size: 9px;
+}
+.qtip-wrapper, .qtip-contentWrapper{
+ border: 0 !important;
+}
+.qtip-borderTop, .qtip-borderBottom{
+ display: none !important;
+}
+.qtip-title{
+ color: #0C377A !important;
+ background-color: #D8DFEA !important;
+}
+.qtip-content{
+ padding: 12px 9px !important;
+ background-color: #f7f7f7 !important;
+ border: 1px #D8DFEA solid;
+}
+
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 130px 0 0 0;
+ font-size: 22px;
+ color: #83bb0c;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 20px;
+ background: url(Oko/oko-logo.png) no-repeat 0 0 ;
+}
+#logo.english{
+}
+#logo a{
+ width:183px;
+ height:57px;
+}
+
+#progress_bar {
+ right: 20px;
+ left: auto;
+ top: 30px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #94d60a;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #94d60a;
+ border: 1px solid #659109;
+ color:#000;
+}
+div.buttons input.next:hover {
+ background-color: #86c209;
+ border: 1px solid #94d60a;
+ color:#fff;
+}
+div.buttons input.prev {
+ background-color: #94d60a;
+ border: 1px solid #659109;
+ color:#000;
+}
+div.buttons input.prev:hover {
+ background-color: #86c209;
+ border: 1px solid #94d60a;
+ color:#fff;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #e7e5e0;
+ border-top: 3px #cecece solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+select { width:95%;}
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+select { width:95%;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+select { width:95%;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+select { width:95%;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Otroci.css b/main/survey/skins/Otroci.css
new file mode 100644
index 0000000..63bf27d
--- /dev/null
+++ b/main/survey/skins/Otroci.css
@@ -0,0 +1,329 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+ background: #ffffff url('Otroci_Safe/otroci-1.png') top left repeat-x;
+}
+#container {
+ position: relative;
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+ background:url('Otroci_Safe/otroci-figure.png') top right no-repeat;
+}
+
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Admin nastavitve okno pri testnih vnosih in previewju */
+#admin_options {
+ left: 20px;
+ position: fixed;
+}
+#preview_open{
+ top: 40px;
+}
+#preview_open a.close{
+ top: 13px;
+ right: 9px;
+ width: 15px;
+ height: 15px;
+
+ color: transparent;
+ background-image: url('1ka/plus.png');
+}
+
+#preview_switch{
+ top: 83px;
+ right: 13px;
+ z-index: 1000;
+
+ padding: 0 20px 7px 20px;
+
+ font-size: 11px;
+
+ border-bottom: 1px #8a9fbf dashed;
+}
+
+#preview-holder{
+ top: 45px;
+
+ font-size: 11px;
+
+ border-top: 30px #e2e4e7 solid;
+ background-color: #e8ecf2;
+}
+#preview {
+ margin: 40px 15px 10px 15px;
+ padding: 0;
+ border: 0;
+}
+#preview a.close{
+ top: -22px;
+ right: 8px;
+
+ width: 14px;
+ height: 15px;
+
+ text-indent: -9999px;
+
+ background-image: url('1ka/close.png');
+}
+#preview a, #preview_switch a, #preview-holder div span a{
+ color: #0C377A;
+ text-decoration: none;
+}
+#preview a:hover, #preview_switch a:hover, #preview-holder div span a:hover{
+ color: #fa4913;
+}
+
+#preview-holder div span.floatLeft{
+ margin-left: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+
+div.qtip-content {
+ font-size: 9px;
+}
+.qtip-wrapper, .qtip-contentWrapper{
+ border: 0 !important;
+}
+.qtip-borderTop, .qtip-borderBottom{
+ display: none !important;
+}
+.qtip-title{
+ color: #0C377A !important;
+ background-color: #D8DFEA !important;
+}
+.qtip-content{
+ padding: 12px 9px !important;
+ background-color: #f7f7f7 !important;
+ border: 1px #D8DFEA solid;
+}
+
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 100px 0 0 0;
+ font-size: 22px;
+ color: #000;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 20px;
+ background: url(Otroci_Safe/otroci-logo.png) no-repeat 0 0 ;
+}
+#logo.english{
+}
+#logo a{
+ width:165px;
+ height:69px;
+}
+
+#progress_bar {
+ right: 210px;
+ left: auto;
+ top: 20px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #f26b16;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #ef6111;
+ border: 1px solid #dd530e;
+ color:#fff;
+}
+div.buttons input.next:hover {
+ background-color: #dd530e;
+ border: 1px solid #dd530e;
+ color:#fff;
+}
+div.buttons input.prev {
+ background-color: #ef6111;
+ border: 1px solid #dd530e;
+ color:#ffff;
+}
+div.buttons input.prev:hover {
+ background-color: #dd530e;
+ border: 1px solid #dd530e;
+ color:#fff;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #e7e5e0;
+ border-top: 3px #cecece solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+select { width:95%;}
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+select { width:95%;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+select { width:95%;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+select { width:95%;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Otroci/nadaljuj-kasneje.png b/main/survey/skins/Otroci/nadaljuj-kasneje.png
new file mode 100644
index 0000000..94c9d09
--- /dev/null
+++ b/main/survey/skins/Otroci/nadaljuj-kasneje.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-3-desno.png b/main/survey/skins/Otroci/otroci-3-desno.png
new file mode 100644
index 0000000..8692030
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-3-desno.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-3-footer.png b/main/survey/skins/Otroci/otroci-3-footer.png
new file mode 100644
index 0000000..8221bcd
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-3-footer.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-3-levo.png b/main/survey/skins/Otroci/otroci-3-levo.png
new file mode 100644
index 0000000..387e11f
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-3-levo.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-3-top.png b/main/survey/skins/Otroci/otroci-3-top.png
new file mode 100644
index 0000000..0868b5b
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-3-top.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-4-desno.png b/main/survey/skins/Otroci/otroci-4-desno.png
new file mode 100644
index 0000000..8692030
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-4-desno.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-4-footer.png b/main/survey/skins/Otroci/otroci-4-footer.png
new file mode 100644
index 0000000..71f0f70
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-4-footer.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-4-top.png b/main/survey/skins/Otroci/otroci-4-top.png
new file mode 100644
index 0000000..2bc8d2e
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-4-top.png
Binary files differ
diff --git a/main/survey/skins/Otroci/otroci-logo.png b/main/survey/skins/Otroci/otroci-logo.png
new file mode 100644
index 0000000..715f030
--- /dev/null
+++ b/main/survey/skins/Otroci/otroci-logo.png
Binary files differ
diff --git a/main/survey/skins/Otroci2.css b/main/survey/skins/Otroci2.css
new file mode 100644
index 0000000..17bc927
--- /dev/null
+++ b/main/survey/skins/Otroci2.css
@@ -0,0 +1,329 @@
+/* 1KA new default theme */
+
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Arial, Verdana, Sans-Serif;
+ font-family: Open Sans, Arial, Sans-Serif !important;
+}
+body.preview, body.testdata{
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+ background: #ffffff url('Otroci_Safe/otroci-2.png') top left repeat-x;
+}
+#container {
+ position: relative;
+ width: 100%;
+ max-width: 980px;
+ margin: 0px auto 10px;
+ background:url('Otroci_Safe/otroci-2-figure.png') top right no-repeat;
+}
+
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+
+ line-height: 25px;
+ color: #ffffff;
+
+ background-color: #fe9c5c;
+ border-bottom: 1px solid #fe9c5c;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+
+/* Admin nastavitve okno pri testnih vnosih in previewju */
+#admin_options {
+ left: 20px;
+ position: fixed;
+}
+#preview_open{
+ top: 40px;
+}
+#preview_open a.close{
+ top: 13px;
+ right: 9px;
+ width: 15px;
+ height: 15px;
+
+ color: transparent;
+ background-image: url('1ka/plus.png');
+}
+
+#preview_switch{
+ top: 83px;
+ right: 13px;
+ z-index: 1000;
+
+ padding: 0 20px 7px 20px;
+
+ font-size: 11px;
+
+ border-bottom: 1px #8a9fbf dashed;
+}
+
+#preview-holder{
+ top: 45px;
+
+ font-size: 11px;
+
+ border-top: 30px #e2e4e7 solid;
+ background-color: #e8ecf2;
+}
+#preview {
+ margin: 40px 15px 10px 15px;
+ padding: 0;
+ border: 0;
+}
+#preview a.close{
+ top: -22px;
+ right: 8px;
+
+ width: 14px;
+ height: 15px;
+
+ text-indent: -9999px;
+
+ background-image: url('1ka/close.png');
+}
+#preview a, #preview_switch a, #preview-holder div span a{
+ color: #0C377A;
+ text-decoration: none;
+}
+#preview a:hover, #preview_switch a:hover, #preview-holder div span a:hover{
+ color: #fa4913;
+}
+
+#preview-holder div span.floatLeft{
+ margin-left: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+#preview-holder div span.floatRight{
+ margin-right: 15px;
+}
+
+div.qtip-content {
+ font-size: 9px;
+}
+.qtip-wrapper, .qtip-contentWrapper{
+ border: 0 !important;
+}
+.qtip-borderTop, .qtip-borderBottom{
+ display: none !important;
+}
+.qtip-title{
+ color: #0C377A !important;
+ background-color: #D8DFEA !important;
+}
+.qtip-content{
+ padding: 12px 9px !important;
+ background-color: #f7f7f7 !important;
+ border: 1px #D8DFEA solid;
+}
+
+
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 100px 0 0 0;
+ font-size: 22px;
+ color: #000;
+ text-align: center;
+}
+h1.evalvacija{
+ margin-bottom: 0;
+}
+
+#logo {
+ left: 0px;
+ top: 20px;
+ background: url(Otroci_Safe/otroci-logo.png) no-repeat 0 0 ;
+}
+#logo.english{
+}
+#logo a{
+ width:165px;
+ height:69px;
+}
+
+#progress_bar {
+ right: 210px;
+ left: auto;
+ top: 20px;
+}
+#progress_bar span {
+ float: left !important; /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #000;
+}
+#progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+#progress_bar div span {
+ height: 10px;
+ background-color: #000;
+}
+
+#progress_bar p a {
+ color: #0C377A;
+ text-decoration: none;
+}
+#progress_bar p a:hover {
+ color: #fa4913;
+}
+
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka.limited{
+ outline: 1px #F15A24 solid;
+}
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+.spremenljivka .naslov{
+ padding-left: 5px;
+ font-size: 13px;
+ font-weight:bold;
+ color: #000;
+}
+.spremenljivka .naslov .spremenljivka_info{
+ font-size: 70%;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential{
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+
+div.variable_holder thead {
+ font-weight: 600;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+div.variable_holder .frame_ranking{
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 6px 8px;
+ text-align: center;
+ font-size: 13px;
+ color: #FFFFFF;
+ border-radius: 4px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #ef6111;
+ border: 1px solid #dd530e;
+ color:#fff;
+}
+div.buttons input.next:hover {
+ background-color: #dd530e;
+ border: 1px solid #dd530e;
+ color:#fff;
+}
+div.buttons input.prev {
+ background-color: #ef6111;
+ border: 1px solid #dd530e;
+ color:#ffff;
+}
+div.buttons input.prev:hover {
+ background-color: #dd530e;
+ border: 1px solid #dd530e;
+ color:#fff;
+}
+
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+ background-color: #e7e5e0;
+ border-top: 3px #cecece solid;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #000;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+
+select { width:95%;}
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+select { width:95%;}
+}
+
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+select { width:95%;}
+}
+
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+select { width:95%;}
+} \ No newline at end of file
diff --git a/main/survey/skins/Otroci3.css b/main/survey/skins/Otroci3.css
new file mode 100644
index 0000000..a8c1a23
--- /dev/null
+++ b/main/survey/skins/Otroci3.css
@@ -0,0 +1,309 @@
+/*
+ Tema Otroci 3
+*/
+/*$font_family: Open Sans, Arial, Sans-Serif;*/
+/* Barve */
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #b0e8ff url(Otroci/otroci-3-footer.png) left bottom repeat-x;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ padding-top: 130px;
+ margin: 0 auto;
+ min-height: 600px;
+ background: url(Otroci/otroci-3-top.png) center top no-repeat;
+}
+
+#container {
+ position: relative;
+ width: 100%;
+ width: 980px;
+ margin: 0px auto 10px;
+ background: #fff;
+ -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
+ -moz-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
+ border: 5px solid rgba(255, 255, 255, 0.5);
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 40px 0 0 0;
+ font-size: 24px;
+ color: #333;
+ text-align: center;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ position: absolute;
+ top: -120px;
+ left: -40px;
+ width: 650px;
+ height: 230px;
+ background: url(Otroci/otroci-3-levo.png) left bottom no-repeat;
+}
+#logo #logo_right {
+ display: inline;
+ position: absolute;
+ top: 102px;
+ right: -475px;
+ width: 158px;
+ height: 311px;
+ background: url(Otroci/otroci-3-desno.png) right bottom no-repeat;
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: -105px;
+ width: auto;
+ height: 110px;
+ padding-right: 150px;
+ padding-bottom: 25px;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #333;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #f26b16;
+}
+.header_settings_holder .progress_bar p a {
+ color: #ef6c00;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #ff943d;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka .naslov {
+ padding-left: 5px;
+ padding-bottom: 15px;
+ font-size: 16px;
+ font-weight: 600;
+ color: #333;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 70%;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential {
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: 600;
+}
+div.variable_holder .frame_ranking {
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #B9C5D9;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+button.ui-datepicker-trigger {
+ color: #ef6c00;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #ff943d;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #777;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #ef6c00;
+}
+button.record_foto::before {
+ color: #ef6c00;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #ff943d;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #ff943d;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #ef6c00;
+ border: 1px solid #ef6c00;
+ color: #fff;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #ff943d;
+ border: 1px solid #ff943d;
+ color: #fff;
+}
+div.buttons input.prev {
+ background-color: #fff;
+ border: 1px solid #ef6c00;
+ color: #ef6c00;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ background-color: #ef6c00;
+ border: 1px solid #ef6c00;
+ color: #fff;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #333;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+ #container {
+ width: 760px;
+ }
+
+ #logo {
+ width: 550px;
+ }
+}
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+ #container {
+ width: 280px;
+ }
+
+ #logo {
+ width: 350px;
+ }
+}
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+ #container {
+ width: 480px;
+ }
+
+ #logo {
+ width: 450px;
+ }
+}
+
+/*# sourceMappingURL=Otroci3.css.map */
diff --git a/main/survey/skins/Otroci4.css b/main/survey/skins/Otroci4.css
new file mode 100644
index 0000000..32cabe5
--- /dev/null
+++ b/main/survey/skins/Otroci4.css
@@ -0,0 +1,293 @@
+/*
+ Tema Otroci 4
+*/
+/*$font_family: Open Sans, Arial, Sans-Serif;*/
+/* Barve */
+body {
+ margin: 0;
+ padding: 0;
+ color: #333;
+ font-size: 75%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #fff url(Otroci/otroci-4-footer.png) left bottom repeat-x;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ padding-top: 130px;
+ margin: 0 auto;
+ background: url(Otroci/otroci-4-top.png) left top repeat-x;
+}
+
+#container {
+ position: relative;
+ width: 100%;
+ width: 980px;
+ margin: 0px auto 10px;
+ background: #fff;
+ -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
+ -moz-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
+ border: 5px solid rgba(255, 255, 255, 0.5);
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert, #test_alert {
+ height: 26px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a, #test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover, #test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span, #test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a, #test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 50px;
+ padding: 40px 0 0 0;
+ font-size: 24px;
+ color: #333;
+ text-align: center;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ position: absolute;
+ top: -50px;
+ left: -20px;
+}
+#logo #logo_right {
+ display: inline;
+ position: absolute;
+ top: 31px;
+ right: -125px;
+ width: 158px;
+ height: 311px;
+ background: url(Otroci/otroci-3-desno.png) right bottom no-repeat;
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: -105px;
+ width: auto;
+ height: 110px;
+ padding-right: 150px;
+ padding-bottom: 25px;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #333;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #f26b16;
+}
+.header_settings_holder .progress_bar p a {
+ color: #ef6c00;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #ff943d;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 20px 12px !important;
+ border-top: 1px #B9C5D9 solid;
+}
+.spremenljivka .naslov {
+ padding-left: 5px;
+ padding-bottom: 15px;
+ font-size: 16px;
+ font-weight: 600;
+ color: #333;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 70%;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential {
+ font-size: 13px;
+}
+
+div.variable_holder {
+ padding: 0 30px;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: 600;
+}
+div.variable_holder .frame_ranking {
+ border: 1px #B9C5D9 solid;
+ background-color: #f7f7f7;
+}
+div.variable_holder .frame_ranking_hover {
+ border: 1px #8A9FBF solid;
+ background-color: #e2e4e7;
+}
+
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #f7f7f7;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #B9C5D9;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+button.ui-datepicker-trigger {
+ color: #ef6c00;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #ff943d;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #777;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #ef6c00;
+}
+button.record_foto::before {
+ color: #ef6c00;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #ff943d;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #ff943d;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 30px 20px 35px;
+ margin: 0 10px;
+ border-top: 1px #B9C5D9 solid;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #ef6c00;
+ border: 1px solid #ef6c00;
+ color: #fff;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #ff943d;
+ border: 1px solid #ff943d;
+ color: #fff;
+}
+div.buttons input.prev {
+ background-color: #fff;
+ border: 1px solid #ef6c00;
+ color: #ef6c00;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ background-color: #ef6c00;
+ border: 1px solid #ef6c00;
+ color: #fff;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 20px;
+}
+#footer_survey a, #footer_survey a:visited {
+ color: #333;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: underline;
+}
+
+/* #Tablet (Portrait) */
+@media only screen and (min-width: 768px) and (max-width: 959px) {
+ #container {
+ width: 760px;
+ }
+}
+/* #Mobile (Portrait) */
+@media only screen and (max-width: 767px) {
+ #container {
+ width: 280px;
+ }
+}
+/* #Mobile (Landscape) */
+@media only screen and (min-width: 480px) and (max-width: 767px) {
+ #container {
+ width: 480px;
+ }
+}
+
+/*# sourceMappingURL=Otroci4.css.map */
diff --git a/main/survey/skins/Otroci_Safe/nadaljuj-kasneje.png b/main/survey/skins/Otroci_Safe/nadaljuj-kasneje.png
new file mode 100644
index 0000000..79e0956
--- /dev/null
+++ b/main/survey/skins/Otroci_Safe/nadaljuj-kasneje.png
Binary files differ
diff --git a/main/survey/skins/Otroci_Safe/otroci-1.png b/main/survey/skins/Otroci_Safe/otroci-1.png
new file mode 100644
index 0000000..ace989f
--- /dev/null
+++ b/main/survey/skins/Otroci_Safe/otroci-1.png
Binary files differ
diff --git a/main/survey/skins/Otroci_Safe/otroci-2-figure.png b/main/survey/skins/Otroci_Safe/otroci-2-figure.png
new file mode 100644
index 0000000..c06aa71
--- /dev/null
+++ b/main/survey/skins/Otroci_Safe/otroci-2-figure.png
Binary files differ
diff --git a/main/survey/skins/Otroci_Safe/otroci-2.png b/main/survey/skins/Otroci_Safe/otroci-2.png
new file mode 100644
index 0000000..40663a5
--- /dev/null
+++ b/main/survey/skins/Otroci_Safe/otroci-2.png
Binary files differ
diff --git a/main/survey/skins/Otroci_Safe/otroci-figure.png b/main/survey/skins/Otroci_Safe/otroci-figure.png
new file mode 100644
index 0000000..248a42e
--- /dev/null
+++ b/main/survey/skins/Otroci_Safe/otroci-figure.png
Binary files differ
diff --git a/main/survey/skins/Otroci_Safe/otroci-logo.png b/main/survey/skins/Otroci_Safe/otroci-logo.png
new file mode 100644
index 0000000..715f030
--- /dev/null
+++ b/main/survey/skins/Otroci_Safe/otroci-logo.png
Binary files differ
diff --git a/main/survey/skins/Slideshow.css b/main/survey/skins/Slideshow.css
new file mode 100644
index 0000000..cf287f4
--- /dev/null
+++ b/main/survey/skins/Slideshow.css
@@ -0,0 +1,111 @@
+* {
+
+ font-family: Verdana,Arial,Helvetica,sans-serif;
+}
+
+body {
+ font-size: 10pt;
+ padding: 0px !important;
+ margin: 0px !important;
+ background: white;
+ color: #333;
+}
+
+p {
+ padding: 0px !important;
+ margin: 0px !important;
+}
+
+#container {
+ width: auto;
+ background: #FFFFFF;
+ padding: 0px !important;
+ margin: 0px !important;
+ border: none !important;
+}
+
+#container h1 {
+ display:none;
+}
+
+.spremenljivka {
+ /*border: 1px solid #999;*/
+ margin: 10px 0px 10px 0px !important;
+ padding: 10px 0px 10px 0px !important;
+ background: none !important;
+}
+
+.variabla{
+ padding: 0px;
+}
+
+div.comment {
+ margin-top: 20px;
+ padding-top: 10px;
+}
+
+.embed_out{
+ display: none !important;
+}
+
+/*Dodano iz 1ka skina */
+
+#logo {
+ margin-right: 10px;
+ top: 20px;
+ background: url("../../../public/img/logo/1ka_slo.svg") no-repeat scroll 100% 0 transparent;
+ background-position: 20px 4px;
+ background-repeat: no-repeat;
+}
+#logo.english{
+ top: 24px;
+ background: url("../../../public/img/logo/1ka_eng.svg") no-repeat scroll 100% 0 transparent;
+}
+#logo a{
+ width: 80px;
+ height: 46px;
+}
+
+/*Do tukaj*/
+
+
+#progress_bar{
+ display: none !important;
+}
+
+#pdfExport {
+ display: none !important;
+}
+
+#printView {
+ display: none !important;
+}
+
+
+.grupa {
+ margin: 0px !important;
+ padding: 0px !important;
+}
+
+.grupa p {
+ margin:0px !important;
+}
+
+.fdv_di_img {
+ display: inline-block;
+ font-family: monospace;
+ font-family: Verdana,Arial,Helvetica,sans-serif;
+ font-size: 9pt;
+ font-size: 0.85em;
+ text-align: justify;
+ }
+
+.pointer {
+ cursor: pointer !important;
+}
+
+.next, .prev, .pause {
+ margin: 0px 20px !important;
+}
+
+#footer_survey {display: none} \ No newline at end of file
diff --git a/main/survey/skins/Uni.css b/main/survey/skins/Uni.css
new file mode 100644
index 0000000..182f2a0
--- /dev/null
+++ b/main/survey/skins/Uni.css
@@ -0,0 +1,534 @@
+/*
+ Uni tema - Siva barva z logotipom univerze
+*/
+/* Barve */
+/* Import osnovne postavitve */
+/*
+ Osnovna tema ankete - 1ka - brez definiranih barv
+*/
+/* Fonti */
+body {
+ margin: 0;
+ padding: 0;
+ color: #505050;
+ font-size: 100%;
+ font-family: Montserrat, Arial, Sans-Serif !important;
+ background: #ffffff;
+}
+
+body.preview, body.testdata {
+ margin-top: 26px;
+}
+
+#outercontainer {
+ width: 100%;
+ margin: 0 auto;
+}
+#outercontainer .outercontainer_header {
+ position: absolute;
+ width: 100%;
+ height: 80px;
+ border-bottom: 6px #666666 solid;
+}
+#outercontainer #container {
+ position: relative;
+ width: 100%;
+ max-width: 1200px;
+ margin: 0px auto 10px;
+}
+
+/* Warning bar (preview, cookie) */
+#cookie_alert,
+#test_alert {
+ height: 26px;
+ font-size: 15px;
+ line-height: 25px;
+ color: #ffffff;
+ background-color: #ffa608;
+ border-bottom: 1px solid #ffa608;
+}
+#cookie_alert a,
+#test_alert a {
+ text-decoration: none;
+ font-weight: bold;
+ color: #ffffff;
+}
+#cookie_alert a:hover,
+#test_alert a:hover {
+ text-decoration: underline;
+}
+#cookie_alert span,
+#test_alert span {
+ color: #ffffff;
+}
+#cookie_alert span a,
+#test_alert span a {
+ color: #ffffff;
+ font-weight: normal;
+}
+
+/* Header - logo, naslov, progressbar */
+h1 {
+ margin: 0px auto 30px;
+ padding: 120px 0 50px 0;
+ font-size: 28px;
+ color: #666666;
+ text-align: center;
+ border-bottom: 1px solid #eeeeee;
+}
+
+h1.evalvacija {
+ margin-bottom: 0;
+}
+
+#logo {
+ right: auto;
+ left: 25px;
+ top: 13px;
+ max-height: 56px !important;
+ background: url("../../../public/img/logo/1ka_slo.svg");
+ background-repeat: no-repeat !important;
+ background-size: auto 100% !important;
+}
+#logo a {
+ width: 250px;
+ height: 56px;
+}
+
+#logo.english {
+ background: url("../../../public/img/logo/1ka_eng.svg");
+}
+
+.header_settings_holder {
+ top: 0px;
+ right: 20px;
+ left: auto;
+}
+.header_settings_holder .progress_bar span {
+ float: left !important;
+ /* ie6,7 doesnt support inline-block */
+ display: block;
+ width: 20px;
+ font-size: 11px;
+ color: #6D87AF;
+}
+.header_settings_holder .progress_bar div {
+ height: 10px;
+ width: 130px;
+ padding: 2px;
+ margin: 0 5px;
+ border: 1px #cccccc solid;
+ background-color: #ffffff;
+}
+.header_settings_holder .progress_bar div span {
+ height: 10px;
+ background-color: #666666;
+}
+.header_settings_holder .progress_bar p a {
+ color: #666666;
+ text-decoration: none;
+}
+.header_settings_holder .progress_bar p a:hover {
+ color: #8c8c8c;
+}
+.header_settings_holder .continue_later_setting a {
+ color: #666666;
+}
+.header_settings_holder .continue_later_setting a:hover {
+ color: #8c8c8c;
+}
+.header_settings_holder .tawk_chat a {
+ color: #666666;
+}
+.header_settings_holder .tawk_chat a:hover {
+ color: #8c8c8c;
+}
+
+/* Spremenljivke */
+.spremenljivka {
+ margin: 20px 10px 20px 10px;
+ padding: 20px 2px 50px 12px !important;
+ border-bottom: 1px #eeeeee solid;
+}
+.spremenljivka .naslov {
+ padding: 5px 0 15px 5px;
+ font-size: 18px;
+ font-weight: 600;
+}
+.spremenljivka .naslov .spremenljivka_info {
+ font-size: 14px;
+ font-weight: 400;
+ padding-top: 7px;
+}
+.spremenljivka .sequence_number {
+ background-color: #eeeeee;
+ color: #888888;
+}
+.spremenljivka .sequence_number:hover {
+ background-color: #d5d5d5;
+}
+.spremenljivka .sequence_number.active {
+ background-color: #888888;
+ color: #ffffff;
+}
+.spremenljivka .counter {
+ font-size: 18px;
+}
+.spremenljivka #dynamic_count {
+ color: #666666;
+}
+.spremenljivka .arrow {
+ color: #666666;
+}
+.spremenljivka .arrow:hover {
+ color: #8c8c8c;
+}
+
+.spremenljivka.limited {
+ outline: 1px #F15A24 solid;
+}
+
+.required, .required_require, .required_limit {
+ outline: 1px #F15A24 solid;
+}
+
+div.variabla,
+td.variabla,
+td.question,
+td.differential,
+.variabla_sum label {
+ font-size: 14px;
+}
+
+div.variable_holder {
+ padding: 10px 0 0 0;
+}
+div.variable_holder thead,
+div.variable_holder tr.table-header {
+ font-weight: normal;
+ font-size: 14px;
+}
+div.variable_holder thead td,
+div.variable_holder tr.table-header td {
+ padding: 10px 5px;
+}
+
+table.grid_table thead tr td {
+ border-bottom: 2px #888888 solid;
+}
+table.grid_table thead tr.middle_row td {
+ border-top: 2px #888888 solid;
+}
+table.grid_table tbody tr.table-header td {
+ border-bottom: 2px #888888 solid;
+ border-top: 2px #888888 solid;
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n+1) {
+ background-color: #ffffff;
+}
+table.grid_table tbody tr:nth-child(2n) {
+ background-color: #eeeeee;
+}
+table.grid_table td {
+ padding: 10px 10px;
+}
+
+span.reminder {
+ left: 3px;
+}
+
+/* Textboxi, textarea, select */
+input, textarea, select {
+ font-family: Montserrat, Arial, Sans-Serif !important;
+}
+
+input[type=text], textarea, select {
+ padding: 10px 15px;
+ border-radius: 3px;
+ border: 1px solid #d1d1d1;
+ border-radius: 3px;
+ background-color: #fff;
+}
+
+/* ranking */
+.dropzone {
+ border-top: 1px #eeeeee solid;
+ margin-top: 12px;
+ padding-top: 17px;
+}
+
+table.ranking_table ul {
+ margin-top: 19px;
+}
+
+.ranking,
+.ranking_long,
+.handle,
+.handle_long,
+.ime,
+.izbran,
+.frame_ranking,
+.frame_ranking_hover,
+.frame_dropping,
+.frame_dropping_hover,
+.frame_moving {
+ font-size: 13px;
+ padding: 7px 10px 9px;
+ border: 2px solid #666666;
+ background-color: #ffffff;
+}
+
+.ranking:hover {
+ background-color: #f5fafe;
+}
+
+div.variable_holder .frame_ranking_hover {
+ border: 2px #666666 solid;
+ background-color: #eeeeee;
+}
+
+div.variable_holder .frame_ranking,
+div.variable_holder .frame_moving,
+div.variable_holder .frame_dropping,
+div.variable_holder .frame_dropping_hover {
+ text-indent: -35px;
+ border: 2px #888888 solid;
+ background-color: #eeeeee;
+}
+
+table.ranking_table b {
+ font-size: 13px;
+ font-weight: 600;
+}
+
+/* Photo upload button */
+button.record_foto {
+ border: 2px solid #666666;
+}
+button.record_foto::before {
+ color: #666666;
+}
+button.record_foto:hover, button.record_foto:focus {
+ border-color: #8c8c8c;
+}
+button.record_foto:hover::before, button.record_foto:focus::before {
+ color: #8c8c8c;
+}
+
+/* Koledar */
+.ui-datepicker {
+ font-size: 14px;
+}
+
+button.ui-datepicker-trigger {
+ color: #666666;
+}
+button.ui-datepicker-trigger:hover, button.ui-datepicker-trigger:focus {
+ color: #8c8c8c;
+}
+
+/* Slider */
+.grupa .spremenljivka .ui-slider-pips .ui-slider-pip {
+ color: #505050;
+}
+.grupa .spremenljivka .slider.ui-widget-content {
+ /*background-color: $color_light !important;*/
+ background-image: none !important;
+ border: 0;
+}
+.grupa .spremenljivka .ui-slider-horizontal {
+ height: 8px;
+}
+.grupa .spremenljivka .ui-slider-handle {
+ cursor: pointer;
+ height: 10px !important;
+ width: 18px !important;
+ margin-top: 1px;
+ border: 0;
+ border-radius: 15px 15px !important;
+ background-color: #666666 !important;
+ background-image: none !important;
+}
+.grupa .spremenljivka .ui-slider-handle:active {
+ background-color: #666666 !important;
+}
+.grupa .spremenljivka .sliderText {
+ padding-top: 2px;
+ color: #505050;
+ background-color: #888888;
+ border: 0;
+}
+.grupa .spremenljivka .sliderText::after {
+ border-color: #888888 transparent;
+}
+
+/* Warning levo od vprasanja */
+.validation_alert {
+ position: absolute;
+ z-index: 51;
+ top: 20px;
+ left: -150px;
+ width: 130px;
+ min-height: 29px;
+ margin: 0;
+ text-align: center;
+ font-size: 11px;
+ line-height: 14px;
+ background-color: #eeeeee;
+ border: 2px solid red;
+ padding: 4px 7px;
+ border-radius: 4px;
+ box-shadow: none;
+}
+
+/* Gumbi na dnu */
+div.buttons {
+ padding: 20px 20px 35px;
+ margin: 0 10px;
+}
+div.buttons input {
+ cursor: pointer;
+ margin: 8px 10px;
+ /*padding: 7px 11px;*/
+ padding: 10px 20px;
+ text-align: center;
+ font-size: 12px;
+ letter-spacing: 1px;
+ font-weight: 600;
+ color: #FFFFFF;
+ border-radius: 20px;
+ border: 0;
+}
+div.buttons input.next {
+ background-color: #666666;
+ border: 1px solid #666666;
+}
+div.buttons input.next:hover, div.buttons input.next:focus {
+ background-color: #8c8c8c;
+ border: 1px solid #8c8c8c;
+}
+div.buttons input.prev {
+ color: #666666;
+ background-color: #fff;
+ border: 1px solid #666666;
+}
+div.buttons input.prev:hover, div.buttons input.prev:focus {
+ color: #fff;
+ background-color: #666666;
+}
+
+/* Footer */
+#footer_survey {
+ padding: 40px;
+ background-color: #ffffff;
+ border-top: 1px #eeeeee solid;
+}
+#footer_survey p, #footer_survey a, #footer_survey a:visited {
+ color: #505050;
+ font-size: 14px;
+ line-height: 25px;
+ font-weight: 400;
+ text-decoration: none;
+}
+#footer_survey a:hover, #footer_survey a:active {
+ text-decoration: none;
+}
+
+/* awesome radio in checkboxi */
+input[type=checkbox] + span.enka-checkbox-radio,
+input[type=radio] + span.enka-checkbox-radio,
+.custom_radio_picture.obarvan > label > span.enka-custom-radio:before,
+.visual-radio-scale.checked .enka-vizualna-skala {
+ color: #888888;
+ font-size: 20px;
+ vertical-align: -1px;
+}
+
+input[type=checkbox]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-checkbox-radio:before,
+input[type=radio]:focus + span.enka-custom-radio:before,
+input[type=radio]:focus + span.enka-vizualna-skala::before {
+ color: #484848;
+}
+
+input[type=text]:focus,
+input[type=number]:focus,
+input[type=email]:focus,
+input[type=password]:focus,
+textarea:focus {
+ border-color: #888888;
+}
+
+/* Ranking drag drop */
+.drag_and_drop {
+ top: -9px;
+ left: -12px;
+}
+
+.drag_and_drop_right {
+ top: -9px !important;
+ left: -12px !important;
+}
+
+.frame_dropping_titles {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ border-top: 2px solid #b9c5d9;
+ border-left: 2px solid #b9c5d9;
+ border-right: 2px solid #b9c5d9;
+ font-size: 13px;
+}
+
+.drag_and_drop_box {
+ top: -9px;
+ left: -12px;
+}
+.drag_and_drop_box img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.drag_and_drop_box_right {
+ top: 19px !important;
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_after_refresh {
+ /*top: 44px!important;*/
+ left: -12px !important;
+}
+
+.drag_and_drop_box_right_over {
+ left: -12px !important;
+}
+
+.frame_dropping_titles_box {
+ width: 240px;
+ padding: 5px;
+ margin: 0px auto 0px auto;
+ height: 15px;
+ text-align: center;
+ background-color: #FFFFFF;
+ font-size: 13px;
+}
+
+.frame_dropping {
+ padding: 7px 10px 9px;
+}
+
+.frame_dropping_box {
+ padding: 7px 10px 9px;
+}
+
+/* Popravimo se logo */
+#logo, #logo.english {
+ background-image: url("../../../public/img/logo/uni.png");
+}
+
+/*# sourceMappingURL=Uni.css.map */
diff --git a/main/survey/skins/check-radio/box_checked_blue.png b/main/survey/skins/check-radio/box_checked_blue.png
new file mode 100644
index 0000000..f3051c2
--- /dev/null
+++ b/main/survey/skins/check-radio/box_checked_blue.png
Binary files differ
diff --git a/main/survey/skins/check-radio/box_checked_grey.png b/main/survey/skins/check-radio/box_checked_grey.png
new file mode 100644
index 0000000..ff46ebe
--- /dev/null
+++ b/main/survey/skins/check-radio/box_checked_grey.png
Binary files differ
diff --git a/main/survey/skins/check-radio/box_empty_blue.png b/main/survey/skins/check-radio/box_empty_blue.png
new file mode 100644
index 0000000..4f847b9
--- /dev/null
+++ b/main/survey/skins/check-radio/box_empty_blue.png
Binary files differ
diff --git a/main/survey/skins/check-radio/box_empty_grey.png b/main/survey/skins/check-radio/box_empty_grey.png
new file mode 100644
index 0000000..4a028dd
--- /dev/null
+++ b/main/survey/skins/check-radio/box_empty_grey.png
Binary files differ
diff --git a/main/survey/skins/check-radio/icons.png b/main/survey/skins/check-radio/icons.png
new file mode 100644
index 0000000..bdca73a
--- /dev/null
+++ b/main/survey/skins/check-radio/icons.png
Binary files differ
diff --git a/main/survey/skins/check-radio/icons.psd b/main/survey/skins/check-radio/icons.psd
new file mode 100644
index 0000000..7d8c8b4
--- /dev/null
+++ b/main/survey/skins/check-radio/icons.psd
Binary files differ
diff --git a/main/survey/skins/check-radio/radio_checked_blue.png b/main/survey/skins/check-radio/radio_checked_blue.png
new file mode 100644
index 0000000..1eb053b
--- /dev/null
+++ b/main/survey/skins/check-radio/radio_checked_blue.png
Binary files differ
diff --git a/main/survey/skins/check-radio/radio_checked_grey.png b/main/survey/skins/check-radio/radio_checked_grey.png
new file mode 100644
index 0000000..7a082c5
--- /dev/null
+++ b/main/survey/skins/check-radio/radio_checked_grey.png
Binary files differ
diff --git a/main/survey/skins/check-radio/radio_unchecked_blue.png b/main/survey/skins/check-radio/radio_unchecked_blue.png
new file mode 100644
index 0000000..034bfab
--- /dev/null
+++ b/main/survey/skins/check-radio/radio_unchecked_blue.png
Binary files differ
diff --git a/main/survey/skins/check-radio/radio_unchecked_grey.png b/main/survey/skins/check-radio/radio_unchecked_grey.png
new file mode 100644
index 0000000..39a495f
--- /dev/null
+++ b/main/survey/skins/check-radio/radio_unchecked_grey.png
Binary files differ
diff --git a/main/survey/skins/check-radio/smiley_happy_blue.png b/main/survey/skins/check-radio/smiley_happy_blue.png
new file mode 100644
index 0000000..3a58984
--- /dev/null
+++ b/main/survey/skins/check-radio/smiley_happy_blue.png
Binary files differ
diff --git a/main/survey/skins/check-radio/smiley_happy_grey.png b/main/survey/skins/check-radio/smiley_happy_grey.png
new file mode 100644
index 0000000..22a514a
--- /dev/null
+++ b/main/survey/skins/check-radio/smiley_happy_grey.png
Binary files differ
diff --git a/main/survey/skins/check-radio/star_blue.png b/main/survey/skins/check-radio/star_blue.png
new file mode 100644
index 0000000..9432712
--- /dev/null
+++ b/main/survey/skins/check-radio/star_blue.png
Binary files differ
diff --git a/main/survey/skins/check-radio/star_empty_blue.png b/main/survey/skins/check-radio/star_empty_blue.png
new file mode 100644
index 0000000..2599957
--- /dev/null
+++ b/main/survey/skins/check-radio/star_empty_blue.png
Binary files differ
diff --git a/main/survey/skins/check-radio/thumbs_up.png b/main/survey/skins/check-radio/thumbs_up.png
new file mode 100644
index 0000000..9fa7ffb
--- /dev/null
+++ b/main/survey/skins/check-radio/thumbs_up.png
Binary files differ
diff --git a/main/survey/skins/check-radio/thumbs_up_blue.png b/main/survey/skins/check-radio/thumbs_up_blue.png
new file mode 100644
index 0000000..a8e1388
--- /dev/null
+++ b/main/survey/skins/check-radio/thumbs_up_blue.png
Binary files differ
diff --git a/main/survey/skins/fdv/fdv.png b/main/survey/skins/fdv/fdv.png
new file mode 100644
index 0000000..e3046de
--- /dev/null
+++ b/main/survey/skins/fdv/fdv.png
Binary files differ
diff --git a/main/survey/skins/glasovanje/Classic.css b/main/survey/skins/glasovanje/Classic.css
new file mode 100644
index 0000000..c0c943f
--- /dev/null
+++ b/main/survey/skins/glasovanje/Classic.css
@@ -0,0 +1,58 @@
+/*p, #arhiv {
+ font-size: 12px;
+}*/
+
+.glas_settings_title p{
+ padding: 5px 0 !important;
+
+ /*font-size: 14px;
+ font-weight: bold;*/
+}
+
+#graph{
+ width: 340px;
+ height: 10px;
+ background-color: #dddddd;
+ border: 1px #aaaaaa solid;
+}
+
+#graph .graph_fill{
+ height: 10px;
+ background-color: #0c377a;
+}
+
+.spol{
+ margin: 20px 0 0 0;
+ font-weight: bold;
+}
+.spol table tr td{
+ vertical-align: bottom;
+}
+.spol_buttons{
+ width: 330px;
+ margin: 15px 10px;
+
+ text-align: center;
+}
+.spol_buttons input{
+ cursor: pointer;
+ width: 75px;
+ padding: 2px;
+ margin: 0 4px 0 4px;
+
+ background-color: #eff2f7;
+ border: 1px solid #dfe2e7;
+ color: #0c377a;
+ border-radius: 3px;
+}
+.spol_buttons input:hover,
+.spol_buttons input.active{
+ color: white;
+ background-color: #0c377a;
+ border: 1px solid #0c377a;
+}
+
+#arhiv a:link{text-decoration: none; color: #0000bb;}
+#arhiv a:visited{text-decoration: none; color: #0000bb;}
+#arhiv a:active{text-decoration: none; color: #0000bb;}
+#arhiv a:hover{text-decoration: none; color: #6666ff;} \ No newline at end of file
diff --git a/main/survey/skins/glasovanje/Modern.css b/main/survey/skins/glasovanje/Modern.css
new file mode 100644
index 0000000..9face9a
--- /dev/null
+++ b/main/survey/skins/glasovanje/Modern.css
@@ -0,0 +1,45 @@
+.glas_settings_title p{
+ padding: 5px 0 !important;
+
+ /*font-size: 14px;
+ font-weight: bold;*/
+}
+
+#graph{
+ width: 340px;
+ height: 2px;
+ background-color: #BBBBBB;
+ border: 1px #888888 solid;
+}
+
+#graph .graph_fill{
+ height: 2px;
+ background-color: #ff0000;
+}
+
+.spol{
+ margin: 20px 0 0 0;
+ font-weight: bold;
+}
+.spol table tr td{
+ vertical-align: bottom;
+}
+.spol_buttons{
+ width: 330px;
+ margin: 10px;
+
+ text-align: center;
+}
+.spol_buttons input{
+ width: 60px;
+ margin: 0 2px 0 2px;
+}
+.spol_buttons input.active{
+ font-weight: bold;
+ color: #bb0000;
+}
+
+#arhiv a:link{text-decoration: none; color: #bb0000;}
+#arhiv a:visited{text-decoration: none; color: #bb0000;}
+#arhiv a:active{text-decoration: none; color: #bb0000;}
+#arhiv a:hover{text-decoration: none; color: #ff5555;}
diff --git a/main/survey/skins/quiz/false.png b/main/survey/skins/quiz/false.png
new file mode 100644
index 0000000..3589f7b
--- /dev/null
+++ b/main/survey/skins/quiz/false.png
Binary files differ
diff --git a/main/survey/skins/quiz/quiz.css b/main/survey/skins/quiz/quiz.css
new file mode 100644
index 0000000..419b372
--- /dev/null
+++ b/main/survey/skins/quiz/quiz.css
@@ -0,0 +1,62 @@
+
+/* PRIKAZ REZULTATOV */
+#quiz_results{
+ /*border-top: 1px solid #b9c5d9;*/
+ margin: 20px 10px 0 10px;
+ padding: 10px 2px 0px 12px !important;
+}
+
+#quiz_results h2{
+ margin: 20px auto 0px;
+ padding: 0;
+
+ text-align: center;
+ color: #0c377a;
+ font-size: 17px;
+}
+
+#quiz_results .spremenljivka .variabla{
+ /*height: 18px;*/
+ line-height: 18px;
+}
+#quiz_results .spremenljivka .variabla.red{
+ color: #ff0000;
+ font-weight: 600;
+}
+#quiz_results .spremenljivka .variabla.green{
+ color: #66c24a;
+ font-weight: 600;
+}
+#quiz_results .spremenljivka .variabla.bold{
+ color: #66c24a;
+ font-weight: 600;
+}
+
+#quiz_results .spremenljivka .variabla .true,
+#quiz_results .spremenljivka .variabla .true2,
+#quiz_results .spremenljivka .variabla .false{
+ display: inline-block;
+ width: 18px;
+ height: 14px;
+
+ vertical-align: middle;
+ line-height: normal;
+ margin: -4px 0 0 15px;
+
+ background-repeat: no-repeat;
+}
+#quiz_results .spremenljivka .variabla .true{
+ background-image: url("true.png");
+}
+#quiz_results .spremenljivka .variabla .true2{
+ background-image: url("true2.png");
+}
+#quiz_results .spremenljivka .variabla .false{
+ background-image: url("false.png");
+}
+
+
+/* PRIKAZ GRAFA */
+#quiz_results_chart_holder{
+ height: 200px;
+}
diff --git a/main/survey/skins/quiz/true.png b/main/survey/skins/quiz/true.png
new file mode 100644
index 0000000..f82366b
--- /dev/null
+++ b/main/survey/skins/quiz/true.png
Binary files differ
diff --git a/main/survey/skins/quiz/true2.png b/main/survey/skins/quiz/true2.png
new file mode 100644
index 0000000..0ac2f69
--- /dev/null
+++ b/main/survey/skins/quiz/true2.png
Binary files differ
diff --git a/main/survey/skins/tooltipster/tooltipster.css b/main/survey/skins/tooltipster/tooltipster.css
new file mode 100644
index 0000000..0e20fa2
--- /dev/null
+++ b/main/survey/skins/tooltipster/tooltipster.css
@@ -0,0 +1,288 @@
+/* This is the default Tooltipster theme (feel free to modify or duplicate and create multiple themes!): */
+.tooltipster-default {
+ border-radius: 5px;
+ border: 2px solid #000;
+ background: #4c4c4c;
+ color: #fff;
+}
+
+/* Use this next selector to style things like font-size and line-height: */
+.tooltipster-default .tooltipster-content {
+ font-family: Arial, sans-serif;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 8px 10px;
+ overflow: hidden;
+}
+
+/* This next selector defines the color of the border on the outside of the arrow. This will automatically match the color and size of the border set on the main tooltip styles. Set display: none; if you would like a border around the tooltip but no border around the arrow */
+.tooltipster-default .tooltipster-arrow .tooltipster-arrow-border {
+ /* border-color: ... !important; */
+}
+
+
+/* If you're using the icon option, use this next selector to style them */
+.tooltipster-icon {
+ cursor: help;
+ margin-left: 4px;
+}
+
+
+
+
+
+
+
+
+/* This is the base styling required to make all Tooltipsters work */
+.tooltipster-base {
+ padding: 0;
+ font-size: 0;
+ line-height: 0;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 9999999;
+ pointer-events: none;
+ width: auto;
+ overflow: visible;
+}
+.tooltipster-base .tooltipster-content {
+ overflow: hidden;
+}
+
+
+/* These next classes handle the styles for the little arrow attached to the tooltip. By default, the arrow will inherit the same colors and border as what is set on the main tooltip itself. */
+.tooltipster-arrow {
+ display: block;
+ text-align: center;
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: -1;
+}
+.tooltipster-arrow span, .tooltipster-arrow-border {
+ display: block;
+ width: 0;
+ height: 0;
+ position: absolute;
+}
+.tooltipster-arrow-top span, .tooltipster-arrow-top-right span, .tooltipster-arrow-top-left span {
+ border-left: 8px solid transparent !important;
+ border-right: 8px solid transparent !important;
+ border-top: 8px solid;
+ bottom: -7px;
+}
+.tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-top-left .tooltipster-arrow-border {
+ border-left: 9px solid transparent !important;
+ border-right: 9px solid transparent !important;
+ border-top: 9px solid;
+ bottom: -7px;
+}
+
+.tooltipster-arrow-bottom span, .tooltipster-arrow-bottom-right span, .tooltipster-arrow-bottom-left span {
+ border-left: 8px solid transparent !important;
+ border-right: 8px solid transparent !important;
+ border-bottom: 8px solid;
+ top: -7px;
+}
+.tooltipster-arrow-bottom .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border {
+ border-left: 9px solid transparent !important;
+ border-right: 9px solid transparent !important;
+ border-bottom: 9px solid;
+ top: -7px;
+}
+.tooltipster-arrow-top span, .tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-bottom span, .tooltipster-arrow-bottom .tooltipster-arrow-border {
+ left: 0;
+ right: 0;
+ margin: 0 auto;
+}
+.tooltipster-arrow-top-left span, .tooltipster-arrow-bottom-left span {
+ left: 6px;
+}
+.tooltipster-arrow-top-left .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border {
+ left: 5px;
+}
+.tooltipster-arrow-top-right span, .tooltipster-arrow-bottom-right span {
+ right: 6px;
+}
+.tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border {
+ right: 5px;
+}
+.tooltipster-arrow-left span, .tooltipster-arrow-left .tooltipster-arrow-border {
+ border-top: 8px solid transparent !important;
+ border-bottom: 8px solid transparent !important;
+ border-left: 8px solid;
+ top: 50%;
+ margin-top: -7px;
+ right: -7px;
+}
+.tooltipster-arrow-left .tooltipster-arrow-border {
+ border-top: 9px solid transparent !important;
+ border-bottom: 9px solid transparent !important;
+ border-left: 9px solid;
+ margin-top: -8px;
+}
+.tooltipster-arrow-right span, .tooltipster-arrow-right .tooltipster-arrow-border {
+ border-top: 8px solid transparent !important;
+ border-bottom: 8px solid transparent !important;
+ border-right: 8px solid;
+ top: 50%;
+ margin-top: -7px;
+ left: -7px;
+}
+.tooltipster-arrow-right .tooltipster-arrow-border {
+ border-top: 9px solid transparent !important;
+ border-bottom: 9px solid transparent !important;
+ border-right: 9px solid;
+ margin-top: -8px;
+}
+
+
+/* Some CSS magic for the awesome animations - feel free to make your own custom animations and reference it in your Tooltipster settings! */
+
+.tooltipster-fade {
+ opacity: 0;
+ -webkit-transition-property: opacity;
+ -moz-transition-property: opacity;
+ -o-transition-property: opacity;
+ -ms-transition-property: opacity;
+ transition-property: opacity;
+}
+.tooltipster-fade-show {
+ opacity: 1;
+}
+
+.tooltipster-grow {
+ -webkit-transform: scale(0,0);
+ -moz-transform: scale(0,0);
+ -o-transform: scale(0,0);
+ -ms-transform: scale(0,0);
+ transform: scale(0,0);
+ -webkit-transition-property: -webkit-transform;
+ -moz-transition-property: -moz-transform;
+ -o-transition-property: -o-transform;
+ -ms-transition-property: -ms-transform;
+ transition-property: transform;
+ -webkit-backface-visibility: hidden;
+}
+.tooltipster-grow-show {
+ -webkit-transform: scale(1,1);
+ -moz-transform: scale(1,1);
+ -o-transform: scale(1,1);
+ -ms-transform: scale(1,1);
+ transform: scale(1,1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+}
+
+.tooltipster-swing {
+ opacity: 0;
+ -webkit-transform: rotateZ(4deg);
+ -moz-transform: rotateZ(4deg);
+ -o-transform: rotateZ(4deg);
+ -ms-transform: rotateZ(4deg);
+ transform: rotateZ(4deg);
+ -webkit-transition-property: -webkit-transform, opacity;
+ -moz-transition-property: -moz-transform;
+ -o-transition-property: -o-transform;
+ -ms-transition-property: -ms-transform;
+ transition-property: transform;
+}
+.tooltipster-swing-show {
+ opacity: 1;
+ -webkit-transform: rotateZ(0deg);
+ -moz-transform: rotateZ(0deg);
+ -o-transform: rotateZ(0deg);
+ -ms-transform: rotateZ(0deg);
+ transform: rotateZ(0deg);
+ -webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ -moz-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ -ms-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ -o-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+}
+
+.tooltipster-fall {
+ top: 0;
+ -webkit-transition-property: top;
+ -moz-transition-property: top;
+ -o-transition-property: top;
+ -ms-transition-property: top;
+ transition-property: top;
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+}
+.tooltipster-fall-show {
+}
+.tooltipster-fall.tooltipster-dying {
+ -webkit-transition-property: all;
+ -moz-transition-property: all;
+ -o-transition-property: all;
+ -ms-transition-property: all;
+ transition-property: all;
+ top: 0px !important;
+ opacity: 0;
+}
+
+.tooltipster-slide {
+ left: -40px;
+ -webkit-transition-property: left;
+ -moz-transition-property: left;
+ -o-transition-property: left;
+ -ms-transition-property: left;
+ transition-property: left;
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+}
+.tooltipster-slide.tooltipster-slide-show {
+}
+.tooltipster-slide.tooltipster-dying {
+ -webkit-transition-property: all;
+ -moz-transition-property: all;
+ -o-transition-property: all;
+ -ms-transition-property: all;
+ transition-property: all;
+ left: 0px !important;
+ opacity: 0;
+}
+
+
+/* CSS transition for when contenting is changing in a tooltip that is still open. The only properties that will NOT transition are: width, height, top, and left */
+.tooltipster-content-changing {
+ opacity: 0.5;
+ -webkit-transform: scale(1.1, 1.1);
+ -moz-transform: scale(1.1, 1.1);
+ -o-transform: scale(1.1, 1.1);
+ -ms-transform: scale(1.1, 1.1);
+ transform: scale(1.1, 1.1);
+}
+
+.tooltipster-shadow {
+ border-radius: 5px;
+ background: #fff;
+ box-shadow: 0px 0px 14px rgba(0,0,0,0.3);
+ color: #2c2c2c;
+ border: 2px solid #c0c0c0;
+}
+.tooltipster-shadow .tooltipster-content {
+ font-family: 'Arial', sans-serif;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 8px 10px;
+}
diff --git a/main/survey/skins/uni/uni.png b/main/survey/skins/uni/uni.png
new file mode 100644
index 0000000..c896228
--- /dev/null
+++ b/main/survey/skins/uni/uni.png
Binary files differ
diff --git a/main/survey/uporabnost.php b/main/survey/uporabnost.php
new file mode 100644
index 0000000..413746d
--- /dev/null
+++ b/main/survey/uporabnost.php
@@ -0,0 +1,44 @@
+<?php
+
+include_once('../../function.php');
+include_once '../../vendor/autoload.php';
+
+echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+';
+
+echo '<head>'."\n\r";
+echo ' <title>OneClick Survey</title>'."\n\r";
+echo ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n\r";
+echo '</head>';
+
+$anketa = $_GET['anketa'];
+
+$sql = sisplet_query("SELECT uporabnost_link FROM srv_anketa WHERE id = '$anketa'");
+$row = mysqli_fetch_array($sql);
+
+SurveySetting::getInstance()->Init($anketa);
+$uporabnost_razdeli = SurveySetting::getInstance()->getSurveyMiscSetting('uporabnost_razdeli');
+
+if (true || ($row['uporabnost_link'] != null && $row['uporabnost_link'] != "")) {
+ echo '
+ <frameset '.($uporabnost_razdeli!=1?'rows':'cols').'="50%,50%">
+ <frame name="link" src="'.(strlen($row['uporabnost_link'])>7?$row['uporabnost_link']:'').'">
+ <frame name="survey" src="'.$site_url.'main/survey/index.php?anketa='.$anketa.''.($_GET['preview']=='on'?'&preview=on':'').''.(isset($_GET['sist_link'])?'&sist_link='.$_GET['sist_link']:'').(isset($_GET['code'])?'&code='.$_GET['code']:'').'">
+ </frameset>
+ ';
+} else {
+ echo '
+ <frameset>
+ <frame name="survey" src="'.$site_url.'main/survey/index.php?anketa='.$anketa.''.($_GET['preview']=='on'?'&preview=on':'').''.(isset($_GET['sist_link'])?'&sist_link='.$_GET['sist_link']:'').(isset($_GET['code'])?'&code='.$_GET['code']:'').'">
+ </frameset>
+ ';
+}
+
+echo '
+</body>
+</html>';
+
+?> \ No newline at end of file
diff --git a/main/survey/view_count.php b/main/survey/view_count.php
new file mode 100644
index 0000000..843df50
--- /dev/null
+++ b/main/survey/view_count.php
@@ -0,0 +1,16 @@
+<?php
+
+/**
+* Stevcek, ki steje stevilo ogledov linka na anketo (dodan je kot slika)
+*/
+
+include_once('../../function.php');
+include_once '../../vendor/autoload.php';
+
+$anketa = $_GET['a'];
+
+SurveySetting::getInstance()->setSID($anketa);
+$view_count = SurveySetting::getInstance()->getSurveyMiscSetting('view_count');
+SurveySetting::getInstance()->setSurveyMiscSetting('view_count', ($view_count+1)."");
+
+?> \ No newline at end of file